Dear list,
This is probably question easy to answer but I'm having some difficulties to find the way out.
How can I re-build the fitted values from coef() and the model.matrix (obtained by fm@X) ?

Here is a code to support my question:

#====================================================================#
set.seed(1520)
ntps<-4
nsubj<-20
sd.gp1<-3 
sd.gp0<-2 
sd.res<-1.3

group<-factor(rep(c("Group1", "Group0"), each=ntps, times=nsubj)) 
subj<-factor(rep(1:(nsubj*2), each=ntps)) 
time<- factor(paste("T", rep(1:ntps, nsubj*2), sep="")) 

over.base<-rep(c(5, 4), each=ntps, times=nsubj) 
subj.base<-rep(rnorm(nsubj*2, sd=c(sd.gp1, sd.gp0)), each=ntps) 
time.base<-rep(1:ntps, nsubj*2)*as.numeric(group=="Group1")

Yn<-rnorm(nsubj*ntps*2, mean=over.base+time.base+subj.base, sd=sd.res) 
dfn<-data.frame(time, group, Yn, subj) 

require(lattice)
xyplot(Yn~time|group, group=subj, type="l", data=dfn) 

f1<-lmer(Yn~group+time+(group|subj), data=dfn)
summary(f1)

### Individual fitted values: 160 x 1 (40 subj x 4 times)
fitted(f1)

### Random effect coefficients (per subj): 40 x 2 (intercept and slope)
ranef(f1)

### Fixed effect coefficients: 5 x 1 (int, gp1, T2, T3, T4)
fixef(f1)

### Individual coefficients: 40 x 5, ie. 40 subj x (int, gp1, T2, T3, T4)
coef(f1)

### Model matrix: 160 x 5 (indicators)
f1@X

#====================================================================#

Best regards,
François

	[[alternative HTML version deleted]]


