Re: [R] Closed form for regression splines

From: Frank E Harrell Jr <>
Date: Tue 06 Dec 2005 - 02:11:32 EST

roger koenker wrote:

> you can do:
> 	X <- model.matrix(formula, data =
> url:            Roger Koenker

Or use a simpler basis such as the truncated power basis, and rely on accuracy of modern matrix algebra routines to handle the non-orthogonality:

f <- fittingfunction(y ~ rcs(age,5)+sex) Function(f) # see algebraic form
latex(f) # see nicely typeset algebraic form publish2Web(f) # Planned future function for evaluating models on the web using R's predict( ) function

Frank Harrell

> email            Department of Economics
> vox:     217-333-4558                University of Illinois
> fax:       217-244-6678                Champaign, IL 61820
> On Dec 5, 2005, at 7:36 AM, Stephen A Roberts wrote:

>>I have a model fitted using bs() and need to be able to write down
>>a closed form for the spline function to enable the use of the
>>fitted model outside R. Does anyone know a simple way of extracting
>>the piecewise cubics from the coefficients and knots? As far as I
>>know they are defined by recurrence relationships, but the R
>>implementation is buried in C code, and I guess in non-trivial to
>>invert. I know about within R, but I want the full
>>piecewise cubic.
>> Dr Steve Roberts
>>Senior Lecturer in Medical Statistics,
>>Biostatistics Group,
>>University of Manchester,
>> mailing list
>>PLEASE do read the posting guide!
> ______________________________________________
> mailing list
> PLEASE do read the posting guide!

Frank E Harrell Jr   Professor and Chair           School of Medicine
                      Department of Biostatistics   Vanderbilt University

______________________________________________ mailing list PLEASE do read the posting guide! Received on Tue Dec 06 02:19:14 2005

This archive was generated by hypermail 2.1.8 : Tue 06 Dec 2005 - 04:25:40 EST