LMIXED Procedure

CONTRAST Statement

  • CONTRAST 'label' contrast-specification <, contrast-specification> <, …> </ options>;

The CONTRAST statement provides a mechanism for obtaining custom hypothesis tests. It is patterned after the CONTRAST statement in PROC MIXED and enables you to select an appropriate inference space (McLean, Sanders, and Stroup 1991).

You can test the hypothesis bold upper L prime bold-italic phi equals bold 0, where bold upper L prime equals left-bracket bold upper K prime bold upper M prime right-bracket and bold-italic phi prime equals left-bracket bold-italic beta prime bold-italic gamma prime right-bracket, in several inference spaces. The inference space corresponds to the choice of bold upper M. When bold upper M equals bold 0, your inferences apply to the entire population from which the random effects are sampled; this is known as the broad inference space. When all elements of bold upper M are nonzero, your inferences apply only to the observed levels of the random effects. This is known as the narrow inference space, and you can also choose it by specifying all the random effects as fixed. The GLM procedure uses the narrow inference space. Finally, by zeroing portions of bold upper M that correspond to selected main effects and interactions, you can choose intermediate inference spaces. The broad inference space is usually the most appropriate, and it is used when you do not specify any random effects in the CONTRAST statement.

You can specify the following:

label

identifies the contrast in the table. A label is required for every contrast that you specify. Labels can be up to 20 characters long and must be enclosed in single quotes.

contrast-specification

identifies the fixed and random effects and their coefficients from which the bold upper L prime matrix is formed. Each contrast-specification is referred to as a row in the bold upper L prime matrix. Specifically, contrast-specification takes the form

< fixed-effect values …> < | random-effect values …>

fixed-effect

identifies an effect that appears in the MODEL statement. The keyword INTERCEPT can be used as an effect when an intercept is fitted in the model. You do not need to include all effects that appear in the MODEL statement.

random-effect

identifies an effect that appears in the RANDOM statement. The first random effect must follow a vertical bar (|); however, random effects are not required.

values

are constants that are elements of the bold upper L matrix associated with the fixed and random effects.

The contrast-specification is specified by a series of nonpositional units. Each unit starts with an effect name, followed by a list of elements in square brackets. In each set of square brackets, you enter the coefficient and level indicators for each variable in an effect. A nonpositional unit has the following form:

effect-name [coefficient, level indicators]
            [coefficient, level indicators]
            ...
            [coefficient, level indicators]

For example, in the following CONTRAST statement, the contrast-specification has two nonpositional units. The first unit is "b [1, 1] [-1, 2]", and the second unit is "a*b [1, 2 1] [-1, 2 2]".

class a b;
model y = a b a*b;
contrast 'B at A2'
          b   [1, 1]   [-1, 2]
          a*b [1, 2 1] [-1, 2 2];

The first nonpositional unit starts with effect 'b', followed by two sets of square brackets. In bracket [1,1], the first element is the coefficient, and the second element is the level indicator 1, which corresponds to the first level of the CLASS variable 'b'.

The second nonpositional unit starts with effect 'a*b', followed by two sets of square brackets, [1, 2 1] and [-1, 2 2]. In bracket [1,2 1], the coefficient is 1, and the level indicators are the second level of variable 'a' and the first level of variable 'b'. In bracket [-1,2 2], the coefficient is -1, and the level indicators are the second level of variable 'a' and the second level of variable 'b'.

The comma that separates the coefficient and level indicators in a bracket is optional.

The rows of the bold upper K prime component of bold upper L prime are specified on the left side of the vertical bars (|). These rows test the fixed effects and are therefore checked for estimability. The rows of the bold upper M prime component of bold upper L prime are specified on the right side of the vertical bars. They test the random effects, and no estimability checking is necessary.

If PROC LMIXED finds the fixed-effects portion in at least one specified contrast-specification to be nonestimable (see the SINGULAR= option), then it determines that the whole contrast is nonestimable and displays missing values for the test statistics and a note in the log.

Assume that there are two fixed effects, 'a' and 'a*b'. If you specify the coefficient for effect 'a' but not for effect 'a*b', then the coefficients for effect 'a' are automatically "filled in" over the levels of the higher-order effect 'a*b'. This feature is designed to preserve estimability in cases where there are complex higher-order effects. The coefficients for the higher-order effect are determined by equitably distributing the coefficients of the lower-level effect. In addition, if the intercept is specified, it is distributed over all classification effects that are not contained by any other specified effect. If an effect is not specified for coefficients and does not contain any coefficient-specified effects, then all of its coefficients in bold upper L are set to 0. You can override this default by specifying coefficients for the higher-order effect.

If you specify a SUBJECT effect in the RANDOM statement, then the coefficients that you specify for the effects in the RANDOM statement are equitably distributed across the levels of the SUBJECT effect. You can use the E option to see exactly what bold upper L matrix is used.

The SUBJECT and GROUP options in the CONTRAST statement are useful for the case where a SUBJECT= or GROUP= variable appears in the RANDOM statement, and you want to contrast different subjects or groups. By default, CONTRAST statement coefficients about random effects are distributed equally across subjects and groups.

PROC LMIXED handles missing level combinations of CLASS variables similarly to the way PROC GLM does. Both procedures delete fixed-effects parameters that correspond to missing levels in order to preserve estimability. However, PROC LMIXED does not delete missing level combinations for random-effects parameters because linear combinations of the random-effects parameters are always estimable. These conventions can affect the way that you specify the CONTRAST statement coefficients.

The CONTRAST statement computes the statistic

upper F equals StartFraction StartBinomialOrMatrix ModifyingAbove bold-italic beta With caret Choose ModifyingAbove bold-italic gamma With caret EndBinomialOrMatrix prime bold upper L left-parenthesis bold upper L prime ModifyingAbove bold upper C With caret bold upper L right-parenthesis Superscript negative 1 Baseline bold upper L prime StartBinomialOrMatrix ModifyingAbove bold-italic beta With caret Choose ModifyingAbove bold-italic gamma With caret EndBinomialOrMatrix Over r EndFraction

where r equals normal r normal a normal n normal k left-parenthesis bold upper L prime ModifyingAbove bold upper C With caret bold upper L right-parenthesis and approximates its distribution with an F distribution. In this expression, ModifyingAbove bold upper C With caret is an estimate of the generalized inverse of the coefficient matrix in the mixed model equations.

The numerator degrees of freedom in the F approximation is r equals normal r normal a normal n normal k left-parenthesis bold upper L prime ModifyingAbove bold upper C With caret bold upper L right-parenthesis, and the denominator degrees of freedom is the residual degrees of freedom that you define by specifying the DDFM=RESIDUAL option. You can change the denominator degrees of freedom by using the DF= option.

Results from all CONTRAST statements are displayed together in the Contrasts ODS table.

You can specify the following options in the CONTRAST statement after a slash (/):

CHISQ

performs chi squared tests in addition to any F tests. A chi squared statistic equals its corresponding F statistic times the associate numerator degrees of freedom, and the same degrees of freedom is used to compute the p-value for the chi squared test. This p-value will always be less than that for the F test, because it effectively corresponds to an F test with infinite denominator degrees of freedom.

DF=number

specifies the denominator degrees of freedom for the F test. The default is the residual degrees of freedom that you define by specifying the DDFM=RESIDUAL option.

E

displays the bold upper L matrix coefficients for the contrast. In the ODS output, the name of this "L Matrix Coefficients" table is Coef.

GROUP coeffs

sets up random-effect contrasts between different groups when a GROUP= variable appears in the RANDOM statement. By default, CONTRAST statement coefficients about random effects are distributed equally across groups. You can enter a multiple-row contrast, but you can enter only one row for the GROUP coefficients. For example, the following CONTRAST statement has a GROUP option with two sets of brackets; these two sets of brackets apply to each row of contrast.

contrast 'Trt @ x=0.4 and 0.5' trt [1 1] [-1 2] | x [0.4 1],
                               trt [1 1] [-1 3] | x [0.4 1],
                               trt [1 1] [-1 2] | x [0.5 1],
                               trt [1 1] [-1 3] | x [0.5 1] /
                               group [1 1] [-1 2];

If the GROUP effect has two levels and random effect 'x' has one level, then the specified coefficient 0.4 in the first contrast row is expanded across two levels of the GROUP effect weighted by GROUP coefficients. The resulting coefficients are

0.4 -0.4

SINGULAR=number

tunes the estimability checking. If bold upper U is a matrix, define ABS(bold upper U prime) to be a vector bold v whose element v Subscript i is the largest absolute value of the elements of row i of bold upper U prime. If one of the elements in (ABS(bold upper K prime minus bold upper K prime bold upper T) - ABS(bold upper K prime)*number) is greater than zero, then the corresponding row of bold upper K prime is declared nonestimable. If any row is nonestimable, then bold upper K is declared nonestimable. Here bold upper T is the Hermite form matrix left-parenthesis bold upper X prime bold upper X right-parenthesis Superscript minus Baseline bold upper X prime bold upper X. The value of number must be between 0 and 1, inclusive. By default, SINGULAR=1E–4.

SUBJECT coeffs

sets up random-effects contrasts between different subjects when a SUBJECT= variable appears in the RANDOM statement. By default, CONTRAST statement coefficients about random effects are distributed equally across subjects. The rules for listing subject coefficients for multiple-row CONTRAST statements are the same as the rules for listing GROUP coefficients.

Last updated: September 22, 2026