Skip to content

how to use the basis matrix of "ns" in R? really confused by multi-dim spline filtering?

3 messages · Michael, vito muggeo

#
Dear Micheal,

 > the output of the "ns" function in R is "basis matrix", but then
Yes you are right, the output of the ns(x, df) is the basis matrix of a 
natural cubic spline with df degrees of freedom. See ?ns (in package 
splines) on how to specify df or knots or ..

Fitting y~ns(x,df) yields a smooth curve given by a linear combination 
of the basis functions (the single colums of the basis matrix) by the 
estimated coefficients (returned by the fitted model).

As far as I know, a tensor product is usually employed to 
multidimensional smoothing and the multidimensional basis is formed via 
the kronecker product of the marginal bases.

Finally, last but not least: Probably you need some statistical 
backaground on spline fitting..
Please, read some statistical papers/books on such topic (for instance 
see references in packages splines, mgcv)

best,
vito
Michael wrote: