[R] Specify Z matrix with lmer function

Mark Lyman mlyman at byu.edu
Thu Nov 3 19:05:03 CET 2005


Is there a way to specify a Z matrix using the lmer function, where the 
model is written as y = X*Beta + Z*u + e?

I am trying to reproduce smoothing methods illustrated in the paper 
"Smoothing with Mixed Model Software" my Long Ngo and M.P. Wand. 
published in the /Journal of Statistical Software/ in 2004 using the 
lme4 and Matrix packages. The code and data sets used can be found at 
http://www.jstatsoft.org/v09/i01/.

There original code did  not work for me without slight modifications 
here is the code that I used with my modifications noted.

x <- fossil$age
y <- 100000*fossil$strontium.ratio
knots <- seq(94,121,length=25)
n <- length(x)
X <- cbind(rep(1,n),x)
Z <- outer(x,knots,"-")
Z <- Z*(Z>0)
# I had to create the groupedData object with one group to fit the model 
I wanted
grp <- rep(1,n)
grp.dat<-groupedData(y~Z|grp)
fit <- lme(y~-1+X,random=pdIdent(~-1+Z),data=grp.dat)

I would like to know how I could fit this same model using the lmer 
function. Specifically can I specify a Z matrix in the same way as I do 
above in lme?

Thanks,
Mark




More information about the R-help mailing list