```-------------------------------------------------------------------------------
help for cochran
-------------------------------------------------------------------------------

Test for equality of proportions in matched samples (Cochran's Q)

cochran varlist [weight] [if exp] [in range] [, detail ]

by ... : may be used with cochran; see help by.

fweights are allowed with cochran; see help weights.

Description

cochran performs a test for equality of two or more proportions in
matched samples: Taking the 1-to-1 matching of observations into account,
cochran tests that the proportion of nonzero outcomes is constant for the
variables in varlist.

The chi-squared calculated by cochran is known as Cochran's Q (Cochran
1950). If only two proportions are compared, Cochran's Q is equal to the
McNemar chi-squared calculated by mcc. An exact significance probability
will be reported in this case.

Options

detail specifies to display the proportions and counts (i.e. number of
nonzero outcomes).

Saved Results

Scalars:

r(N)         number of cases
r(chi2)      Cochran's Q
r(df)        degrees of freedom
r(p)         p-value
r(p_exact)   exact p-value (if only two proportions are compared)

Matrices:

r(T)         proportions and counts

Methods and Formulas

Cochran's Q is defined as

c * (c-1) * sum_j ( T_j - T_bar )^2
Q = -------------------------------------
c * sum_i ( u_i ) - sum_i ( u_i^2 )

where c is the number columns (= number of proportions = number of
variables), T_j is the number of nonzero outcomes in the jth column,
T_bar is the mean number of nonzero outcomes (i.e. the proportion of
nonzero outcomes) per column, and u_i is the number of nonzero outcomes
in the ith row (= number of nonzero outcomes in the ith observarion).

For large samples, Q is chi-square distributed with (c-1) degrees of
freedom.

Reference

Cochran, W. G. 1950. The Comparison of Percentages in Matched Samples.
Biometrika 37(3/4): 256-266.

Author

Ben Jann, ETH Zurich, jann@soz.gess.ethz.ch

Also see

```