RPT: Robust Permutation Test

Description Usage Arguments Value Author(s) References Examples

View source: R/RPT.R


This function considers the k-sample problem of comparing general parameters, such as means, medians, or parameters that depend on the joint distribution using permutation tests. Under weak assumptions for comparing estimator, the permutation tests implemented here provide a general test procedure whereby the asymptotic validity of the permutation test holds while retaining the exact rejection probability α in finite samples when the underlying distributions are identical. Here we will consider three test for the 2 sample case, but the function works for k-samples.

Difference of means: Here, the null hypothesis is of the form H_0: μ(P)-μ(Q)=0, and the corresponding test statistic is given by

T_{m,n}=\frac{N^{1/2}(\bar{X}_m-\bar{Y}_n)}{√{\frac{N}{m}σ^2_m(X_1,…,X_m)+ \frac{N}{n}σ^2_n(Y_1,…,Y_n)}}

where \bar{X}_m and \bar{Y}_n are the sample means from population P and population Q, respectively, and σ^2_m(X_1,…,X_m) is a consistent estimator of σ^2(P)$ when $X_1,…,X_m are i.i.d. from P. Assume consitency also under Q.

Difference of medians: Let F and G be the CDFs corresponding to P and Q, and denote θ(F) the median of F i.e. θ(F)=\inf\{x:F(x)≥1/2\}. Assume that F is continuously differentiable at θ(P) with derivative F' (and the same with F replaced by G). Here, the null hypothesis is of the form H_0: θ(P)-θ(Q)=0, and the corresponding test statistic is given by


where \hat{υ}_{m,n} is a consistent estimator of υ(P,Q):


Choices of \hat{υ}_{m,n} may include the kernel estimator of Devroye and Wagner (1980), the bootstrap estimator of Efron (1992), or the smoothed bootstrap Hall et al. (1989) to list a few. For further details, see Chung and Romano (2013). Current implementation uses the bootstrap estimator of Efron (1992)

Difference of variances: Here, the null hypothesis is of the form H_0: σ^2(P)-σ^2(Q)=0, and the corresponding test statistic is given by


where \hat{μ}_{4,m} the sample analog of E(X-μ)^4 based on an iid sample X_1,…,X_m from P. Similarly for \hat{μ}_{4,n}.

We could also have the case when the parameter of interest is a function of the joint distribution. The examples considered here are

Lehmann (1951) two-sample U statistics: Consider testing H_0: P=Q, or the more general hypothesis that P and Q only differ in location against the alternative that the Y's are more spread out than the X's. The null hypothesis is of the form

H_0: P(\vert Y-Y'\vert>\vert X-X'\vert)=1/2


Two-sample Wilcoxon statistic, where the null hypothesis is of the form

H_0: P(X≤ Y)=1/2


Two-sample Wilcoxon statistic without continuity assumption. In this case, the null hypothesis is of the form

H_0: P(X≤ Y)=P(Y≤ X)


Hollander (1967) two-sample U statistics. The null hypothesis is of the form

H_0: P(X+X'<Y+Y')=1/2



RPT(formula, data, test = "means", n.perm = 499, na.action,
  wilcoxon.option = "continuity")



a formula object, with the response on the left of a ~ operator, and the groups on the right.


a data.frame in which to interpret the variables named in the formula. If this is missing, then the variables in the formula should be on the search list.


test to be perfomed. Multiple options are available, depending on the nature of the testing problem. In general, we have two types of problem. First, when the researcher is interested in comparing parameters. In this case, "means" will perform a Difference of Means, "medians" a Difference of Medians, "variances" a Difference of Variances. This case allows for 2 or more population comparisons. For the test of difference of medians the Efron (1992) bootstrap estimator is used to estimate the variances (for further details, see Chung and Romano (2013)). Second, when the parameter of interest is a function of the joint distribution. In this case, "lehmann.2S.test" will perform Lehmann (1951) two-sample U statistics, "wilcoxon.2s.test" the two-sample Wilcoxon test (with or without continuity assumption), and "hollander.2S.test" Hollander (1967) two sample U statistics. In this case, only 2 sample comparisons are permitted.


Numeric. Number of permutations needed for the stochastic approximation of the p-values. See remark 3.2 in Canay and Kamat (2017). The default is n.perm=499.


a function to filter missing data. This is applied to the model.frame . The default is na.omit, which deletes observations that contain one or more missing values.


Continuity assumption for Wilcoxon test" with continuity ("continuity") or without ("discontinuity"). The default is "continuity"


An object of class "RPT" is a list containing at least the following components:


Type of test, can be Difference of Means, Medians, or Variances.


Number of grups.


Sample Size.


Observed test statistic.




Vector. Test statistics from the permutations.


Number of permutations.


Estimated parameters.


Groups lengths.


Maurcio Olivares Gonzalez

Ignacio Sarmiento Barbieri


Chung, E. and Romano, J. P. (2013). Exact and asymptotically robust permutation tests. The Annals of Statistics, 41(2):484–507. Chung, E. and Romano, J. P. (2016). Asymptotically valid and exact permutation tests based on two-sample u-statistics. Journal of Statistical Planning and Inference, 168:97–105. Devroye, L. P. and Wagner, T. J. (1980). The strong uniform consistency of kernel density estimates. In Multivariate Analysis V: Proceedings of the fifth International Symposium on Multivariate Analysis, volume 5, pages 59–77. Efron, B. (1992). Bootstrap methods: another look at the jackknife. In Breakthroughs in statistics, pages 569–593. Springer. Hall, P., DiCiccio, T. J., and Romano, J. P. (1989). On smoothing and the bootstrap. The Annals of Statistics, pages 692–704. Hollander, M. (1967). Asymptotic efficiency of two nonparametric competitors of wilcoxon’s two sample test. Journal of the American Statistical Association, 62(319):939–949. Lehmann, E. L. (1951). Consistency and unbiasedness of certain nonparametric tests. The Annals of Mathematical Statistics, pages 165–179.


## Not run: 

## End(Not run)

ignaciomsarmiento/RATest documentation built on Dec. 9, 2018, 8:05 a.m.