__Title__

**[R] margins, pwcompare** -- Pairwise comparisons of margins

__Syntax__

**margins** [*marginlist*] [*if*] [*in*] [*weight*] [**,** __pwcomp__**are** *margins_options*]

**margins** [*marginlist*] [*if*] [*in*] [*weight*] [**,** __pwcomp__**are(***suboptions***)**
*margins_options*]

where *marginlist* is a list of factor variables or interactions that
appear in the current estimation results. The variables may be typed
with or without the **i.** prefix, and you may use any factor-variable
syntax:

. **margins i.sex i.group i.sex#i.group, pwcompare**

. **margins sex group sex#i.group, pwcompare**

. **margins sex##group, pwcompare**

*suboptions* Description
-------------------------------------------------------------------------
Pairwise comparisons
__ci__**effects** show effects table with confidence intervals; the
default
__pv__**effects** show effects table with p-values
__eff__**ects** show effects table with confidence intervals and
p-values
__cim__**argins** show table of margins and confidence intervals
__group__**s** show table of margins and group codes
**sort** sort the margins or contrasts in each term
-------------------------------------------------------------------------

**fweight**s, **aweight**s, **iweight**s, and **pweight**s are allowed; see weight.

__Menu__

**Statistics > Postestimation**

__Description__

**margins** with the **pwcompare** option performs pairwise comparisons of
margins. **margins, pwcompare** extends the capabilities of **pwcompare** to any
of the nonlinear responses, predictive margins, or other margins that can
be estimated by **margins**.

__Suboptions__

+----------------------+
----+ Pairwise comparisons +---------------------------------------------

**cieffects** specifies that a table of the pairwise comparisons with their
standard errors and confidence intervals be reported. This is the
default.

**pveffects** specifies that a table of the pairwise comparisons with their
standard errors, test statistics, and p-values be reported.

**effects** specifies that a table of the pairwise comparisons with their
standard errors, test statistics, p-values, and confidence intervals
be reported.

**cimargins** specifies that a table of the margins with their standard
errors and confidence intervals be reported.

**groups** specifies that a table of the margins with their standard errors
and group codes be reported. Margins with the same letter in the
group code are not significantly different at the specified
significance level.

**sort** specifies that the reported tables be sorted on the margins or
contrasts in each term.

__Examples__

These examples are intended for quick reference. For a conceptual
overview of **margins,** **pwcompare** and examples with discussion, see *Remarks*
*and examples* in **[R] margins, pwcompare**.

Setup
**. webuse nhanes2**
**. logistic highbp sex##agegrp##c.bmi**

Pairwise comparisons of the average predicted probability of high blood
pressure conditional on being in each of the six age groups
**. margins agegrp, pwcompare**

Predictive margins with group codes denoting margins that are not
significantly different
**. margins agegrp, pwcompare(group)**

Pairwise comparisons of margins using Bonferroni's adjustment for
multiple comparisons
**. margins agegrp, pwcompare(group) mcompare(bonferroni)**

__Stored results__

**margins,** **pwcompare** stores the following additional results in **r()**:

Scalars
**r(k_terms)** number of terms participating in pairwise
comparisons

Macros
**r(cmd)** **pwcompare**
**r(cmd2)** **margins**
**r(group***#***)** group code for the *#*th margin in **r(b)**
**r(mcmethod_vs)** *method* from **mcompare()**
**r(mctitle_vs)** title for *method* from **mcompare()**
**r(mcadjustall_vs)** **adjustall** or empty

Matrices
**r(b)** margin estimates
**r(V)** variance-covariance matrix of the margin estimates
**r(b_vs)** margin difference estimates
**r(V_vs)** variance-covariance matrix of the margin difference
estimates
**r(error_vs)** margin difference estimability codes;
**0** means estimable,
**8** means not estimable
**r(table_vs)** matrix containing the margin differences with their
standard errors, test statistics, p-values, and
confidence intervals
**r(L)** matrix that produces the margin differences

**margins,** **pwcompare** with the **post** option also stores the following
additional results in **e()**:

Scalars
**e(k_terms)** number of terms participating in pairwise
comparisons

Macros
**e(cmd)** **pwcompare**
**e(cmd2)** **margins**

Matrices
**e(b)** margin estimates
**e(V)** variance-covariance matrix of the margin estimates
**e(b_vs)** margin difference estimates
**e(V_vs)** variance-covariance matrix of the margin difference
estimates
**e(error_vs)** margin difference estimability codes;
**0** means estimable,
**8** means not estimable
**e(L)** matrix that produces the margin differences