[R-sig-ME] problems formulating arguments to lme()

Ben Bolker bbolker at gmail.com
Wed Dec 1 17:35:07 CET 2010

```-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1

On 10-12-01 05:22 AM, Robert Kinley wrote:
> this is a clearer (I hope) version of an earlier post  -

(Please don't cross-post: r-sig-mixed-models is probably more
appropriate.)

> My problem is formulating the  random = argument to give estimates
> of all 9 random components for this kind of setup where there are
> (I think) 9  variance/covariance components ...
>
>                              Study.1    Study.2   ...  Study.5
>  Treatment T1: subject:  1  2  3          4  5  6   ...  13 14 15
>
>  Treatment T2: subject: 16 17 18   19 20 21   ...  28 29 30
>
>  A variable is measured at the same 2 fixed sites (a and b) on each
> subject
>
> { Toy example data at end of email }
>
> so fixed effects are :-
>  between-Treatments ( T1 and T2 )
>  between-sites   ( a and b )
>  Treatment*site interaction
>
> and random effects are :-
>  study effects at site a
>  study effects at site b
>  correlation between site a and site b study effects
>
>  study*treatment interaction effects at site a
>  study*treatment interaction effects at site b
>  correlation between site a and b study*treatment interaction effects
>
>  residual (between-subject) effects at site a
>  residual (between-subject) effects at site b
>  correlation between site a and b residuals (between-subject) effects
>
> I'm having trouble seeing how to formulate this correctly in  lme()

I don't know offhand if you can do this in lme(), you may need to
switch to lmer() in the lme4 package, but I would take a wild initial
guess at

lme(Result~Treatment*Site,random=list(~Site|Subject,Site*Treatment|Study))

This gives 13 variance components, I'm not sure they're the same as
yours --

a. variation across subjects
b. variation in site effect across subjects
c. correlation between a and b

d. variation across studies
e. variation in treatment effect across studies
f. variation in site effect across studies
g. variation in site:treatment interaction across studies
h, i, j, k, l, m ... correlations among these effects.

Because your subjects are (sensibly) numbered uniquely, rather than
within study, you don't have to specify 'nesting' explicitly.

If you really want to estimate all of these effects I hope you have a
very big data set ...

> Hope someone can help ...
>
>         cheers          Bob Kinley
>
>> Toy
>    Study Treatment Subject Site    Result
>    1        T1       1    a      13.901820
>    1        T1       1    b      19.158889
>    1        T1       2    a      16.026299
>    1        T1       2    b      15.545153
>    1        T1       3    a      19.667706
>    1        T1       3    b      21.945156
>    1        T2      16    a       9.822498
>    1        T2      16    b      13.271435
>    1        T2      17    a      18.602909
>    1        T2      17    b      15.679736
>    1        T2      18    a      15.083195
>    1        T2      18    b      18.012834
>    2        T1       4    a      19.394835
>    2        T1       4    b      13.537977
>    2        T1       5    a      17.921014
>    2        T1       5    b      12.070566
>    2        T1       6    a      14.419953
>    2        T1       6    b      16.990585
>    2        T2      19    a      15.489600
>    2        T2      19    b      21.721682
>    2        T2      20    a      18.553789
>    2        T2      20    b      16.628156
>    2        T2      21    a      20.310238
>    2        T2      21    b      18.604716
>    3        T1       7    a      12.458706
>    3        T1       7    b      17.279394
>    3        T1       8    a      14.598512
>    3        T1       8    b      17.024093
>    3        T1       9    a      20.821720
>    3        T1       9    b      22.051680
>    3        T2      22    a      17.923521
>    3        T2      22    b      11.690319
>    3        T2      23    a      12.547144
>    3        T2      23    b      15.051402
>    3        T2      24    a      12.865087
>    3        T2      24    b      13.451004
>    4        T1      10    a      13.819201
>    4        T1      10    b      18.375914
>    4        T1      11    a      18.540972
>    4        T1      11    b      15.741144
>    4        T1      12    a      16.992064
>    4        T1      12    b      16.964870
>    4        T2      25    a      18.583896
>    4        T2      25    b      19.920100
>    4        T2      26    a      18.782343
>    4        T2      26    b      15.095778
>    4        T2      27    a      23.042282
>    4        T2      27    b      19.296852
>    5        T1      13    a      12.425960
>    5        T1      13    b      12.865022
>    5        T1      14    a      16.774604
>    5        T1      14    b      15.540754
>    5        T1      15    a      15.726991
>    5        T1      15    b       8.089564
>    5        T2      28    a      11.694392
>    5        T2      28    b      24.740416
>    5        T2      29    a      14.664904
>    5        T2      29    b      16.348194
>    5        T2      30    a      20.911168
>    5        T2      30    b      15.394160
>>
> 	[[alternative HTML version deleted]]
>
> _______________________________________________
> R-sig-mixed-models at r-project.org mailing list
> https://stat.ethz.ch/mailman/listinfo/r-sig-mixed-models

-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.4.10 (GNU/Linux)
Comment: Using GnuPG with Mozilla - http://enigmail.mozdev.org/

iEYEARECAAYFAkz2eTsACgkQc5UpGjwzenOqjQCdEIPvZv4YoXnoWnapsUqZUeLf
qE8AnjRagrymmcgWfonjT1WV9fkgz2e9
=om4v
-----END PGP SIGNATURE-----

```