Re: [Rd] Rd] Numerics behind splineDesign

From: Terry Therneau <therneau_at_mayo.edu>
Date: Thu, 02 Aug 2012 12:26:08 -0500

Clearly, I got it wrong.
Thanks to others for the clearer and correct message. Terry T

On 08/02/2012 11:59 AM, William Dunlap wrote:
> If R's bs() and ns() are like S+'s (they do give very similar results* and
> S+'s were written by Doug Bates), then bs() does not do any linear algebra
> (like qr()) on splineDesign's output. bs() needs to come up with a default
> set of knots (if the user didn't supply them), combine the Boundary.knots
> (repeated ord times) and knots into one vector to pass to splineDesign,
> and, if there are any x's outside of range(Boundary.knots), treat them specially.
>
> ns() needs to project splineDesign's basis functions onto the subspace
> of functions whose 2nd derivatives are zero at the endpoints. The projection
> can be done with qr() and friends (S+ uses qr()).
>
> (If you want basis functions for a periodic spline you could use a similar procedure
> to project to the subspace of functions whose first and second derivatives
> match at the upper and lower Boundary.knots.)
>
> * The only difference between the R and S+ versions of bs() that I've noticed
> is in how they deal with the x's that are outside of range(Boundary.knots).
> S+ extrapolates with cubics both above and below that range while R extrapolates
> with a cubic below the range and with a quadratic above the range. I don't know
> what the rationale for this is.
>
> Bill Dunlap
> Spotfire, TIBCO Software
> wdunlap tibco.com
>
>
>> -----Original Message-----
>> From: r-devel-bounces_at_r-project.org [mailto:r-devel-bounces_at_r-project.org] On Behalf
>> Of Terry Therneau
>> Sent: Thursday, August 02, 2012 6:10 AM
>> To: r-devel_at_r-project.org; Nathaniel Smith
>> Subject: Re: [Rd] Rd] Numerics behind splineDesign
>>
>>
>>
>> On 08/02/2012 05:00 AM, r-devel-request_at_r-project.org wrote:
>>> 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
>> The ns and bs function post-process the spline bases to get an
>> orthagonal basis matrix, this is the use of qr. I think this causes
>> much more grief than it is worth, for the sake of a small increase in
>> numeric stability. For instance when you plot the spline bases, they
>> don't look anything like the basis functions one would expect. (Perhaps
>> my background in numerical analysis was a hindrance here, since I know
>> something about splines and thus have an expectation).
>>
>> Terry Therneau
>>
>> ______________________________________________
>> R-devel_at_r-project.org mailing list
>> https://stat.ethz.ch/mailman/listinfo/r-devel



R-devel_at_r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/r-devel Received on Thu 02 Aug 2012 - 17:28:51 GMT

This quarter's messages: by month, or sorted: [ by date ] [ by thread ] [ by subject ] [ by author ]

All messages

Archive maintained by Robert King, hosted by the discipline of statistics at the University of Newcastle, Australia.
Archive generated by hypermail 2.2.0, at Thu 02 Aug 2012 - 17:30:35 GMT.

Mailing list information is available at https://stat.ethz.ch/mailman/listinfo/r-devel. Please read the posting guide before posting to the list.

list of date sections of archive