[R] ERROR: gamm function (mgcv package). attempt to set an attribute on NULL

Ben Bolker bbolker at gmail.com
Fri Mar 11 03:10:03 CET 2011


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 an 
  attribute 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



More information about the R-help mailing list