[R] Error in nonlinear mixed-effects model

Douglas Bates bates at stat.wisc.edu
Wed Apr 27 03:04:35 CEST 2005


Revilla,AJ (pgt) wrote:
> Dear all,
> 
> I am trying to fit a mixed-effects non linear regression, but I have
> some trouble with it. My data are a balanced panel of 904 subjects
> with 8 observations (at regular periods) per subject. The functional
> form of my model is Y=Aexp(-BX1)X2 +e. I want to allow parameters A
> and B to vary among subjects and also include an autocorrelation
> term. I have already fitted a standard nonlinear regression to the
> data, but I keep having problems with NLME.
> 
> I have defined my data as a groupedData object, and when I try to fit
> the model I get this error message:
> 
> dat<-groupedData(V~VAC|ID,data=dat) 
 > attach(dat)

I don't think that attach'ing a groupedData object will propagate the 
grouping factors.  I suggest that you avoid the construction of the 
groupedData object and also that you avoid attaching and detaching data 
frames.  Just use

  mod <- nlme(V~A*exp(B*YEAR)*VAC, dat, fixed=A+B~1, random=A+B~1|ID, 
correlation=corCAR1(), start=c(A=1.2,B=0.2))

You will also need to specify a formula for the corAR1 constructor.  My 
guess is form = ~ YEAR | ID but you will need to decide if that is what 
you intend.  Check the help page for corAR1 to see the list of possible 
arguments.


Error in
> getGroups.data.frame(dataMix, eval(parse(text = paste("~1",
> deparse(groups[[2]]),  : Invalid formula for groups
> 
> Do you have any clue of what’s happening? It’s the first time I fit a
> model like this in R, so the problem is probably pretty obvious, but
> I cannot see it.
> 
> Thank you very much,
> 
> Antonio
> 
> ______________________________________________ 
> R-help at stat.math.ethz.ch mailing list 
> https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the
> posting guide! http://www.R-project.org/posting-guide.html




More information about the R-help mailing list