GLM Syntax - Example 3: Hierarchically Nested Design with Random Effects

This example illustrates the specification for a 3-factor hierarchically nested design with random effects. You can run this example with the example data file Nested.sta. Note that brief descriptive comments are enclosed in curly brackets. Also, instead of variables A1, B1, and C1 you could use variables A2, B2, and C2, which code the levels of B and C within A and B(A), respectively. See also Variance Components, Example 3 for additional details.

GLM;

{ Dependent variable: }

   DEPENDENT = Y;

{ Specification of grouping variables (factors); note that

   in this example, the numeric values (codes) are specified that

   identify each group; these values are optional, and if left out,

   the program would by default use all values (codes) found in the

   data file. }

   GROUPS = A1(1 2)

            B1 (1 2 3 4 5)

            C1 (1 2 3 4 5 6 7 8 9 10 11);

{ The nesting operator "()" is used to specify the nested structure

  of the data, namely, that B1 is nested in A1, and C1 is nested in B1.}

   DESIGN = A1 + B1(A1) + C1(B1);

{ The overparameterized model is requested; because of the complex

   structure of some nested designs, the overparameterized model

   is always required for nested designs. }

   PARAM = OVERP;

{ Type I (sequential) sums of squares decomposition is requested. }

   SSTYPE = 1;

{ All factors in the design are random factors; and the program will

  estimate components of variance for all effects; for additional details,

  see also the Variance Components and Mixed Model ANOVA/ANCOVA

  module. }

   RANDOM = A1 B1 C1;

For more examples, see GLM Syntax Examples.