Skip to content

Variance and Covariance Matrix D and R in nlme or lme4 part II

4 messages · Alexandre Galvão Patriota, Douglas Bates

#
Alexandre Galv??o Patriota wrote:
The VarCorr function can provide D.
#
Hi Douglas, I need to find the matrix V=ZDZ'+R, for
example:

require(nlme)
data(Orthodont)
attach(Orthodont)
fm1 <- lme(distance ~ age + Sex, data =
Orthodont,random=~age)
X<-model.matrix(distance ~ age + Sex)
Z<-model.matrix(distance ~ age + Subject -1)
D<-diag(ncol(Z))
cova<-VarCorr(fm1,rdig=7)
D[,1]<-D[1,]<-as.numeric(cova[2,3])*as.numeric(cova[1,2])*as.numeric(cova[2,2])
diag(D)<-c(as.numeric(cova[1,1]),rep(as.numeric(cova[2,1]),
27))
se2<-summary(fm1)$sigma^2
V<-Z%*%D%*%t(Z) + se2*diag(108)

Is It right?? I compared a function vcov(fm1) with
solve(t(X)%*%solve(V)%*%X). Could you give me a hint
on why the two functions are giving incompatible
results?

thank you in advance for your help


 --- Douglas Bates <bates at stat.wisc.edu> escreveu:
#
Alexandre Galv??o Patriota wrote:
I don't know.

I wouldn't calculate the variance-covariance matrix for the parameter 
estimates that way.