I want to fit a smoothing spline using gam function. An attempt to plot the fitted values is resulting in an error -object$nsdf? I am wondering if that is a needed input and if so what is df referring to? How to fix this code.
gam.fit=gam(y~s(disp,6)+s(hp,5)+s(wt,5), data=train.dat)
mean((test.dat$y - gam.pred)^2) # 0.0002282536
plot(gam.fit, se=TRUE, col="blue",main="10.3f.gam")
# Error in 1:object$nsdf : argument of length 0
Thank you. Sincerely, Mary A. Marion