[R] fitting a model with the nlme package

Frank Johannes fjohannes at fastmail.fm
Thu Aug 3 20:23:24 CEST 2006


Dear all,
I am analyzing some data that requires a mixed model. I have been
reading Pinheiro and Bates' book,
but cannot find the notation to fit the following model:

Suppose I have the dataset below. Here I am fitting variable p as a
fixed effect, variable h
as a random effect and variable t as nested within h.  I would like to
include the variable j as well
as an independent (non-nested) random effect. I can't find the notation
in the book to tell R
to do this. Does anybody know? 

library(nlme)

h<-c(1,1,1,2,2,2,3,3,3)
j<-c(2,3,8,3,4,3,9,5,4)
t<-c(1,2,3,1,2,3,1,2,3)
f<-c(1,2,1,2,1,2,1,2,1)
p<-c(45,32,35,12,23,12,2,9,12)
set<-data.frame(p,h,j,t)

out<-lme(p~ -1 + f,data=set, random=~1|h/t)

Thanks a alot,
frank.

-- 

                          unladen european swallow



More information about the R-help mailing list