I apologize for cross-posting. In the reproducable example below, I fit the same model with lme() and nlme(). However, I get 12 degrees of freedom with lme() and 2 df with nlme(). library(nlme) set.seed(14) a <- 2 x <- rep(rnorm(3),rep(5,3)) id <- rep(c("a","b","c"),rep(5,3)) y <- a+x+rnorm(15) data <- data.frame(y=y,id=id) initx <- matrix(x[c(1,6,11)],dimnames=list(c("a","b","c"),"x")) summary(fit.lme <- lme(y ~ 1,data=data,random=~1|id,method="ML")) summary(fit.nlme <- nlme(y ~ a + x, fixed= a~1, random=x~1|id, data=data, start=list(fixed=c(a=2), random=list(id=initx)),method="ML")) When I try the same thing with set.seed(18), I get 12 df for both. I have submitted a bug report on that issue on Dec 20th and I have tried to find the source of the problem, but no success. You can check what I found so far at: http://r-bugs.biostat.ku.dk/cgi-bin/R/Add-ons?id=2384 Can anyone help find the source of this problem? Sincerely, Jerome Asselin R 1.6.2 on Red Hat Linux 7.2 Package: nlme 3.1-38 ______________________________________________ R-help@stat.math.ethz.ch mailing list https://www.stat.math.ethz.ch/mailman/listinfo/r-help
Instead of submitting the same bug report multiple times and harrassing the developers of nlme via personal email you could perhaps have read the section in Pinheiro and Bates (2000) on calculation of degrees of freedom. Had you taken a few minutes to do so you would have discovered that the calculation of the degrees of freedom for the constant in a linear mixed-effects model is a special case. By disguising the linear model as a nonlinear model you have managed to defeat the detection of this special case and ended up with a different number of degrees of freedom. jerome@hivnet.ubc.ca writes:> I apologize for cross-posting. > > In the reproducable example below, I fit the same model with lme() and > nlme(). However, I get 12 degrees of freedom with lme() and 2 df with > nlme(). > > library(nlme) > set.seed(14) > > a <- 2 > x <- rep(rnorm(3),rep(5,3)) > id <- rep(c("a","b","c"),rep(5,3)) > y <- a+x+rnorm(15) > data <- data.frame(y=y,id=id) > initx <- matrix(x[c(1,6,11)],dimnames=list(c("a","b","c"),"x")) > > summary(fit.lme <- > lme(y ~ 1,data=data,random=~1|id,method="ML")) > summary(fit.nlme <- > nlme(y ~ a + x, fixed= a~1, random=x~1|id, > data=data, start=list(fixed=c(a=2), > random=list(id=initx)),method="ML")) > > When I try the same thing with set.seed(18), I get 12 df for both. > > I have submitted a bug report on that issue on Dec 20th and I have tried > to find the source of the problem, but no success. You can check what I > found so far at: > http://r-bugs.biostat.ku.dk/cgi-bin/R/Add-ons?id=2384 > > Can anyone help find the source of this problem? > > Sincerely, > Jerome Asselin > > R 1.6.2 on Red Hat Linux 7.2 > Package: nlme 3.1-38 > > ______________________________________________ > R-help@stat.math.ethz.ch mailing list > https://www.stat.math.ethz.ch/mailman/listinfo/r-help > > ______________________________________________ > R-devel@stat.math.ethz.ch mailing list > https://www.stat.math.ethz.ch/mailman/listinfo/r-devel-- Douglas Bates bates@stat.wisc.edu Statistics Department 608/262-2598 University of Wisconsin - Madison http://www.stat.wisc.edu/~bates/