Resampling Statistics

The coin package provides the ability to perform a wide variety of re-randomization or permutation based statistical tests. These tests do not assume random sampling from well-defined populations. They can be a reasonable alternative to classical procedures when test assumptions can not be met. See coin: A Computational Framework for Conditional Inference for details.

In the examples below, lower case letters represent numerical variables and upper case letters represent categorical factors. Monte-Carlo simulation are available for all tests. Exact tests are available for 2 group procedures.

Independent Two- and K-Sample Location Tests

# Exact Wilcoxon Mann Whitney Rank Sum Test
# where y is numeric and A is a binary factor
wilcox_test(y~A, data=mydata, distribution="exact")
# One-Way Permutation Test based on 9999 Monte-Carlo
# resamplings. y is numeric and A is a categorical factor

oneway_test(y~A, data=mydata,

Symmetry of a response for repeated measurements

# Exact Wilcoxon Signed Rank Test
# where y1 and y2 are repeated measures
wilcoxsign_test(y1~y2, data=mydata, distribution="exact")
# Freidman Test based on 9999 Monte-Carlo resamplings.
# y is numeric, A is a grouping factor, and B is a
blocking factor.
friedman_test(y~A|B, data=mydata,

Independence of Two Numeric Variables

# Spearman Test of Independence based on 9999 Monte-Carlo
# resamplings. x and y are numeric variables.
spearman_test(y~x, data=mydata,

Independence in Contingency Tables

# Independence in 2-way Contingency Table based on
# 9999 Monte-Carlo resamplings. A and B are factors.
chisq_test(A~B, data=mydata,
# Cochran-Mantel-Haenzsel Test of 3-way Contingency Table
# based on 9999 Monte-Carlo resamplings. A, B, are
# and C is a stratefying factor.
mh_test(A~B|C, data=mydata,
# Linear by Linear Association Test based on 9999
Monte-Carlo resamplings.
A and B are ordered factors.
lbl_test(A~B, data=mydata,

Many other univariate and multivariate tests are possible using the functions in the coin package. See A Lego System for Conditional Inference for more details.

To Practice

Try the exercises in this course on data analysis and statistical inference in R.