Message-ID: <20041113171550.93876.qmail@web52705.mail.yahoo.com>
Date: 2004-11-13T17:15:50Z
From: Alexandre Galvão Patriota
Subject: Variance and Covariance Matrix D and R in nlme or lme4 part II [Please]
In-Reply-To: <41962147.5060009@stat.wisc.edu>
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:
> > The model is Y = XB + Zg + e
> >
> > where
> >
> > g~N(0, D)
> >
> > e~N(0, R)
> >
> > How to extract the VAR(g)= D, VAR(e)=R and
> V=ZDZ'+R?
> >
> > thanks
>
> The VarCorr function can provide D.
>
>