**[R] pwmean** -- Pairwise comparisons of means

__Syntax__

**pwmean** *varname***,** **over(***varlist***)** [*options*]

*options* Description
-------------------------------------------------------------------------
Main
* **over(***varlist***)** compare means across each combination of the
levels in *varlist*
__mcomp__**are(***method***)** adjust for multiple comparisons; default is
**mcompare(noadjust)**

Reporting
__l__**evel(***#***)** confidence level; default is **level(95)**
__ci__**effects** display a table of mean differences and
confidence intervals; the default
__pv__**effects** display a table of mean differences and p-values
__eff__**ects** display a table of mean differences with p-values
and confidence intervals
__cim__**eans** display a table of means and confidence intervals
__group__**s** display a table of means with codes that group
them with other means that are not
significantly different
**sort** sort results tables by displayed mean or
difference
*display_options* control column formats, line width, and
factor-variable labeling
-------------------------------------------------------------------------
***over(***varlist***)** is required.
See **[R] pwmean postestimation** for features available after estimation.

*method* Description
-------------------------------------------------------------------------
__noadj__**ust** do not adjust for multiple comparisons; the
default
__bon__**ferroni** Bonferroni's method
__sid__**ak** Sidak's method
__sch__**effe** Scheffe's method
__tuk__**ey** Tukey's method
**snk** Student-Newman-Keuls's method
__dunc__**an** Duncan's method
__dunn__**ett** Dunnett's method
-------------------------------------------------------------------------

__Menu__

**Statistics > Summaries, tables, and tests >** **Summary and descriptive**
**statistics > Pairwise comparisons of means**

__Description__

**pwmean** performs pairwise comparisons of means. It computes all pairwise
differences of the means of *varname* over the combination of the levels of
the variables in *varlist*. The tests and confidence intervals for the
pairwise comparisons assume equal variances across groups. **pwmean** also
allows for adjusting the confidence intervals and p-values to account for
multiple comparisons using Bonferroni's method, Scheffe's method, Tukey's
method, Dunnett's method, and others.

See **[R] pwcompare** for performing pairwise comparisons of means, estimated
marginal means, and other types of marginal linear predictions after
**anova**, **regress**, and most other estimation commands.

__Options__

+------+
----+ Main +-------------------------------------------------------------

**over(***varlist***)** is required and specifies that the means are computed for
each combination of the levels of the variables in *varlist*.

**mcompare(***method***)** specifies the method for computing p-values and
confidence intervals that account for multiple comparisons.

Most methods adjust the comparisonwise error rate, alpha_c, to
achieve a prespecified experimentwise error rate, alpha_e.

**mcompare(noadjust)** is the default; it specifies no adjustment.

alpha_c = alpha_e

**mcompare(bonferroni)** adjusts the comparisonwise error rate based on
the upper limit of the Bonferroni inequality:

alpha_e <= m * alpha_c

where m is the number of comparisons within the term.

The adjusted comparisonwise error rate is

alpha_c = alpha_e/m

**mcompare(sidak)** adjusts the comparisonwise error rate based on the
upper limit of the probability inequality

alpha_e <= 1 - (1 - alpha_c)^m

where m is the number of comparisons within the term.

The adjusted comparisonwise error rate is

alpha_c = 1 - (1 - alpha_e)^(1/m)

This adjustment is exact when the m comparisons are independent.

**mcompare(scheffe)** controls the experimentwise error rate using the F
(or chi-squared) distribution with degrees of freedom equal to
k-1 where k is the number of means being compared.

**mcompare(tukey)** uses what is commonly referred to as Tukey's honestly
significant difference. This method uses the Studentized range
distribution instead of the t distribution.

**mcompare(snk)** is a variation on **mcompare(tukey)** that counts only the
number of means participating in the range for a given comparison
instead of the full number of means.

**mcompare(duncan)** is a variation on **mcompare(snk)** with additional
adjustment to the significance probabilities.

**mcompare(dunnett)** uses Dunnett's method for making comparisons with a
reference category.

+-----------+
----+ Reporting +--------------------------------------------------------

**level(***#***)** specifies the confidence level, as a percentage, for confidence
intervals. The default is **level(95)** or as set by **set level**. The
significance level used by the **groups** option is 100-*#*, expressed as a
percentage.

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

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

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

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

**groups** specifies that a table of the means with their standard errors and
group codes be reported. Means 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 by the mean or
difference that is displayed in the table.

*display_options*: __nofvlab__**el**, **fvwrap(***#***)**, **fvwrapon(***style***)**, **cformat(***%fmt***)**,
**pformat(%***fmt***)**, **sformat(%***fmt***)**, and **nolstretch**.

**nofvlabel** displays factor-variable level values rather than attached
value labels. This option overrides the **fvlabel** setting; see **[R]**
**set showbaselevels**.

**fvwrap(***#***)** specifies how many lines to allow when long value labels
must be wrapped. Labels requiring more than *#* lines are
truncated. This option overrides the **fvwrap** setting; see **[R] set**
**showbaselevels**.

**fvwrapon(***style***)** specifies whether value labels that wrap will break
at word boundaries or break based on available space.

**fvwrapon(word)**, the default, specifies that value labels break at
word boundaries.

**fvwrapon(width)** specifies that value labels break based on
available space.

This option overrides the **fvwrapon** setting; see **[R] set**
**showbaselevels**.

**cformat(%***fmt***)** specifies how to format means, standard errors, and
confidence limits in the table of pairwise comparison of means.

**pformat(%***fmt***)** specifies how to format p-values in the table of
pairwise comparison of means.

**sformat(%***fmt***)** specifies how to format test statistics in the table of
pairwise comparison of means.

**nolstretch** specifies that the width of the table of pairwise
comparisons not be automatically widened to accommodate longer
variable names. The default, **lstretch**, is to automatically widen
the table of pairwise comparisons up to the width of the Results
window. To change the default, use **set lstretch off**. **nolstretch**
is not shown in the dialog box.

__Examples__

Setup
**. webuse yield**

Mean yield for each fertilizer
**. pwmean yield, over(fertilizer) cimeans**

Pairwise comparisons of mean yields for the fertilizers
**. pwmean yield, over(fertilizer) effects**

Pairwise comparisons of the mean yields using Tukey's adjustment for
multiple comparisons when computing p-values
**. pwmean yield, over(fertilizer) pveffects mcompare(tukey)**

Comparisons of the mean yield for each fertilizer to the control
(fertilizer 1) using Dunnett's adjustment
**. pwmean yield, over(fertilizer) effects mcompare(dunnett)**

__Stored results__

**pwmean** stores the following in **e()**:

Scalars
**e(df_r)** variance degrees of freedom
**e(balanced)** **1** if fully balanced data, **0** otherwise

Macros
**e(cmd)** **pwmean**
**e(cmdline)** command as typed
**e(title)** title in output
**e(depvar)** name of variable from which the means are computed
**e(over)** *varlist* from **over()**
**e(properties)** **b V**

Matrices
**e(b)** mean estimates
**e(V)** variance-covariance matrix of the mean estimates
**e(error)** mean estimability codes;
**0** means estimable,
**8** means not estimable
**e(b_vs)** mean difference estimates
**e(V_vs)** variance-covariance matrix of the mean difference
estimates
**e(error_vs)** mean difference estimability codes;
**0** means estimable,
**8** means not estimable