Re: [R] Predicting a single observatio using LME

From: Dieter Menne <dieter.menne_at_menne-biomed.de>
Date: Sat, 07 Jun 2008 08:29:27 +0000 (UTC)

Rebecca Sela <rsela <at> stern.nyu.edu> writes:

>
> When I use a model fit with LME, I get an error if I try to use "predict" with
a dataset consisting of a single line.
>
> For example, using this data:
> > simpledata
> Y t D ID
> 23 4.359511097 3 1 6
> 24 6.165419699 4 1 6
>
> This happened:
> > testLME <- lme(Y~t+D,data=simpledata,random=~1|ID)
> > predict(testLME, simpledata[1,])
> Error in val[revOrder, level + 1] : incorrect number of dimensions
>
> This has occurred with other datasets as well. Is this a bug in the code, or
am I doing something wrong?

No, this looks like a bug due to dimension-dropping when using one row. Probably nobody used it with one value before. As a workaround, do some cheating

predict(testLME, simpledata[c(1,2),])

Dieter



R-help_at_r-project.org 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. Received on Sat 07 Jun 2008 - 08:31:59 GMT

Archive maintained by Robert King, hosted by the discipline of statistics at the University of Newcastle, Australia.
Archive generated by hypermail 2.2.0, at Sat 07 Jun 2008 - 14:30:37 GMT.

Mailing list information is available at https://stat.ethz.ch/mailman/listinfo/r-help. Please read the posting guide before posting to the list.

list of date sections of archive