predict_sp {lazy.stat} | R Documentation |
Predicting from Spline Regression
predict_sp(object, xnew)
object |
Output of spreg containing: |
xnew |
A new x varaibale at which to predict y |
If the object contains the result of b-spline, it must have
boundary.knots parameters.
If the object contains the result of p-spline, it must have
all the p-spline options such as
rescale orth, xrange, xrange0, Xrange0.
A list of:
xnew The input
ynew The prediction at xnew: ynew = X %*% beta
X The design matrix
set.seed(1701) n <- 20 x <- floor(10*runif(n)) y <- 10*runif(n)+1.5*sort(x) # spline regression of y on x res=spreg( y,x, type="b", nknots=2, plot=1, print=1 ) # prediction xnew=seq(0,10,.1) res2=predict_sp( res, xnew ) ynew=res2$ynew # plot plot(x,y, xlim=c(0,10), ylim=c(0,25)) par(new=TRUE) plot(xnew,ynew,type="o",xlim=c(0,10), ylim=c(0,25))