Skip to content
Prev 12404 / 398502 Next

VarComp in R

Richard Scott <rscott at rochester.rr.com> writes:
You can do this with lme but, as I mentioned in our private
correspondence, lme is better designed for nested random effects than
for crossed random effects like this.  You need to use the pdIdent
form of the variance-covariance matrix on the matrix of indicator
columns, created with formulas like ~ PARTS - 1, and combine those
with pdBlocked.

Do you really have a fully crossed design with random effects?  It
seems strange to pick the PART at random then reuse that particular
part 6 times.

Anyway, here is how you would do it.
+    PARTS = gl(5, 6, 30))
OPERATORS FIXTURES PARTS
 1:10      1:15     1:6  
 2:10      2:15     2:6  
 3:10               3:6  
                    4:6  
                    5:6
OPERATORS FIXTURES PARTS
1          1        1     1
2          2        1     1
3          3        1     1
4          1        2     1
5          2        2     1
6          3        2     1
7          1        1     2
8          2        1     2
9          3        1     2
10         1        2     2
+           random = pdBlocked(list(pdIdent(~ OPERATORS - 1),
+                                   pdIdent(~ FIXTURES - 1),
+                                   pdIdent(~ PARTS - 1))))
Linear mixed-effects model fit by REML
  Data: gr 
  Log-restricted-likelihood: -13.95199
  Fixed: Meas ~ 1 
(Intercept) 
   12.73601 

Random effects:
 Composite Structure: Blocked

 Block 1: OPERATORS1, OPERATORS2, OPERATORS3
 Formula: ~OPERATORS - 1 | Grp
 Structure: Multiple of an Identity
        OPERATORS1 OPERATORS2 OPERATORS3
StdDev:  0.5424059  0.5424059  0.5424059

 Block 2: FIXTURES1, FIXTURES2
 Formula: ~FIXTURES - 1 | Grp
 Structure: Multiple of an Identity
        FIXTURES1 FIXTURES2
StdDev:  1.723611  1.723611

 Block 3: PARTS1, PARTS2, PARTS3, PARTS4, PARTS5
 Formula: ~PARTS - 1 | Grp
 Structure: Multiple of an Identity
           PARTS1    PARTS2    PARTS3    PARTS4    PARTS5 Residual
StdDev: 0.3006655 0.3006655 0.3006655 0.3006655 0.3006655 0.245659

Number of Observations: 30
Number of Groups: 1
Grp = pdIdent(OPERATORS - 1), pdIdent(FIXTURES - 1), pdIdent(PARTS - 1) 
           Variance   StdDev   
OPERATORS1 0.29420413 0.5424059
OPERATORS2 0.29420413 0.5424059
OPERATORS3 0.29420413 0.5424059
FIXTURES1  2.97083530 1.7236111
FIXTURES2  2.97083530 1.7236111
PARTS1     0.09039977 0.3006655
PARTS2     0.09039977 0.3006655
PARTS3     0.09039977 0.3006655
PARTS4     0.09039977 0.3006655
PARTS5     0.09039977 0.3006655
Residual   0.06034835 0.2456590