*! version 1.0.0 05sep2014
help alignedpairs

Title

alignedpairs-- Aligned ranks test for matched pairs (Hodges-Lehmann)

Syntax

alignedpairs varname = exp [if] [in] [, level(#)]

level(level:level) specifies the confidence level for the Hodges-Lehmann estimator; level(95)

by is allowed with alignedpairs; see [D] by.

Description

alignedpairs performs two analyses for matched-pairs: (1) the standard Wilcoxon signed-ranks test (Wilcoxon 1945) using the official
Stata [R] signrank, and (2) the Hodges-Lehmann (1963) treatment effects estimator with distribution-free confidence intervals
(for exposition, see Hollander et al. [2014] pg 56-60).

In the case of matched-pairs, the Hodges-Lehmann estimator is defined as the median of the set of n(n+1)/2 Walsh averages (Walsh 1949).
More specifically, the process entails estimating the average difference in outcomes (x-y) for every possible n(n+1)/2 pair and then deriving the
overall median of all averages (the Hodges-Lehmann estimator). A distribution-free confidence interval is estimated using large-sample approximation
(see Hollander et al. [2014] pg. 59).

For the Hodges-Lehmann aligned ranks test on unmatched data, see alignedranks, and for the Hodges-Lehmann aligned ranks test
for matched sets, see alignedsets (both available for download at SSC).

Examples

Load example data

. use hamilton, clear

Perform aligned ranks test comparing x and y outcomes specifying a 96% confidence interval (see Hollander et al. [2014] pg 56-60)

. alignedpairs y=x, level(96)

Compare results using a paired t test

. ttest y=x, level(96)

Saved results

alignedpairs saves the following in r():

Scalars

r(N_neg) number of negative comparisons

r(N_pos) number of positive comparisons

r(N_tie) number of tied comparisons

r(p_2) two-sided probability

r(p_neg) one-sided probability of negative comparison

r(p_pos) one-sided probability of positive comparison

r(estimate) Hodges-Lehmann estimate

r(lb_1) lower confidence bound

r(ub_1) upper confidence bound

r(hl_obs) n(n+1)/2 number of observations

References

Hershberger, S. L. 2011. Hodges-Lehmann Estimators.
In International Encyclopedia of Statistical Science (pp. 635-636). Berlin: Springer.

Hodges, J. L., and E. L. Lehmann. 1962. Rank methods for combination of
independent experiments in the analysis of variance.
Annals of Mathematical Statistics 33: 482–497.

Hodges, J. L., and E. L. Lehmann. 1963. Estimation of location based on ranks.
Annals of Mathematical Statistics 34: 598–611.

Hodges, J. L., and E. L. Lehmann. 1983. In S. Kotz, N. L. Johnson, L. Norman, and C.B. Read (Eds),
Encyclopedia of Statistical Sciences, Volume 3, pp. 642-645. New York: John Wiley and Sons, Inc.

Hollander, M., Wolfe, D.A., and Eric Chicken. 2014. Nonparametric Statistical Methods (3rd ed).
Hoboken, New Jersey: John Wiley and Sons.

Lehmann, E. L. 2006. Nonparametrics: statistical methods based on ranks (Rev. ed.)
New York: Springer.

Rosenbaum, P. R. 1993. Hodges-Lehmann point estimates of treatment effect in
observational studies. Journal of the American Statistical Association 88: 1250-1253.

Walsh, J. E. 1949. Some significance tests for the median which are
valid under very general conditions. Annals of Mathematical Statistics 20: 64–81.

Wilcoxon, F. 1945. Individual comparisons by ranking methods.
Biometrics 1: 80-83.

Citation of alignedpairs

alignedpairs is not an official Stata command. It is a free contribution
to the research community, like a paper. Please cite it as such:

Linden, Ariel. 2014.
alignedpairs: Stata module for implementing aligned ranks test for matched pairs (Hodges-Lehmann).

Author

Ariel Linden

President, Linden Consulting Group, LLC

Ann Arbor, MI, USA

alinden@lindenconsulting.org

http://www.lindenconsulting.org

Acknowledgments

I wish to thank Nicholas J. Cox for his support while developing alignedpairs

Also see

Online: signrank, ranksum, alignedranks (if installed),
alignedsets (if installed), somersd (if installed)