Inference on quantiles: confidence intervals, p-values, and testing

Improved quantile inference for one- and two-sample (e.g., treatment vs. control) cases
821 Downloads
Updated 23 Mar 2012

View License

Detailed documentation includes further explanation and examples; just type "help quantile_inf". The following briefly describes functionality as well as the theoretical foundations from the literature.

This code implements four different methods for quantile inference: Hutson (1999), bootstrap percentile-t, Kaplan (2011), and Kaplan and Goldman (2012). Papers with theoretical and simulation results for the third (and soon fourth) method can be found here: http://econ.ucsd.edu/~dkaplan/personalResearch.html

This Matlab code provides hypothesis testing (reject/don't), p-values, and confidence intervals, for one- and two-sample setups, and one- and two-sided inference.

When it is computable, the exact method based on fractional order statistics in Hutson (1999) always controls size and has significantly better power than other analytic or bootstrap methods in the one-sample case. Even for small samples, among simulations of 14 different types of distribution, empirical size for a nominal 5% test never exceeded 5.5%. The Kaplan and Goldman (2012) two-sample method is also based on fractional order statistics and has similarly good simulation results.

When a fractional order statistic method is not computable (further in the tails), the method of Kaplan (2011) or a bootstrap percentile-t is used. Extensive simulations (Section 6 of paper has some examples) have shown Kaplan (2011) to control size better than bootstrap ("BS") methods and the analytic Hall and Sheather (1988; "HS") method, while maintaining competitive power. This new method builds on the work of HS and Goh (2004) to improve testing properties via testing-optimal smoothing parameter selection using Edgeworth expansions and smoothing parameter dependent critical values. Simulations have not been done in the two-sample case when the sample are different in size, so bootstrap percentile-t is used there. In general, this particular bootstrap performs similarly to Kaplan (2011) in the two-sample case, though suffers size distortion in the one-sample case.

For example, if you have a univariate data sample and want to test if it is from a population with median (or whichever quantile/percentile) equal to zero, you can get a p-value, run this test at a 5% (or whatever value you input) level, and get a 95% (or whatever value you want) confidence interval for the median.

If you have two samples (say, treatment and control), you can test for equality at any quantile (percentile), either computing a p-value or testing at a specified level.

Again, detailed documentation includes further explanation and examples; just type "help quantile_inf"

Cite As

David Kaplan (2024). Inference on quantiles: confidence intervals, p-values, and testing (https://www.mathworks.com/matlabcentral/fileexchange/32410-inference-on-quantiles-confidence-intervals-p-values-and-testing), MATLAB Central File Exchange. Retrieved .

MATLAB Release Compatibility
Created with R2011a
Compatible with any release
Platform Compatibility
Windows macOS Linux
Categories
Find more on Statistics and Machine Learning Toolbox in Help Center and MATLAB Answers

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!
Version Published Release Notes
1.7.0.0

Minor correction: replaced "quantile_test" with "quantile_inf" in description and documentation.

1.6.0.0

Significant additions and changes, including much improved two-sample inference, one-sided inference, easier-to-read code/comments, and return value for name of method actually used.

1.5.0.0

Now using Hutson (1999) when applicable, and Kaplan (2011) otherwise.

1.3.0.0

Now uses method in Hutson (1999) when applicable, and Kaplan (2011) otherwise.

1.2.0.0

Further improved univariate size properties via simulated critical values, for when n*p<3 or n*p>=n-2

1.1.0.0

Improved size properties with more accurate (simulated) critical value when quantile is close to zero or one, i.e. n*p in [1,2] or [n-2,n-1]. Also corrected error message regarding valid values for the quantile parameter.

1.0.0.0