wang cheng
2011-Mar-10 15:07 UTC
[R] ERROR: gamm function (mgcv package). attempt to set an attribute on NULL
Hello:I run a gamm with following call :mode<-gamm(A~B,random=list(ID=~1),family=gaussian,na.action=na.omit,data=rs)an error happened:ERROR names(object$sp) <- names(G$sp) : attempt to set an attribute on NULLwith mgcv version 1.7-3What so? How can I correct the Error? Thanks very much for any help. [[alternative HTML version deleted]]
Ben Bolker
2011-Mar-11 02:10 UTC
[R] ERROR: gamm function (mgcv package). attempt to set an attribute on NULL
wang cheng <cheng_wang29 <at> yahoo.com.cn> writes:> > Hello:I run a gamm with following call > :mode<-gamm(A~B,random=list(ID=~1),family=gaussian,na.action=na.omit,data=rs)an error> happened:ERROR names(object$sp) <- names(G$sp) : attempt to set anattribute on NULL with mgcv version 1.7-3 What so? How can I correct the Error? Thanks very much for any help.>Thank you for telling us that you are using a function within a contributed package, but ... Please read the posting guide. We are unlikely to be able to help without a reproducible example, unless you happen to have encountered a very common error. Update: I was able to guess what your problem was and create my own reproducible example. You have specified a generalized additive mixed model (GAMM) without any smooth terms, which means that you really don't need gamm (or the mgcv package in general) to do the problem. rs <- data.frame(A=1:20,B=1:20,ID=rep(1:2,each=10))> gamm(A~B,random=list(ID=~1),family=gaussian,na.action=na.omit,data=rs)Error in names(object$sp) <- names(G$sp) : attempt to set an attribute on NULL You could run the model you have requested via library(nlme) lme(A~B,random=~1|ID,na.action=na.omit,data=rs) good luck (it would still be a good idea to read the posting guide, for future reference!) Ben Bolker
Simon Wood
2011-Mar-11 18:01 UTC
[R] ERROR: gamm function (mgcv package). attempt to set an attribute on NULL
Thanks. This is a bug, the source code made an implicit assumption that there would always be at least one smooth, when creating the gam object after fitting. Fixed for the next release (1.7-5). For now, you could use glmmPQL from the MASS library to get an equivalent fit when there are no smooth terms. Simon On Thursday 10 March 2011 15:07, wang cheng wrote:> Hello:I run a gamm with following call > :mode<-gamm(A~B,random=list(ID=~1),family=gaussian,na.action=na.omit,data=r >s)an error happened:ERROR names(object$sp) <- names(G$sp) : attempt to set > an attribute on NULLwith mgcv version 1.7-3What so? How can I correct the > Error? Thanks very much for any help. > > > > [[alternative HTML version deleted]] > > ______________________________________________ > R-help at 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 Sciences, University of Bath, Bath, BA2 7AY UK > +44 1225 386603 www.maths.bath.ac.uk/~sw283