To construct a least squares mean (LS-mean) for a particular level of a particular effect, construct a row vector according to the following rules and use it in an ESTIMATE statement to compute the value of the LS-mean:
Set all that correspond to covariates (continuous variables) to their mean value.
Consider effects that are contained by the particular effect. (For a definition of containing, see Chapter 16, The Four Types of Estimable Functions.) Set the that correspond to levels associated with the particular level equal to 1. Set all other
in these effects equal to 0.
Consider the particular effect. Set the that correspond to the particular level equal to 1. Set the
that correspond to other levels equal to 0.
Consider the effects that contain the particular effect. If these effects are not nested within the particular effect, then set the that correspond to the particular level to
, where k is the number of such columns. If these effects are nested within the particular effect, then set the
that correspond to the particular level to
, where
is the number of nested levels within this combination of nested effects and
is the number of such combinations. For
that correspond to other levels, use 0.
Consider other effects that are not yet considered. For each effect that has no nested factors, set all that correspond to this effect to
, where j is the number of levels in the effect. For each effect that has nested factors, set all
that correspond to this effect to
, where
is the number of nested levels within a particular combination of nested effects and
is the number of such combinations.
The consequence of these rules is that the sum of the Xs within any classification effect is 1. This set of Xs forms a linear combination of the parameters that is checked for estimability before it is evaluated.
For example, consider the following model:
proc orthoreg;
class A B C;
model Y=A B A*B C Z;
lsmeans A B A*B C;
run;
Assume A has 3 levels, B has 2 levels, and C has 2 levels, and assume that every combination of levels of A and B exists in the data. Assume also that Z is a continuous variable with an average of 12.5. Then the least squares means are computed by the following linear combinations of the parameter estimates: