Dieter Menne
2001-Feb-23 20:20 UTC
[R] as.formula and lme ( Fixed effects: Error in as.vector(x, "list") : cannot coerce to vector)
Using a formula converted with as.formula with lme leads
to an error message. Same works ok with lm, and with
lme and a fixed formula.
# demonstrates problems with lme and as.formula
demo<-data.frame(x=1:20,y=(1:20)+rnorm(20),subj=as.factor(rep(1:2,10)))
demo.lm1<-lme(y~x,data=demo,random=~1|subj)
print(summary(demo.lm1))
newframe<-data.frame(x=1:5,subj=rep(1,5))
predict(demo.lm1,newframe,level=0)
fma<-as.formula("y~x")
demo.lm<-lm(fma,data=demo) # ok
predict(demo.lm,newframe,level=0) # ok
demo.lm2<-lme(fma,data=demo,random=~1|subj) # looks ok, but isn't
print(summary(demo.lm2))
#Fixed effects: Error in as.vector(x, "list") : cannot coerce to
vector
#predict(demo.lm2,newframe,level=0) # does not work
---------------------------------------
Dr. Dieter Menne
Biomed Software
72074 T?bingen
Tel (49) (7071) 52176
FAX (49) (7071) 55 10 46
dieter.menne at menne-biomed.de
www.menne-biomed.de
-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-
r-help mailing list -- Read http://www.ci.tuwien.ac.at/~hornik/R/R-FAQ.html
Send "info", "help", or "[un]subscribe"
(in the "body", not the subject !) To: r-help-request at
stat.math.ethz.ch
_._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._
Douglas Bates
2001-Feb-23 21:01 UTC
[R] as.formula and lme ( Fixed effects: Error in as.vector(x, "list") : cannot coerce to vector)
"Dieter Menne" <dieter.menne at menne-biomed.de> writes:> Using a formula converted with as.formula with lme leads > to an error message. Same works ok with lm, and with > lme and a fixed formula. > > # demonstrates problems with lme and as.formula > demo<-data.frame(x=1:20,y=(1:20)+rnorm(20),subj=as.factor(rep(1:2,10))) > demo.lm1<-lme(y~x,data=demo,random=~1|subj) > print(summary(demo.lm1)) > newframe<-data.frame(x=1:5,subj=rep(1,5)) > predict(demo.lm1,newframe,level=0) > > fma<-as.formula("y~x") > demo.lm<-lm(fma,data=demo) # ok > predict(demo.lm,newframe,level=0) # ok > demo.lm2<-lme(fma,data=demo,random=~1|subj) # looks ok, but isn't > print(summary(demo.lm2)) > > #Fixed effects: Error in as.vector(x, "list") : cannot coerce to vector > #predict(demo.lm2,newframe,level=0) # does not workThanks for the detailed report. I can reproduce the problem. It appears that there needs to be an eval early in the lme function so it stores the formula for the fixed effects, not the name of the formula. -.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.- r-help mailing list -- Read http://www.ci.tuwien.ac.at/~hornik/R/R-FAQ.html Send "info", "help", or "[un]subscribe" (in the "body", not the subject !) To: r-help-request at stat.math.ethz.ch _._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._
Reasonably Related Threads
- as.formula and lme ( Fixed effects: Error in as.vector(x, "list") : cannot coerce to vector)
- Remove columns by name data[-c("subj","drug")]
- Comparing two regression slopes
- Overfitting/Calibration plots (Statistics question)
- Help needed in interpreting linear models