Skip to content
Prev 17306 / 398513 Next

nlme - Confidence Interval for Variance in ANOVA

Susanne Schwenke <ml-r-help at epigenomics.com> writes:
The answer to your question is not "extremely simple".  It happens
that the lme function is much better suited to nested random effects
than to crossed random effects.  To estimate crossed random effects
you must create an awkward formulation with a grouping factor that has
one level and the random effects model matrix based on the indicators
for factor a and the indicators for factor b.  These two sets of
random effects each have variance-covariance matrices that are
multiples of an identity and the are grouped together as a
block-diagonal matrix.  The whole formulation is

 lme(response ~ 1, data = myData, 
     random = pdBlocked(list(pdIdent(~ a - 1), pdIdent(~ b - 1))))

and myData must be a groupedData object with a grouping factor that
has only one level.

There is an example of fitting crossed random effects in section 4.2
of Pinheiro and Bates (2000) "Mixed-effects Models in S and S-PLUS",
Springer.  That example happens to have two blocks and a random effect
for the block is added.  If we fit a single block it would look like
Loading required package: nls
logDens ~ 1 | Block
Block  sample dilut     logDens        
 2:30   a:10   1:12   Min.   :-0.23319  
 1:30   b:10   2:12   1st Qu.: 0.08404  
        c:10   3:12   Median : 0.31183  
        d:10   4:12   Mean   : 0.27300  
        e:10   5:12   3rd Qu.: 0.51175  
        f:10          Max.   : 0.67549
+ random = pdBlocked(list(pdIdent(~ sample - 1), pdIdent(~ dilut - 1))))
Linear mixed-effects model fit by REML
 Data: B1 
        AIC       BIC   logLik
  -42.21756 -36.74837 25.10878

Random effects:
 Composite Structure: Blocked

 Block 1: samplea, sampleb, samplec, sampled, samplee, samplef
 Formula: ~sample - 1 | Block
 Structure: Multiple of an Identity
           samplea    sampleb    samplec    sampled    samplee    samplef
StdDev: 0.09128746 0.09128746 0.09128746 0.09128746 0.09128746 0.09128746

 Block 2: dilut1, dilut2, dilut3, dilut4, dilut5
 Formula: ~dilut - 1 | Block
 Structure: Multiple of an Identity
           dilut1    dilut2    dilut3    dilut4    dilut5   Residual
StdDev: 0.2903284 0.2903284 0.2903284 0.2903284 0.2903284 0.05280506

Fixed effects: logDens ~ 1 
                Value Std.Error DF  t-value p-value
(Intercept) 0.2847687 0.1354251 29 2.102776  0.0443

Standardized Within-Group Residuals:
       Min         Q1        Med         Q3        Max 
-2.3867399 -0.3489126  0.0328683  0.3878895  2.0134090 

Number of Observations: 30
Number of Groups: 1 
-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-
r-help mailing list -- Read http://www.ci.tuwien.ac.at/~hornik/R/R-FAQ.html
Send "info", "help", or "[un]subscribe"
(in the "body", not the subject !)  To: r-help-request at stat.math.ethz.ch
_._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._