Warning: non-expert thoughts to follow. When passing an object to a predict method, the method looks at (a copy) of the original information from the dataframe that was used in the fit. Your original data contains information on trt1 and trt2, but factor(trt1) and factor(trt2) cannot be found in the original data. If you did the factor conversion in the original data
myDat <- factor(myDat$trt1) myDat <- factor(myDat$trt2) then used myDat as the dataframe in the nlme call, all information would be available for the augPred method. That's why it works when you use trt1 and trt2 instead of factor(trt1) and factor(trt2). There is actually an implicit factor conversion happening in the nlme call if trt1 and trt2 are character variables, however if trt1 and trt2 are defined as numeric (ie 0 1) then it will fit as a numeric. --Matt > -----Original Message----- > From: [EMAIL PROTECTED] > [mailto:[EMAIL PROTECTED] Behalf Of Christian Mora > Sent: Friday, November 18, 2005 4:01 AM > To: Spencer Graves > Cc: [email protected] > Subject: Re: [R] nlme questions > > > > > > > > Spencer; > > Thanks for your suggestions. I found the problem is in the > library nlme. If > you define phi1~factor(trt1)+factor(trt2) instead of > phi1~trt1+trt2 the > augPred function works. A bug? I don't know. > > Christian > > > > > > > Spencer Graves <[EMAIL PROTECTED]> on 17-11-2005 20:19:32 > > To: Christian Mora <[EMAIL PROTECTED]> > cc: [email protected] > > Subject: Re: [R] nlme questions > > > Both your questions seem too vague to me. You might get > more useful > replies if you provide a simple example in a few lines of R > code that a > reader could copy from your email into R and see the result (as > suggested in the posting guide! > "www.R-project.org/posting-guide.html"). > The process of preparing such a simple example might by > itself provide > the insight you desire. Alternatively, you might work line by line > through the code for the R function you are using. Also, if you don't > have Pinheiro and Bates (2000) Mixed-Effects Models in S and S-PLUS > (Springer), I suggest you get it; it is excellent for things > like this. > > I'm sorry I couldn't help more. > spencer graves > > Christian Mora wrote: > > > > > > > > > Dear R users; > > > > Ive got two questions concerning nlme library 3.1-65 > (running on R 2.2.0 > / > > Win XP Pro). The first one is related to augPred function. Ive been > working > > with a nonlinear mixed model with no problems so far. > However, when the > > parameters of the model are specified in terms of some > other covariates, > > say treatment (i.e. phi1~trt1+trt2, etc) the augPred > function give me the > > following error: "Error in predict.nlme(object, > > value[1:(nrow(value)/nL),,drop=FALSE], : Levels 0,1 not > allowed for trt1, > > trt2". The same model specification as well as the augPred > function under > > SPlus 2000 run without problems. The second question has to > deal with the > > time needed for the model to converge. It really takes a > lot of time to > fit > > the model on R in relation to the time required to fit the > same model on > > SPlus. I can imagine this is related to the optimization > algorithm or > > something like that, but I would like to have a different opinion on > these > > two issues. > > > > Thanks in advance > > > > Christian Mora > > > > ______________________________________________ > > [email protected] mailing list > > https://stat.ethz.ch/mailman/listinfo/r-help > > PLEASE do read the posting guide! > http://www.R-project.org/posting-guide.html > > -- > Spencer Graves, PhD > Senior Development Engineer > PDF Solutions, Inc. > 333 West San Carlos Street Suite 700 > San Jose, CA 95110, USA > > [EMAIL PROTECTED] > www.pdf.com <http://www.pdf.com> > Tel: 408-938-4420 > Fax: 408-280-7915 > > ______________________________________________ > [email protected] mailing list > https://stat.ethz.ch/mailman/listinfo/r-help > PLEASE do read the posting guide! > http://www.R-project.org/posting-guide.html > ______________________________________________ [email protected] mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html
