# [S] Simulation in linear mixed effects model in S

Chul Ahn (chulahn@heart.med.uth.tmc.edu)
Tue, 26 May 1998 13:32:20 -0500

Using lme(linear mixed effects model), I got the z-ratios from the third
column using summary(lme.fit)\$fixed.table [,3].

I am planning to run 1000 (maybe 5000) simulations using linear mixed
models. I created the large file which contains 1000 data sets in a
standard form that lme analysis can be done.

For example, my dataset looks like as follows.

dsn subject sex age distance
1 1 0 8 26.0
1 1 0 10 25.0
1 1 0 12 29.0
1 1 0 14 31.0
...
1 27 1 8 24.5
1 27 1 10 25.0
1 27 1 12 28.0
1 27 1 14 28.0
...
1000 1 0 8 23.0
...
1000 27 1 14 25.2

Here dsn=1 means the data set #1 and dsn=1000 means the data set #1000.
I used the following S-Plus statement to run all the 1000 data set at a time.

S>by(ortho,ortho\$dsn,function(data)lme(fixed=distance ~age*sex, random=
~age, cluster= ~subj, data=data))

It worked fine. So, I got the outputs from all 1000 data sets at a time. I
tried to incorporate the summary statement in the above S-command and get
the z-ratios. I could get neither the summary result nor z-ratios.
When I ran lme using one data set, I got the z-ratios with the following
S-commands.
S>orth1.fit_lme(fixed=distance ~age*sex, random=~age, cluster= ~subj,
data=orth1)
S>summary(orth1.fit)\$fixed.table [,3]

However, I couldn't figure out how to run the above statements using all
1000 data sets (dsn=1,...,1000).
I couldn't put the summary statement inside the by command. When I tried, I
kept on getting error messages.
Would you please let me know how I can obtain the file which contains the
z-ratios of the fixed effects?
If z-ratios are not possible, how can I get the file containing the summary
of lme fit?