Re: [R] getting the smoother matrix from smooth.spline

From: Simon Wood <sw283_at_maths.bath.ac.uk>
Date: Sat 01 Jul 2006 - 23:47:52 EST

maybe not directly, as it's returning the hat/influence/smoother matrix rather than the model/design matrix itself... however a similar trick which manipulated the `fit$coef' component of a single spline fit and then predicted from this at the x values would be one way of extracting the model matrix.

> Perhaps this could be developed into a spline smooth method
> for model.matrix and included in R.
>
> On 6/30/06, Simon Wood <sw283@maths.bath.ac.uk> wrote:
>> smooth.matrix = function(x, df){
>> n = length(x);
>> A = matrix(0, n, n);
>> for(i in 1:n){
>> y = rep(0, n); y[i]=1;
>> yi = predict(smooth.spline(x, y, df=df),x)$y;
>> A[,i]= yi;
>> }
>> (A+t(A))/2;
>> }
>>
>>
>> >- Simon Wood, Mathematical Sciences, University of Bath, Bath BA2 7AY
>> >- +44 (0)1225 386603 www.maths.bath.ac.uk/~sw283/

>>
>>
>> On Sat, 24 Jun 2006, Gregory Gentlemen wrote:
>>
>> > Can anyone tell me the trick for obtaining the smoother matrix from
>> smooth.spline when there are non-unique values for x. I have the following
>> code but, of course, it only works when all values of x are unique.
>> >
>> > ## get the smoother matrix (x having unique values
>> > smooth.matrix = function(x, df){
>> > n = length(x);
>> > A = matrix(0, n, n);
>> > for(i in 1:n){
>> > y = rep(0, n); y[i]=1;
>> > yi = smooth.spline(x, y, df=df)$y;
>> > A[,i]= yi;
>> > }
>> > (A+t(A))/2;
>> > }
>> >
>> >
>> > Thanks for any assistance,
>> > Gregory
>> >
>> >
>> > ---------------------------------
>> >
>> > ---------------------------------
>> > Get a sneak peak at messages with a handy reading pane.
>> > [[alternative HTML version deleted]]
>> >
>> > ______________________________________________
>> > R-help@stat.math.ethz.ch mailing list
>> > https://stat.ethz.ch/mailman/listinfo/r-help
>> > PLEASE do read the posting guide!
>> http://www.R-project.org/posting-guide.html
>> >
>>
>> ______________________________________________
>> R-help@stat.math.ethz.ch mailing list
>> https://stat.ethz.ch/mailman/listinfo/r-help
>> PLEASE do read the posting guide!
>> http://www.R-project.org/posting-guide.html
>>
>



R-help@stat.math.ethz.ch mailing list
https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html Received on Sat Jul 01 23:59:28 2006

Archive maintained by Robert King, hosted by the discipline of statistics at the University of Newcastle, Australia.
Archive generated by hypermail 2.1.8, at Sun 02 Jul 2006 - 02:13:18 EST.

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