Shared Concepts and Topics

Syntax: MARGINS Statement

  • MARGINS fixed-effects </ options>;

You can specify multiple effects in one or multiple MARGINS statements, and all MARGINS statements must appear after the MODEL statement. Predictive margin computations are not supported for t or lognormal distributions or for constructed effects.

Some procedures construct an approximate t test to test the null hypothesis that the associated population quantity equals zero; other procedures perform chi-square-based inference. By default, the denominator degrees of freedom for the t test are the same as those displayed for the effect in the "Type III Tests of Fixed Effects" table. Table 31 summarizes the options available in the MARGINS statement. All options for the MARGINS statement are discussed in alphabetical order after the table.

Table 31: MARGINS Statement Options

Option Description
Construction and Computation of Predictive Margins
AT Modifies the covariate value in computing predictive margins
DIFF Computes differences of predictive margins
SLICEBY= Partitions tests of interaction effects
SLICEDIFF Computes differences of sliced predictive margins and determines the types of differences
USEWEIGHT Specifies whether to use WEIGHT variables to compute predictive margins
Degrees of Freedom and p-Values
ADJUST= Specifies the method of multiple comparison adjustment of predictive margin differences
ALPHA=alpha Specifies the confidence level (1 minus alpha)
DF= Assigns a specific value to degrees of freedom for t tests and confidence limits
STEPDOWN Adjusts multiple comparison p-values further in a step-down fashion
Statistical Output
CL Constructs confidence limits for predictive margins and/or predictive margin differences


You can specify the following options in the MARGINS statement after a slash (/).

ADJUST=BON
ADJUST=DUNNETT
ADJUST=SCHEFFE
ADJUST=SIDAK
ADJUST=SIMULATE<(simoptions)>
ADJUST=SMM | GT2
ADJUST=TUKEY

performs a multiple comparison adjustment for the p-values and confidence limits for the differences of predictive margins. The adjusted quantities are produced in addition to the unadjusted quantities. By default, the procedures perform all pairwise differences. If you specify ADJUST=DUNNETT, the procedures analyze all differences between the margins and the control level. The ADJUST= option does not imply the DIFF option.

The BON (Bonferroni) and SIDAK adjustments involve correction factors described in Chapter 53, The GLM Procedure, and Chapter 86, The MULTTEST Procedure; also see Westfall and Young (1993) and Westfall et al. (1999). When you specify ADJUST=TUKEY and your data are unbalanced, the procedures use the approximation described in Kramer (1956) and identify the adjustment as "Tukey-Kramer" in the results. Similarly, when you specify ADJUST=DUNNETT and the predictive margins are correlated, the procedures use the factor-analytic covariance approximation described in Hsu (1992) and identify the adjustment as "Dunnett-Hsu" in the results. The approximation derives an approximate "effective sample sizes" for which exact critical values are computed. Note that computing the exact adjusted p-values and critical values for unbalanced designs can be computationally intensive. A simulation-based approach, specified by the ADJUST=SIM option, is nondeterministic but can provide sufficiently accurate inferences in much less time. The preceding references also describe the SCHEFFE and SMM adjustments.

The SIMULATE adjustment computes adjusted p-values and confidence limits from the simulated distribution of the maximum or maximum absolute value of a multivariate t random vector. All covariance parameters, except the residual scale parameter, are fixed at their estimated values throughout the simulation, potentially resulting in some underdispersion. The simulation estimates q, the true left-parenthesis 1 minus alpha right-parenthesis quantile, where 1 minus alpha is the confidence coefficient. The default value of alpha is 0.05, and you can change this value by specifying the ALPHA= option in the MARGINS statement.

The number of samples is set so that the tail area for the simulated q is within gamma of 1 minus alpha with 100 left-parenthesis 1 minus epsilon right-parenthesis% confidence. In equation form,

normal upper P normal r left-parenthesis StartAbsoluteValue upper F left-parenthesis ModifyingAbove q With caret right-parenthesis minus left-parenthesis 1 minus alpha right-parenthesis EndAbsoluteValue less-than-or-equal-to gamma right-parenthesis equals 1 minus epsilon

where ModifyingAbove q With caret is the simulated q and F is the true distribution function of the maximum; see Edwards and Berry (1987) for details. By default, gamma = 0.005 and epsilon = 0.01, placing the tail area of ModifyingAbove q With caret within 0.005 of 0.95 with 99% confidence. The ACC= and EPS= —simoptions reset gamma and epsilon, respectively; the NSAMP= simoption sets the sample size directly; and the SEED= simoption specifies an integer to use in starting the pseudorandom number generator for the simulation. If you do not specify a seed, or if you specify a value less than or equal to zero, the seed is generated by reading the time of day from the computer’s clock. For additional descriptions of these and other simulation options, see the section LSMEANS Statement in Chapter 53, The GLM Procedure.

If you specify the STEPDOWN option, the p-values are further adjusted in a step-down fashion. For certain options and data, this adjustment is exact under an iid upper N left-parenthesis 0 comma sigma squared right-parenthesis model for the dependent variable, in particular for the following:

  • for ADJUST=DUNNETT when the means are uncorrelated

  • for ADJUST=TUKEY with STEPDOWN(TYPE=LOGICAL) when the means are balanced and uncorrelated

The first case is a consequence of the nature of the successive step-down hypotheses for comparisons with a control; the second case uses an extension of the maximum studentized range distribution appropriate for partition hypotheses (Royen 1989). Finally, when STEPDOWN(TYPE=FREE), the ADJUST=TUKEY option uses the Royen (1989) extension in such a way that the resulting p-values are conservative.

ALPHA=number

constructs confidence intervals for each of the predictive margins with significance level 1 – number. The value of number must be between 0 and 1; by default, ALPHA=0.05.

AT variable=value
AT (variable-list)=(value-list)
AT MEANS

enables you to modify the values of the covariates that are used in computing predictive margins. By default, all covariate effects are set equal to their observed values for computation of predictive margins. The AT option enables you to assign arbitrary values to the covariates. Additional columns in the output table indicate the values of the covariates.

If there is an effect that contains two or more covariates, the AT MEANS option sets the effect equal to the product of the individual means rather than the mean of the product.

As an example, consider the following invocation of PROC GLIMMIX:

proc glimmix;
   class A;
   model Y = A x1 x2 x1*x2;
   margins A;
   margins A / at means;
   margins A / at x1=1.2;
   margins A / at (x1 x2)=(1.2 0.3);
run;

The first two MARGINS statements set x1 and x2 to their observed values for each observation. In the second MARGINS statement, x1 is set to x overbar Subscript 1 (the mean of x1) and x2 is set to x overbar Subscript 2 (the mean of x2). Their interaction is set to x overbar Subscript 1 Baseline times x overbar Subscript 2. The third MARGINS statement sets x1 to 1.2, and the final MARGINS statement sets these variables to 1.2 and 0.3, respectively.

CL

constructs t-type confidence limits for each of the predictive margins. If the procedure enables you to specify the DDFM=NONE option, then the procedure uses infinite degrees of freedom for this test, essentially computing a z interval. The confidence level is 0.95 by default; you can change this by specifying the ALPHA= option. If you specify an ADJUST= option, then the confidence limits are adjusted for multiplicity, but if you also specify the STEPDOWN option, then only p-values are adjusted in a step-down fashion, not the confidence limits.

DF=number

specifies the degrees of freedom for the t test and confidence limits. The default is the denominator degrees of freedom from the "Type III Tests of Fixed Effects" table corresponding to the margins effect. This option has no effect on procedures that perform chi-square-based inference.

DIFF<=difftype>
PDIFF<=difftype>

displays differences of the predictive margins. The optional difftype specifies which differences to display; the difftype values are ALL, CONTROL, CONTROLL, and CONTROLU. The ALL difftype (the default) displays all pairwise differences. The CONTROL difftype computes differences between each margin and a control; by default, the control is the first level of each effect that you specify in the MARGINS statement.

To specify which levels of the effects are the controls, list the quoted formatted values in parentheses after the CONTROL keyword. For example, for the classification variables A, B, and C, each having two levels, 1 and 2, the following MARGINS statement specifies the (1,2) level of A*B and the (2,1) level of B*C as controls:

margins A*B B*C / diff=control('1' '2', '2' '1');

For an effect that has multiple classification variables, the quoted formatted values are assigned to these variables in the order in which they appear in the CLASS statement.

Two-tailed tests and confidence limits are associated with the CONTROL difftype. For one-tailed results, use either the CONTROLL or CONTROLU difftype. The CONTROLL difftype tests whether the noncontrol levels are significantly smaller than the control; the upper confidence limits for the control minus the noncontrol levels are considered to be infinity and are displayed as missing. Conversely, the CONTROLU difftype tests whether the noncontrol levels are significantly larger than the control; the upper confidence limits for the noncontrol levels minus the control are considered to be infinity and are displayed as missing.

If you want to perform multiple comparison adjustments on the differences of predictive margins, you must specify the ADJUST= option.

SLICEBY=fixed-effect | (fixed-effects)

specifies effects by which to partition interaction MARGINS effects. This option produces tests of margins for each level of the specified slice effect.

For example, suppose that the margins effect is A*B. To test the margins of A*B for each level of A, you can specify the following statement:

margins A*B / sliceby=A;

The SLICEBY= option produces an F test (or a chi-square test for procedures that perform chi-square-based inference) that tests the simultaneous equality of the margins at a fixed level of the slice effect A. To display differences of the margins while holding one or more factors at a fixed level, specify the SLICEDIFF option.

SLICEDIFF<=difftype>

constructs the specified type of differences for the sliced margins and tests them against zero. The difftype values are ALL, CONTROL, CONTROLL, and CONTROLU. The ALL difftype constructs all pairwise differences; it is the default. The CONTROL, CONTROLL, and CONTROLU difftypes construct the differences between the margins and the control. Whereas the SLICEBY= option tests the simultaneous equality of the margins at a fixed level of the slice effect, the SLICEDIFF option tests pairwise differences of these margins. This enables you to perform multiple comparisons among the levels of one factor at a fixed level of the other factor.

For example, assume that, in a certain design, factors A and B have a = 4 and b = 3 levels, respectively. Consider the following statements:

proc glimmix;
   class A B;
   model y = A B A*B;
   margins A*B / sliceby=A;
   margins A*B / sliceby=A slicediff=all;
run;

The first MARGINS statement produces four F tests, one per level of A. Denote the three margins that correspond to the first level of A as bold m Subscript a Baseline 1 Superscript left parenthesis 1 right parenthesis, bold m Subscript a Baseline 1 Superscript left parenthesis 2 right parenthesis, and bold m Subscript a Baseline 1 Superscript left parenthesis 3 right parenthesis. Then the first F test performs a test of the two-degrees-of-freedom hypothesis

upper H colon StartLayout Enlarged left brace 1st Row  bold m Subscript a Baseline 1 Superscript left parenthesis 1 right parenthesis Baseline minus bold m Subscript a Baseline 1 Superscript left parenthesis 2 right parenthesis Baseline equals 0 2nd Row  bold m Subscript a Baseline 1 Superscript left parenthesis 1 right parenthesis Baseline minus bold m Subscript a Baseline 1 Superscript left parenthesis 3 right parenthesis Baseline equals 0 EndLayout

The SLICEDIFF=ALL option performs tests of the difference between all pairs of these three margins. In the example this corresponds to tests of the form

StartLayout 1st Row 1st Column upper H colon bold m Subscript a Baseline 1 Superscript left parenthesis 1 right parenthesis Baseline minus bold m Subscript a Baseline 1 Superscript left parenthesis 2 right parenthesis Baseline 2nd Column equals 0 2nd Row 1st Column upper H colon bold m Subscript a Baseline 1 Superscript left parenthesis 1 right parenthesis Baseline minus bold m Subscript a Baseline 1 Superscript left parenthesis 3 right parenthesis Baseline 2nd Column equals 0 3rd Row 1st Column upper H colon bold m Subscript a Baseline 1 Superscript left parenthesis 2 right parenthesis Baseline minus bold m Subscript a Baseline 1 Superscript left parenthesis 3 right parenthesis Baseline 2nd Column equals 0 EndLayout

In the example, with a = 4 and b = 3, the second MARGINS statement produces four sets of predictive margin differences. Within each set, factor A is held fixed at a particular level, and each set consists of three comparisons.

For computing differences between the margins and the control, the default control is the first level of each effect that you specify in the MARGINS statement. To specify which levels of the effects are the controls, list the quoted formatted values in parentheses after the keyword CONTROL.

For example, if the effects A and B are classification variables, each having three levels (1, 2, and 3), the following MARGINS statement specifies the (1,3) level of A*B as the control:

margins A*B / sliceby=(A B)
              slicediff=control('1' '3');

This MARGINS statement first produces predictive margin differences while holding the levels of A fixed, and then produces predictive margin differences while holding the levels of B fixed. In the former case, level '3' of B serves as the control level. In the latter case, level '1' of A serves as the control.

Note that the control level specification is positional; for example, if you want to produce predictive margin differences while holding the levels of A fixed and using level '3' of B as the control level, then you still must specify a placeholder for the control level of A:

margins A*B / sliceby=A
              slicediff=control('1' '3');

For an effect that has multiple classification variables, the quoted formatted values are assigned to these variables in the order in which they appear in the CLASS statement.

Two-tailed tests and confidence limits are associated with the CONTROL difftype. For one-tailed results, use either the CONTROLL or CONTROLU difftype. The CONTROLL difftype tests whether the noncontrol levels are significantly smaller than the control; the upper confidence limits for the control minus the noncontrol levels are considered to be infinity and are displayed as missing. Conversely, the CONTROLU difftype tests whether the noncontrol levels are significantly larger than the control; the upper confidence limits for the noncontrol levels minus the control are considered to be infinity and are displayed as missing.

When you specify the ADJUST= option, the procedures also adjust the tests for multiplicity. The adjustment is based on the number of comparisons within each level of the SLICEBY= effect.

STEPDOWN<(step-down-options)>

further adjusts multiple comparison adjustments for the p-values of predictive margin differences in a step-down fashion. Step-down methods increase the power of multiple comparisons by taking advantage of the fact that a p-value is never declared significant unless all smaller p-values are also declared significant. Note that the step-down adjustment together with the ADJUST=BON option corresponds to the methods of Holm (1979) and "Method 2" of Shaffer (1986); this is the default. Using step-down-adjusted p-values combined with the ADJUST=SIMULATE option corresponds to the method of Westfall (1997).

The STEPDOWN option affects only p-values, not confidence limits. When ADJUST=SIMULATE, the generalized least squares hybrid approach of Westfall (1997) is used to increase Monte Carlo accuracy.

You can specify the following step-down-options in parentheses:

MAXTIME=n

specifies the time (in seconds) to spend computing the maximal logically consistent sequential subsets of equality hypotheses when TYPE=LOGICAL. By default, MAXTIME=60. If the specified value is exceeded, the adjusted tests are not computed. When this occurs, you can try increasing this value. However, note that there are common multiple comparison problems for which this computation requires a huge amount of time—for example, for all pairwise comparisons of more than 10 groups. In such cases, try specifying TYPE=FREE (the default) or TYPE=LOGICAL(n) for small n.

TYPE=LOGICAL<(n)> | FREE

specifies whether to use logical constraints. When TYPE=LOGICAL, the step-down adjustments are computed by using maximal logically consistent sequential subsets of equality hypotheses (Shaffer 1986; Westfall 1997). When TYPE=FREE, sequential subsets are computed without logical constraints. The TYPE=FREE results are more conservative than those for TYPE=LOGICAL, but they can be much more efficient to produce for many comparisons. For example, it is not feasible to take logical constraints between all pairwise comparisons of more than 10 groups. For this reason, TYPE=FREE is the default.

However, you can reduce the computational complexity of taking logical constraints into account by limiting the depth of the search tree that you use to compute them, specifying the optional depth parameter as a number n in parentheses after TYPE=LOGICAL. As with TYPE=FREE, results for TYPE=LOGICAL(n) are more conservative than the true TYPE=LOGICAL results, but even for TYPE=LOGICAL(0) they can be appreciably less conservative than the TYPE=FREE results, and they are computationally feasible for much larger numbers of comparisons. If you do not specify n, or if n = –1, the full search tree is used.

USEWEIGHT<=TRUE | FALSE>
WEIGHT<=TRUE | FALSE>
WEIGHTED<=TRUE | FALSE>

specifies whether to take WEIGHT variables into account in computing predictive margins. Frequency variables are always used in the predictive margins computations. Specifying the USEWEIGHT option is the same as specifying USEWEIGHT=TRUE. See the individual procedure chapters to determine whether weights are used in the computations by default.

Last updated: December 09, 2022