Anybody knows how to generate the basis matrix for smoothing spline? And how about the smoother matrix? I tried to use the following code, but there exist replicated data in X, and the length of smooth.spline(X, S[,i])$y is smaller than X, and then there is error in the last step. spl <- smooth.spline(X, Y) S <- diag(X) for (i in 1:N) S[i,] <- smooth.spline(X, S[,i])$y #smoother matrix S Someone help please! Thanks in advance. -- View this message in context: http://n4.nabble.com/Smoothing-Spline-Basis-Matrix-tp1573131p1573131.html Sent from the R help mailing list archive at Nabble.com.
I believe that smooth.spline fits a cubic B-spline to the data. So you just need to know the knot points (which are returned by smooth.spline as spl$fit$knot) and then use the bs() function in the splines library. pinkdd wrote:> > Anybody knows how to generate the basis matrix for smoothing spline? > > And how about the smoother matrix? I tried to use the following code, but > there exist replicated data in X, and the length of smooth.spline(X, > S[,i])$y is smaller than X, and then there is error in the last step. > > spl <- smooth.spline(X, Y) > S <- diag(X) > for (i in 1:N) > S[i,] <- smooth.spline(X, S[,i])$y #smoother matrix S > > > Someone help please! Thanks in advance. >-- View this message in context: http://n4.nabble.com/Smoothing-Spline-Basis-Matrix-tp1573131p1573597.html Sent from the R help mailing list archive at Nabble.com.