DeaR

I am trying to use a dynamically create formula with nlsList and nlme, but I
cannot get the environment of the string-generated formal to work similarly
to the manually entered one.

Any idea?

Dieter

#-----
library(nlme)
# Pinheiro/Bates p 280
fm1Indom.lis = nlsList(conc~SSbiexp(time,A1,lrc1,A2,lrc2),
  data=Indometh)
nlme(fm1Indom.lis,random=pdDiag(A1+lrc1+A2~1))
# works...


# Simulating a dynamic formula
form = as.formula("conc~SSbiexp(time,A1,lrc1,A2,lrc2)")
fm2Indom.lis = nlsList(form,data=Indometh)
# still correct

nlme(fm2Indom.lis,random=pdDiag(A1+lrc1+A2~1))
#Error in switch(mode(x), "NULL" = structure(NULL, class = "formula"),  :
#        invalid formula


# B.D. Ripley val(subst) workaround
# http://finzi.psych.upenn.edu/R/Rhelp02a/archive/16599.html
fm3Indom.lis = eval(substitute(nlsList(form,data=Indometh)),
  list(form=form))
nlme(fm3Indom.lis,random=pdDiag(A1+lrc1+A2~1))
#.. Same error

______________________________________________
R-help@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
and provide commented, minimal, self-contained, reproducible code.

Reply via email to