RPT {RATest} | R Documentation |
Robust Permutation Test
Description
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 , and the corresponding test statistic is given by
where and
are the sample means from population
and population
, respectively, and
is a consistent estimator of
when
are i.i.d. from
. Assume consistency also under
.
Difference of medians: Let and
be the CDFs corresponding to
and
, and denote
the median of
i.e.
. Assume that
is continuously differentiable at
with derivative
(and the same with
replaced by
). Here, the null hypothesis is of the form
, and the corresponding test statistic is given by
where is a consistent estimator of
:
Choices of 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 , and the corresponding test statistic is given by
where the sample analog of
based on an i.i.d. sample
from
. Similarly for
.
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 , or the more general hypothesis that
and
only differ in location against the alternative that the
's are more spread out than the
's. The null hypothesis is of the form
.
Two-sample Wilcoxon statistic, where the null hypothesis is of the form
.
Two-sample Wilcoxon statistic without continuity assumption. In this case, the null hypothesis is of the form
.
Hollander (1967) two-sample U statistics. The null hypothesis is of the form
.
Usage
RPT(
formula,
data,
test = "means",
n.perm = 499,
na.action,
wilcoxon.option = "continuity"
)
Arguments
formula |
a formula object, with the response on the left of a ~ operator, and the groups on the right. |
data |
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 |
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. |
n.perm |
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. |
na.action |
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. |
wilcoxon.option |
Continuity assumption for Wilcoxon test" with continuity ("continuity") or without ("discontinuity"). The default is "continuity" |
Value
An object of class "RPT" is a list containing at least the following components:
description |
Type of test, can be Difference of Means, Medians, or Variances. |
n_populations |
Number of grups. |
N |
Sample Size. |
T.obs |
Observed test statistic. |
pvalue |
P-value. |
T.perm |
Vector. Test statistics from the permutations. |
n_perm |
Number of permutations. |
parameters |
Estimated parameters. |
sample_sizes |
Groups lengths. |
Author(s)
Maurcio Olivares
Ignacio Sarmiento Barbieri
References
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.
Examples
## Not run:
male<-rnorm(50,1,1)
female<-rnorm(50,1,2)
dta<-data.frame(group=c(rep(1,50),rep(2,50)),outcome=c(male,female))
rpt.var<-RPT(dta$outcome~dta$group,test="variances")
summary(rpt.var)
## End(Not run)