Kilometres has only 5 unique values, while Bonus has only 7, but the default smoothing basis dimension for the s terms is 10, so there is a problem. Solution is to reduce the basis dimension. e.g.

amgam <- gam(log(Payment) ~ offset(log(Insured))+
+ s(as.numeric(Kilometres),k=5) + s(Bonus,k=7) + Make + s(Claims),family = gaussian,
+ data = motori)


On 08/11/11 16:57, Gyanendra Pokharel wrote:
Hi R community!
I am analyzing the data set "motorins" in the package "faraway" by using
the generalized additive model. it shows the following error. Can some one
suggest me the right way?

library(faraway)
data(motorins)
motori<- motorins[motorins$Zone==1,]
library(mgcv)
amgam<- gam(log(Payment) ~ offset(log(Insured))+
s(as.numeric(Kilometres)) + s(Bonus) + Make + s(Claims),family = gaussian,
data = motori)
Error in smooth.construct.tp.smooth.
spec(object, dk$data, dk$knots) :
   A term has fewer unique covariate combinations than specified maximum
degrees of freedom
summary(amgam)
Error in summary(amgam) : object 'amgam' not found
Gyan

        [[alternative HTML version deleted]]

______________________________________________
R-help@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
and provide commented, minimal, self-contained, reproducible code.



--
Simon Wood, Mathematical Science, University of Bath BA2 7AY UK
+44 (0)1225 386603               http://people.bath.ac.uk/sw283

______________________________________________
R-help@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
and provide commented, minimal, self-contained, reproducible code.

Reply via email to