help with syntax of random formula

classic Classic list List threaded Threaded
1 message Options
Reply | Threaded
Open this post in threaded view

help with syntax of random formula

Thomas Wutzler
Dear R-users

Thanks to Jose Pinheiro, Douglas Bates and coworkes for providing R with the nlme package.

Could someone help me, please, to specify a correct random formula for a
mixed model, that specifies no random effect on a higher level?

I have the following dataset of timeseries of respiration measurements
(column resp) of biomass including a parameter initial biomass x0. Respiration
measurements have been recorded in several experiments, each consisting
of several replicates.

'data.frame':   3229 obs. of  5 variables:
 $ suite     : Factor w/ 3 levels "Face","Fal","Pushchino": 1 1 1 1 1 1
1 1 1 1 ...
 $ experiment: Factor w/ 44 levels "1","2","3","4",..: 1 1 1 1 1 1 1 1 1
1 ...
 $ replicate : Factor w/ 3 levels "1","2","3": 1 1 1 1 1 1 1 1 1 1 ...
 $ time      : num  1.84 2.84 3.84 4.84 5.84 ...
 $ resp      : num  4.09 3.94 3.70 3.88 4.03 ...

rd <-
groupedData( resp ~ time | experiment/replicate, data=rd)

Time is the first level at the same level as the dependent variable
resp, replicate is the second level, experiment the third. (In future
suite will be used as another level. For simplicity here, I first try
with data of only one suite)

I want to fit a mixed model to the data which includes random effects on
the replicate level but no random effects on the experiment level. The
random effects should have a distribution around 0 within each experiment.

I succeded to include random effects on both levels.
random=list( experiment=x0~1, replicate=x0~1 )

I succeded also to fit a model to only replicate level:
# replicate 1 in experiment i has nothing to do with replicate 1 in
other experiment
rd$exprep <- paste( rd$experiment, rd$replicate, sep="_")
random=list( exprep=x0~1 )

However, this gives a single distribution across all replicates of all
Instead, I want to have a distribution of random effects across only
replicates of an experiment with mean zero for each experiment

I tried amongst others the following syntax without success:
random=list( experiment=~1, exprep=x0~1 )
random=list( experiment=1~1, exprep=x0~1 )
random=list( experiment=NULL, exprep=x0~1 )

I am using nlme version 3.1-86 on R 2.6.1 on Windows XP.

Is it possible to fit such a model with nlme?
What is the correct syntax?
Do I need the exprep- variable or is it clear with the grouping that
replicate=1 in experiment=1 is different from replicate=1 in other

Best regards
Thomas Wutzler

[hidden email] mailing list
PLEASE do read the posting guide
and provide commented, minimal, self-contained, reproducible code.