# Degrees of Freedom using “Containment” method

I have a question about the way SAS uses the "containment" method to obtain degrees of freedom in mixed models. In particular, I think SAS does the wrong thing in obtaining df for least-squares means (while doing the right thing for comparisons thereof).

To illustrate, consider the first provided example in the documentation for the MIXED procedure. It comprises a balanced split-plot experiment with 4 blocks. Each block is divided into 3 plots, which are assigned to levels of A. And each plot is divided into 2 subplots, which are assigned to levels of B. The SAS statements are

proc mixed data = sp;
class Block A B;
model Y = A B / ddfm = contain;
random Block A*Block;
lsmeans A B / diff;


What I am concerned about are the results from the LSMEANS statement

                          Least Squares Means
Standard
Effect    A    B    Estimate       Error      DF    t Value    Pr > |t|
A         1          32.8750      4.5403       6       7.24      0.0004
A         2          34.1250      4.5403       6       7.52      0.0003
A         3          25.7500      4.5403       6       5.67      0.0013
B              1     33.6667      4.2279      11       7.96      <.0001
B              2     28.1667      4.2279      11       6.66      <.0001

Differences of Least Squares Means
Standard
Effect   A   B   _A   _B   Estimate      Error     DF   t Value   Pr > |t|
A        1       2          -1.2500     3.1672      6     -0.39     0.7067
A        1       3           7.1250     3.1672      6      2.25     0.0655
A        2       3           8.3750     3.1672      6      2.64     0.0383
B            1        2      5.5000     1.5546     11      3.54     0.0046


These show that the LS means for A, or comparisons thereof, each have 6 df, and LS means for B or comparisons thereof each have 11 df.

My understanding is that containment is considered a conservative approach -- i.e., erring on the low side in obtaining degrees of freedom. Accordingly, I don't dispute the df for the comparisons, but I think the df for the LS means themselves are incorrect -- for both A and B.

My reasoning is this: Let $y_{ijk}$ denote the observation on the $i$th block, $j$th level of A, and $k$th level of B; and let $\bar y_{\cdot j\cdot}$ denote the observed mean at the $j$th level of A (which is equal to its LS mean, because the data are balanced). Also let $\sigma^2_b$, $\sigma^2_{Ab}$, and $\sigma^2_w$ denote the variance components for blocks, plots (A*Block interaction), and within error, respectively. Now, $Var(\bar y_{\cdot j\cdot})$ is a weighted sum of all three of these variances, while for a comparison of these means, $Var(\bar y_{\cdot j\cdot} - \bar y_{\cdot j'\cdot})$ involves only $\sigma^2_{Ab}$ and $\sigma^2_w$ because the block effects cancel out when we compute the difference. So it makes sense that if we are trying to be conservative, the degrees of freedom for the comparison should be 6, as that is the degrees of freedom for the coarsest random grouping involved, e.g. plots. However, the A means themselves include block effects, so their coarsest grouping is the blocks, which have only 3 df.

Similarly, for the B means, $Var(\bar y_{\cdot\cdot k})$ involves all three variances so the degrees of freedom for estimating it should be 3, the degrees of freedom for blocks. Meanwhile for the comparison, $Var(\bar y_{\cdot\cdot 1} - \bar y_{\cdot\cdot 2})$ involves only $\sigma^2_w$ because the block and plot effects cancel out. So it is right to use the residual df for the B comparisons but not for the B means.

As a point of additional information, if you replace ddfm = contain with ddfm = satterth in the example code, the resulting degrees of freedom are 4.2 for A, 3.21 for B, 6 for A differences, and 11 for B differences. So relative to Satterthwaite, containment over-estimates the df for the means themselves, while my idea of using 3 df for each under-estimates the df.

In summary, isn't "containment" supposed to have to do with which variance components come into play when estimating a parameter, and then choosing the minimum degrees of freedom involved in estimating those variance components?