From gunter.berton at gene.com  Wed Aug  1 18:03:06 2012
From: gunter.berton at gene.com (Bert Gunter)
Date: Wed, 1 Aug 2012 09:03:06 -0700
Subject: [Rd] Numerics behind splineDesign
In-Reply-To: <CAPJVwBnB6-=V7PMejU0qe9WG1YLn1d3gDGFQd-timyYEwkdZkQ@mail.gmail.com>
References: <CAPJVwB=ppJ=SOs9k0p5ZHqGdnk8L1MZMBUbCSQ6oH5Zd5Pwpig@mail.gmail.com>
	<loom.20120731T152127-870@post.gmane.org>
	<CACk-te3ERmEVe2f2YqU8t5iFSVj0E9a4RGDTudDvGiAUyUQUtg@mail.gmail.com>
	<D7CCBAE0-4D80-436D-8594-17EDF691A75A@gmail.com>
	<CAPJVwBnB6-=V7PMejU0qe9WG1YLn1d3gDGFQd-timyYEwkdZkQ@mail.gmail.com>
Message-ID: <CACk-te2bWUuvngQ6JiQ-QR0K+Dx4Mwh33pL-qB0d5o+EKgVz_g@mail.gmail.com>

Inline...

On Wed, Aug 1, 2012 at 8:36 AM, Nathaniel Smith <njs at pobox.com> wrote:
> Thanks everyone for the suggestions.
>
> On Wed, Aug 1, 2012 at 2:39 PM, peter dalgaard <pdalgd at gmail.com> wrote:
>>
>> On Jul 31, 2012, at 15:46 , Bert Gunter wrote:
>>
>>> Well, I would first check the references given in the Help file!.
>>> That's what they're for, no?  Hastie's book is likely to more complete
>>> on the algebra, I think.
>
> How embarrassing... the help files do cite the white book (only), and
> I did check it of course, but it has no more details on how the basis
> functions are computed than does the help file itself, and so I must
> have forgotten about it when writing my email. Still, my apologies for
> the confusion.
>
> I'm not sure what you mean by "Hastie's book", though?

Ummm...  The following appears in the  ?bs man page. Why do you not
see it? Are you perhaps being too "hasty" in your reading (heh-heh)?

References

Hastie, T. J. (1992) Generalized additive models. Chapter 7 of
Statistical Models in S eds J. M. Chambers and T. J. Hastie, Wadsworth
& Brooks/Cole.

-- Bert
>
>>> You might also be interested in the relevant chapters of Friedman,
>>> Hastie, et. al "The Elements of Statistical Learning Theory," which
>>> might be a gentler exposition of the math.
>>>
>>> Of course, the code (or a suitable exposition of it, which may not
>>> exist) is the ultimate reference.
>>
>> Also check out the various web resources (Google for basis spline or B-spline). I don't recall the white book chapter, but it might be a little short on the algebraic details. Another Google point is "de Boor".
>
> And indeed, it looks like the appendix to chapter 5 of Hastie,
> Tibshirani, and Friedman (2008) has a short description of the de Boor
> algorithm. Excellent. For the archives, this seems to be enough to
> exactly implement spline.des/splineDesign, and if anyone else is
> working in Python then it turns out that there is a more-or-less
> undocumented implementation of this algorithm in
> scipy.interpolate.splev.
>
> Now I just have to grovel over the R code in ns() and bs() to figure
> out how exactly they pick knots and handle boundary conditions, plus
> there is some code that I don't understand in ns() that uses qr() to
> postprocess the output from spline.des. I assume this is involved
> somehow in imposing the boundary conditions...
>
> Thanks again everyone for your help,
> -- Nathaniel



-- 

Bert Gunter
Genentech Nonclinical Biostatistics

Internal Contact Info:
Phone: 467-7374
Website:
http://pharmadevelopment.roche.com/index/pdb/pdb-functional-groups/pdb-biostatistics/pdb-ncb-home.htm



[Rd] Numerics behind splineDesign
Bert Gunter