[R] Predicting a single observatio using LME

Dieter Menne dieter.menne at menne-biomed.de
Sat Jun 7 10:29:27 CEST 2008


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



More information about the R-help mailing list