Home  /  Products  /  Features  /  Contrasts, pairwise comparisons, and margins

Contrasts, pairwise comparisons, and margins

Contrasts, pairwise comparisons, marginal means and marginal effects let you analyze the relationships between your outcome variable and your covariates, even when that outcome is binary, count, ordinal, categorical, or survival. Compute adjusted predictions with covariates set to interesting or representative values. Or compute marginal means for each level of a categorical covariate. Make comparisons of the adjusted predictions or marginal means using contrasts. After fitting almost any model in Stata, analyze the effect of covariate interactions, and easily create plots to visualize those interactions.


  • Analysis of main effects, simple effects, interaction effects, partial interaction effects, and nested effects
  • Comparisons against reference groups, of adjacent levels, or against the grand mean
  • Orthogonal polynomials
  • Helmert contrasts
  • Custom contrasts
  • ANOVA-style tests
  • Contrasts of nonlinear responses
  • Multiple-comparison adjustments
  • Balanced and unbalanced data
  • Contrasts in odds-ratio metric
  • Contrasts of means, intercepts, and slopes
  • Graphs of contrasts
  • Interaction plots

Pairwise comparisons

  • Compare estimated means, intercepts, and slopes
  • Compare marginal means, intercepts, and slopes
  • Balanced and unbalanced data
  • Nonlinear responses
  • Multiple-comparison adjustments: Bonferroni, Šidák, Scheffé, Tukey HSD, Duncan, and Student–Newman–Keuls adjustments
  • Group comparisons that are significant
  • Graphs of pairwise comparisons

Marginal analysis

  • Estimated marginal means
  • Marginal and partial effects
  • Average marginal and partial effects
  • Least-squares means
  • Predictive margins
  • Adjusted predictions, means, and effects
  • Works with multiple outcomes simultaneously
  • Contrasts of margins
  • Pairwise comparisons of margins
  • Profile plots
  • Graphs of margins and marginal effects
Watch Introduction to margins in Stata tutorials
Watch Profile plots and interaction plots in Stata tutorials

Additional resources

See New in Stata 18 to learn about what was added in Stata 18.