Ed230B/C

Nested Designs


Also Know as Hierarchical Designs

  • A hierarchical experiment is one in which the levels of at least one treatment are nested within those of another treatment. All of the other treatments are completely crossed.
  • B(A) is read as B nested within A (B|A in Stata).
  • B(A) is functionally equivalent to the interaction, A*B, but cannot be intrepreted as such since the factors are not completely crossed.

    Compare these Three Designs

    Crossed, nested, and confounded.

      a1a2
    b1s1s5
    b2s2s6
    b3s3s7
    b4s4s8

      a1a2
    b1s1  
    b2s2  
    b3   s3
    b4   s4

      a1a2
    b1s1  
    b2   s2

    Linear Model

    Yijk = μ + αj + βk(j) + εi(jk)

    Expected Mean Squares

    E(MSA) = σ2ε + nσ2β + nqσ2α

    E(MSB(A)) = σ2ε + nσ2β

    E(MSresid) = σ2ε

    ANOVA Summary Table for CRH-pq(A) where A is a Fixed Variable

     
      Source     Errorterm      df            
    1 A             [2]         p-1               
    2 B(A)          [3]         p(q(j)-1) 
    3 Residual                  pq(j)(n-1)
    

    Example CRH-2,8(A)

    a1b1  3  6  3  3
    a1b2  1  2  2  2
    a1b3  5  6  5  6
    a1b4  2  3  4  3
    a2b5  7  8  7  6
    a2b6  4  5  4  3
    a2b7  7  8  9  8
    a2b8 10 10  9 11
    

    Using Stata

    input a b y x1 x2 x3 x4 x5 x6 x7
    1 1  3  1  1  1  1  0  0  0
    1 1  6  1  1  1  1  0  0  0
    1 1  3  1  1  1  1  0  0  0
    1 1  3  1  1  1  1  0  0  0
    1 2  1  1 -1  1  1  0  0  0
    1 2  2  1 -1  1  1  0  0  0
    1 2  2  1 -1  1  1  0  0  0
    1 2  2  1 -1  1  1  0  0  0
    1 3  5  1  0 -2  1  0  0  0
    1 3  6  1  0 -2  1  0  0  0
    1 3  5  1  0 -2  1  0  0  0
    1 3  6  1  0 -2  1  0  0  0
    1 4  2  1  0  0 -3  0  0  0
    1 4  3  1  0  0 -3  0  0  0
    1 4  4  1  0  0 -3  0  0  0
    1 4  3  1  0  0 -3  0  0  0
    2 5  7 -1  0  0  0  1  1  1
    2 5  8 -1  0  0  0  1  1  1
    2 5  7 -1  0  0  0  1  1  1
    2 5  6 -1  0  0  0  1  1  1
    2 6  4 -1  0  0  0 -1  1  1
    2 6  5 -1  0  0  0 -1  1  1
    2 6  4 -1  0  0  0 -1  1  1
    2 6  3 -1  0  0  0 -1  1  1
    2 7  7 -1  0  0  0  0 -2  1
    2 7  8 -1  0  0  0  0 -2  1
    2 7  9 -1  0  0  0  0 -2  1
    2 7  8 -1  0  0  0  0 -2  1
    2 8 10 -1  0  0  0  0  0 -3
    2 8 10 -1  0  0  0  0  0 -3
    2 8  9 -1  0  0  0  0  0 -3
    2 8 11 -1  0  0  0  0  0 -3
    end
     
    table b a,contents(freq mean y sd y)
    
    ----------+-------------------
              |         a         
            b |        1         2
    ----------+-------------------
            1 |        4          
              |     3.75          
              |      1.5          
              | 
            2 |        4          
              |     1.75          
              |       .5          
              | 
            3 |        4          
              |      5.5          
              | .5773503          
              | 
            4 |        4          
              |        3          
              | .8164966          
              | 
            5 |                  4
              |                  7
              |           .8164966
              | 
            6 |                  4
              |                  4
              |           .8164966
              | 
            7 |                  4
              |                  8
              |           .8164966
              | 
            8 |                  4
              |                 10
              |           .8164966
    ----------+-------------------
     
    histogram y, by(a b) normal
    
    
     
    anova y a / b|a /
    
                         Number of obs =      32     R-squared     =  0.9214
                         Root MSE      = .877971     Adj R-squared =  0.8985
    
                Source |  Partial SS    df       MS           F     Prob > F
            -----------+----------------------------------------------------
                 Model |      217.00     7       31.00      40.22     0.0000
                       |
                     a |      112.50     1      112.50       6.46     0.0440
                   b|a |      104.50     6  17.4166667   
            -----------+----------------------------------------------------
                   b|a |      104.50     6  17.4166667      22.59     0.0000
                       |
              Residual |       18.50    24  .770833333   
            -----------+----------------------------------------------------
                 Total |      235.50    31  7.59677419 
     
    regress y x1 x2 x3 x4 x5 x6 x7
    
      Source |       SS       df       MS               Number of obs =      32
    ---------+------------------------------            F(  7,    24) =   40.22
       Model |      217.00     7       31.00            Prob > F      =  0.0000
    Residual |       18.50    24  .770833333            R-squared     =  0.9214
    ---------+------------------------------            Adj R-squared =  0.8985
       Total |      235.50    31  7.59677419            Root MSE      =  .87797
    
    ------------------------------------------------------------------------------
               y |      Coef.   Std. Err.      t    P>|t|     [95% Conf. Interval]
    -------------+----------------------------------------------------------------
              x1 |     -1.875   .1552048   -12.08   0.000    -2.195327   -1.554673
              x2 |          1   .3104097     3.22   0.004     .3593459    1.640654
              x3 |  -.9166667   .1792151    -5.11   0.000    -1.286548   -.5467849
              x4 |   .1666667   .1267242     1.32   0.201    -.0948793    .4282126
              x5 |        1.5   .3104097     4.83   0.000     .8593459    2.140654
              x6 |  -.8333333   .1792151    -4.65   0.000    -1.203215   -.4634515
              x7 |  -.9166667   .1267242    -7.23   0.000    -1.178213   -.6551207
           _cons |      5.375   .1552048    34.63   0.000     5.054673    5.695327
    ------------------------------------------------------------------------------
     
    test2 x1 / x2 x3 x4 x5 x6 x7  /* available from ATS */
    
    Testing: x1 
    Error term: x2 x3 x4 x5 x6 x7
    
         F(  1,   6)  =     6.46
             Prob > F =     0.0440
     
    test x2 x3 x4 x5 x6 x7
    
     ( 1)  x2 = 0.0
     ( 2)  x3 = 0.0
     ( 3)  x4 = 0.0
     ( 4)  x5 = 0.0
     ( 5)  x6 = 0.0
     ( 6)  x7 = 0.0
    
           F(  6,    24) =   22.59
                Prob > F =    0.0000
    Using xi3

    To use xi3 for this nested design, we have to create a new variable b2 to rerplace b. b2 will have the values 1 to 4 at A1 and 1 to 4 again at A2.

    generate b2 = b
    
    recode b2 5=1 6=2 7=3 8=4
    
    xi3: regress y r.b2@i.a
    
    r.b2              _Ib2_1-4            (naturally coded; _Ib2_1 omitted)
    i.a               _Ia_1-2             (naturally coded; _Ia_1 omitted)
    
          Source |       SS       df       MS              Number of obs =      32
    -------------+------------------------------           F(  7,    24) =   40.22
           Model |         217     7          31           Prob > F      =  0.0000
        Residual |        18.5    24  .770833333           R-squared     =  0.9214
    -------------+------------------------------           Adj R-squared =  0.8985
           Total |       235.5    31  7.59677419           Root MSE      =  .87797
    
    ------------------------------------------------------------------------------
               y |      Coef.   Std. Err.      t    P>|t|     [95% Conf. Interval]
    -------------+----------------------------------------------------------------
           _Ia_2 |       3.75   .3104097    12.08   0.000     3.109346    4.390654
        _Ib22Wa1 |         -2   .6208194    -3.22   0.004    -3.281308   -.7186918
        _Ib22Wa2 |         -3   .6208194    -4.83   0.000    -4.281308   -1.718692
        _Ib23Wa1 |       2.75   .5376453     5.11   0.000     1.640355    3.859645
        _Ib23Wa2 |        2.5   .5376453     4.65   0.000     1.390355    3.609645
        _Ib24Wa1 |  -.6666667   .5068969    -1.32   0.201     -1.71285    .3795171
        _Ib24Wa2 |   3.666667   .5068969     7.23   0.000     2.620483     4.71285
           _cons |        3.5   .2194928    15.95   0.000     3.046989    3.953011
    ------------------------------------------------------------------------------
    
    test2 _Ia_2 / _Ib22Wa1 _Ib22Wa2 _Ib23Wa1 _Ib23Wa2 _Ib24Wa1 _Ib24Wa2  /* available for ATS */
    
    Testing: _Ia_2 
    Error term: _Ib22Wa1 _Ib22Wa2 _Ib23Wa1 _Ib23Wa2 _Ib24Wa1 _Ib24Wa2
    
         F(  1,   6)  =     6.46
             Prob > F =     0.0440
    
    test _Ib22Wa1 _Ib22Wa2 _Ib23Wa1 _Ib23Wa2 _Ib24Wa1 _Ib24Wa2
    
     ( 1)  _Ib22Wa1 = 0
     ( 2)  _Ib22Wa2 = 0
     ( 3)  _Ib23Wa1 = 0
     ( 4)  _Ib23Wa2 = 0
     ( 5)  _Ib24Wa1 = 0
     ( 6)  _Ib24Wa2 = 0
    
           F(  6,    24) =   22.59
                Prob > F =    0.0000
    Multilevel Model Using xtmixed

    It is also possible to analyze these data using a multilevel model approach equivalent to using proc mixed in SAS or using HLM. We will run this as a random intercept restricted maximum likelihood model.

    xi: xtmixed y i.a || b: , var /* reml - restricted maximum likelihood model */
    
    i.a               _Ia_1-2             (naturally coded; _Ia_1 omitted)
    
    Performing EM optimization: 
    
    Performing gradient-based optimization: 
    
    Iteration 0:   log restricted-likelihood =  -50.78963  
    Iteration 1:   log restricted-likelihood =  -50.78963  
    
    Computing standard errors:
    
    Mixed-effects REML regression                   Number of obs      =        32
    Group variable: b                               Number of groups   =         8
    
                                                    Obs per group: min =         4
                                                                   avg =       4.0
                                                                   max =         4
    
    
                                                    Wald chi2(1)       =      6.46
    Log restricted-likelihood =  -50.78963          Prob > chi2        =    0.0110
    
    ------------------------------------------------------------------------------
               y |      Coef.   Std. Err.      z    P>|z|     [95% Conf. Interval]
    -------------+----------------------------------------------------------------
           _Ia_2 |       3.75   1.475494     2.54   0.011     .8580841    6.641916
           _cons |        3.5   1.043332     3.35   0.001     1.455107    5.544893
    ------------------------------------------------------------------------------
    
    ------------------------------------------------------------------------------
      Random-effects Parameters  |   Estimate   Std. Err.     [95% Conf. Interval]
    -----------------------------+------------------------------------------------
    b: Identity                  |
                      var(_cons) |   4.161459   2.514495       1.27327    13.60099
    -----------------------------+------------------------------------------------
                   var(Residual) |   .7708333   .2225204      .4377637    1.357317
    ------------------------------------------------------------------------------
    LR test vs. linear regression: chibar2(01) =    31.43 Prob >= chibar2 = 0.0000
    
    test _Ia_2
    
     ( 1)  [y]_Ia_2 = 0
    
               chi2(  1) =    6.46
             Prob > chi2 =    0.0110
    CRH-pq(A)r(A*B)

    Linear Model

    Yijkl = μ + αj + βk(j) + γl(jk) + εi(jkl)

    Schematic

    a1a2
    b1 c1s1
    b1 c2s2
    b2 c3s3
    b2 c4s4
    b3 c5s5
    b3 c6s6
    b4 c7s7
    b4 c8s8

    Anova Summary Table for CRH-pq(A)r(A*B) where A is a Fixed Variable
      Source     Errorterm     df
    1 A             [2]        p-1
    2 B(A)          [3]        p(q(j)-1)
    3 C(A*B)        [4]        pq(j)(r(jk)-1)
    4 Residual                 pq(j)r(jk)(n-1)
    

    CRPH-pq(A)r

    Linear Model

    Yijkl = μ + αj + βk(j) + γl + αγjl + βγk(j)l + εi(jkl)

    Schematic

    a1
    c1
    a1
    c2
    a2
    c1
    a2
    c2
    b1s1s3
    b2s2s4
    b3s5s7
    b4s6s8

    Anova Summary Table for CRPH-pq(A)r where A & C are Fixed Variables
      Source      Errorterm    df
    1 A              [2]       p-1
    2 B(A)           [6]       p(q(j)-1)
    3 C              [5]       r-1
    4 A*C            [5]       (p-1)(r-1)
    5 B(A)*C         [6]       p(q(j)-1)(r-1)
    6 Residual                 pq(j)r(n-1)
    
    CRPH-pq(A)r(A)

    Linear Model

    Yijkl = μ + αj + βk(j) + γl(j) + βγk(j)l(j) + εi(jkl)

    Schematic

    a1a2
    b1 c1s1
    b1 c2s2
    b2 c1s3
    b2 c2s4
    b3 c3s5
    b3 c4s6
    b4 c3s7
    b4 c4s8

    Anova Summary Table for CRPH-pq(A)r(A) where A & C are Fixed Variables
      Source      Errorterm    df
    1 A              [2]       p-1
    2 B(A)           [5]       p(q(j)-1)
    3 C(A)           [4]       p(r(j)-1)
    4 B(A)*C(A)      [5]       p(q(j)-1)(r(j)-1)
    5 Residual                 pq(j)r(j)(n-1)
    
    CRPH-pqr(A*B)

    Linear Model

    Yijkl = μ + αj + βk + γl(jk) + αβjk + εi(jkl)

    Schematic

    a1
    b1
    a1
    b2
    a2
    b1
    a2
    b2
    c1s1
    c2s2
    c3s3
    c4s4
    c5s5
    c6s6
    c7s7
    c8s8

    Anova Summary Table for CRPH-pqr(A*B) where A & B are Fixed Variables
      Source     Errorterm     df
    1 A             [3]        p-1
    2 B             [3]        q-1
    3 C(A*B)        [5]        pq(r(jk)-1)
    4 A*B           [5]        (p-1)(q-1)
    5 Residual                 pqr(jk)(n-1)


    Linear Statistical Models Course

    Phil Ender, 14may06, 9may00