Example 3: Variance Component Estimation for a Hierarchically Nested Random Design
Example 3 is based on a fictitious data set with three independent variables A, B, and C (coded in two different ways as described below) and a single dependent variable, Y. All three factors are considered to have random effects, and Factor C is nested within Factor B, which in turn is nested within Factor A, making the design a hierarchically nested random effects design. There are unequal Ns for all three factors. The data are shown below and are available in the file nested.sta. Open this data file via the File - Open Examples menu; it is in the Datasets folder.

As can be seen in the listing of the data set above, A1 and A2 are coded identically. B1, and C1 are coded with values identifying consecutive overall levels of the B and C nested factors, respectively, and B2 and C2 are coded with values identifying the levels within the other factors in which B and C are nested, respectively. Thus, the two sets of factors merely represent different codings of the levels of the nested factors. We will first estimate variance components for the factors in the hierarchically nested random effects design using the A1, B1, and C1 variables.
To perform the analysis, select Variance Components from the Statistics - Advanced Linear/Nonlinear Models menu to display the Variance Components & Mixed Model ANOVA Startup Panel. On the Quick tab, click the Variables button to display the standard variable selection dialog. Here, select variable Y as the Dependent vars, variables A1, B1, and C1 as Random factors, and then click the OK button. To specify the design and the coding of the independent variables, click on the Model tab and select the Hierarchically nested design and Codes identify consecutive overall levels option buttons. Then click the OK button on the Startup Panel to display the Variance Components and Mixed Model ANOVA/ANCOVA Results dialog.
Reviewing the Results.


To perform the same analysis using the A2, B2, and C2 variables, click the Cancel button on the Results dialog to return to the Variance Components & Mixed Model ANOVA Startup Panel. On the Quick tab, click the Variables button, and change the Random factors to A2, B2, and C2. On the Model tab, select the Codes identify levels within other factors option button, and then click the OK button to display the Variance Components and Mixed Model ANOVA/ANCOVA Results dialog. Now, click the Summary: Components of variance button to display the Components of variance and Denominator synthesis ANOVA spreadsheets. You should find that the results are identical to those for the A1, B1, and C1 variables.
See Variance Components Index.