*! version 1.0.0 24aug2014
help alignedsets

Title

alignedsets-- Aligned ranks test for matched sets (Hodges-Lehmann)

Syntax

alignedsets depvar [if] [in] , by(groupvar)
set(varlist)

options

* by(varlist:groupvar) grouping variable. It must contain integer values of 0 and 1 representing the treatment levels

* set(varlist:varlist) stratify by varlist

* by(groupvar) and set(varlist) are required.

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

Description

alignedsets is the Hodges & Lehmann (1962) extension to the Wilcoxon signed-ranks test [R] signrank for matching
with multiple controls. The approach involves ranking observations after they have undergone alignment within their respective sets,
thereby removing set-specific effects from the data. More specifically, each matched set is first centered by subtracting the set's mean from
each outcome, next the aligned outcomes are ranked over all sets, and finally the sum of ranks is calculated for the treated participants.

alignedsets produces the Hodges & Lehmann aligned rank statistic which is used to test the null hypothesis of no difference
between an outcome for the treated unit(s) in the set compared to the outcomes of matched controls.

For Hodges & Lehmann aligned ranks test on unmatched data, see alignedranks (available for download at SSC).

Options

Main

by(groupvar) is required. It specifies the
name of the grouping variable, and must contain integer values of 0 and 1 representing the treatment levels

set(varlist) specifies the variable on which to stratify the analysis (ie., the set identifier that matched subjects
belong to). Observations will be ignored for missing values of set.

Examples

Load example data

. use simdata, clear

Perform aligned ranks test on the baseline variable x1 to demonstrate covariate balance

. alignedsets x1, by(treat) set(set)

Perform aligned ranks test on the outcome variable y

. alignedsets y, by(treat) set(set)

We now limit the analysis to the first 100 sets

. alignedsets y if inrange(set, 1, 100), by(treat) set(set)

Saved results

alignedsets saves the following in r():

Scalars

r(actual) actual sum of ranks for treated group (group coded as 1)

r(expect) expected sum of ranks for treated group

r(diff) difference (aligned rank statistic)

r(var) variance

r(se) standard error

r(z) z statistic

r(p) two-sided probability

References

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.

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

Citation of alignedsets

alignedsets 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.
alignedsets: Stata module for implementing aligned ranks test for matched sets (Hodges-Lehmann).

Author

Ariel Linden

President, Linden Consulting Group, LLC

Ann Arbor, MI, USA

alinden@lindenconsulting.org

http://www.lindenconsulting.org

Also see

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