*! version 1.0 13 Jan 2021

Title

csranks -- construct uniformly asymptotically valid confidence sets on ranks

Syntax

csranks,
id(varname) mean(varname) se(varname) [options]

Required
id(varname) unique identifier of observations to be ranked

mean(varname) sample means

se(varname) sample standard error of means

Optional
simultaneous returns simultaneous confidence set over all observations (otherwise, returns marginal confidence intervals)

boot(#) number of bootstrap replications (default = 1000), required if simultaneous

Description

csranks implements the methods in "Inference on Ranks with Applications to Mobility Across Neighborhoods and Academic Achievement Across Countries" by Magne Mogstad, Joseph P. Romano, Azeem M. Shaikh, and Daniel Wilhelm (2020). They introduce methods to construct uniformly asymptotically valid two-sided confidence intervals on the ranks of observations in a distribution. These methods require only the means and standard error of means of observations of the observations to be ranked, under an independence assumption across observations. This program implements their methods for marginal confidence intervals that are valid for individual observations as well as for the simultaneous confidence set over all observations.

csranks adds three new variables to the data, which are named after the id variable: the minimum rank in the confidence region (id_rk_min), the maximum rank in the confidence region (id_rk_max), and the rank of the original estimate (id_rk_mean). Observations are ranked in decreasing order of the variable.

Stored Results

csranks stores the following in e():

Scalars

e(N) Number of observations identified by id

e(critval) Stores critical value of test statistic.: 1.96 in the case of marginal confidence intervals, obtained by parametric bootstrap in the case of a simultaneous confidence set.

Examples

1. You have a data set of the average standardized test scores (contained in est) of 100 schools (uniquely identified by sid), along with standard errors for each estimate (contained in stderr). This code would construct the simultaneous confidence set on the ranking of all schools.

. set obs 100

. gen sid = _n

. gen estimate = _n + rnormal()

. gen stderr = exp(1 + 0.5*rnormal())

. csranks, id(sid) mean(estimate) se(stderr) simultaneous b(1000)

2. You have a data set of the average standardized test scores (contained in est) of 100 schools (uniquely identified by sid), along with standard errors for each estimate (contained in stderr). This code would construct marginal confidence intervals on the rank of each school. For example, these confidence intervals would be appropriate if you wanted to test the null hypothesis that the school identified by sid == 10 had a rank equal to 1.

. set obs 100

. gen sid = _n

. gen estimate = _n + rnormal()

. gen stderr = exp(1 + 0.5*rnormal())

. csranks, id(sid) mean(estimate) se(stderr)

. di sid_rk_max if id == 10

. di sid_rk_min if id == 10

Prerequisite

To run, csranks requires that you pre-install the Stata command gtools, available from the SSC.

Citation of csranks

csranks is not an official Stata command. It is a free contribution to the research community. Please cite it as such using the following format:

Soltas, E. 2021. "csranks: uniformly asymptotically valid confidence sets on ranks. http://ideas.repec.org/c/boc/bocode/s458898.html

Author

Evan Soltas

MIT Economics

Email: esoltas@mit.edu

References

Magne Mogstad, Joseph P. Romano, Azeem M. Shaikh, and Daniel Wilhelm. "Inference on Ranks with Applications to Mobility Across Neighborhoods and Academic Achievement Across Countries."
Becker Friedman Institute Working Paper 2020-16, University of Chicago.
[link]

R package for csranks.
https://danielwilhelm.github.io/R-CS-ranks/