I constructed a model of the form:

mdl.gam<-gam(sqrt(y) ~ s(x1,fx=FALSE,k=-1,bs="cs")+s(x2,fx=FALSE,k=-1,bs="cs")+
        s(x9,fx=FALSE,k=-1,bs="cs") + s(x10,fx=FALSE,k=-1,bs="cs")+
        s(x11,fx=FALSE,k=-1,bs="cs") + s(x12,fx=FALSE,k=-1,bs="cs"),  
        data = data) 

The error message I get is:

Error in smooth.construct.cr.smooth.spec(object, data, knots) : 
x9 has insufficient unique values to support 10 knots: reduce k.

I have two questions:

1) Isn't the the option fx=FALSE, k = -1 supposed to determined optimal number of knots through cross validation? If yes, then I should not have an error saying x9 does not support 10 knots since number of knots is being determined by cross validation

2) bs=cs is fitting a cubic regression spline with shrinkage. Does it mean it will penalise the model for over-fitting and hence determined the optimal number of knots to fit in the model? How is it different from bs=cr?




Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.