Hi all,

I am running some linear mixed models for longitudinal data using the nlme
package. Part of the code I've developed tests for differences among models
using the anova function, but I can't simply pass the corresponding lme
objects as parameters to the anova function because some of the models do
not converge and others are retained for comparison only if certain criteria
are met.

So, the simple solution seemed to be generating a list of models and using
do.call to test models that made the cut, either by converging, or by
meeting some of the substantive criteria I set. Unfortunately, the do.call
command generates an error. I dug around on the R-help archives and came
across some similar problems, but none that helped to resolve this error.

The error I receive is:

Error in `row.names<-.data.frame`(`*tmp*`, value =
c("structure(list(modelStruct = structure(list(reStruct = structure(list(",
:
  invalid 'row.names' length

The traceback() didn't provide clear feedback about what was wrong, at least
to my ignorant eye.

Here is a simple reproducible example:


library(nlme)
dataTest <- data.frame(y=c(rnorm(100, 0, 1), rnorm(100,5,1)), time=rep(0:3,
each=50), id=rep(1:50, 4))
uncMeansModel <- lme(y ~ 1, data=dataTest, random=~1|id, method="ML")
uncGrowthModel <- lme(y ~ 1 + time, data=dataTest, random=~time|id,
method="ML")
uncGrowthModel2 <- lme(y ~ 1 + time + I(time^2), data=dataTest,
random=~time|id, method="ML")

models <- list(uncMeansModel, uncGrowthModel, uncGrowthModel2)

do.call("anova.lme", models) #doesn't work
anova.lme(uncMeansModel, uncGrowthModel, uncGrowthModel2) #works


And here is my sessionInfo():
> sessionInfo()

R version 2.11.1 (2010-05-31)
x86_64-pc-linux-gnu

locale:
 [1] LC_CTYPE=en_US.UTF-8          LC_NUMERIC=C
 [3] LC_TIME=en_US.UTF-8           LC_COLLATE=en_US.UTF-8
 [5] LC_MONETARY=en_US.UTF-8       LC_MESSAGES=en_US.UTF-8
 [7] LC_PAPER=en_US.UTF-8          LC_NAME=en_US.UTF-8
 [9] LC_ADDRESS=en_US.UTF-8        LC_TELEPHONE=en_US.UTF-8
[11] LC_MEASUREMENT=en_US.UTF-8    LC_IDENTIFICATION=en_US.UTF-8

attached base packages:
[1] stats     graphics  grDevices utils     datasets  methods   base

other attached packages:
[1] nlme_3.1-96 rj_0.5.0-5

loaded via a namespace (and not attached):
[1] grid_2.11.1     lattice_0.19-11 rJava_0.8-6     tools_2.11.1

Thanks for any help you can provide!

Best wishes,
Michael Hallquist

	[[alternative HTML version deleted]]

