Permutation test to test a hypothesis involving two samples.
permTest(x, ...)# S3 method for default
permTest(
x,
group,
statistic = mean,
B = 9999,
alternative = "two.sided",
plot.hist = TRUE,
plot.qq = FALSE,
xlab = NULL,
ylab = NULL,
title = NULL,
seed = NULL,
...
)
# S3 method for formula
permTest(formula, data = parent.frame(), subset, ...)
Returns invisibly a vector of the replicates of the test statistic.
a numeric vector. If the function is the mean (fun = mean
)
and x
is a binary numeric vector of 0's and 1's, then the test is
between proportions.
further arguments to be passed to or from methods.
a factor variable with two levels. If group
is a binary
numeric vector, it will be coerced into a factor variable.
the statistic of interest.
the number of resamples (positive integer greater than 2).
the alternative hypothesis. Options are
"two.sided"
, "less"
or "greater"
.
a logical value. If TRUE
, the permutation
distribution of the statistic is plotted.
a logical value. If TRUE
, then a normal
quantile-quantile plot of the resampled test statistic is created.
an optional character string for the x-axis label
an optional character string for the y-axis label
an optional character string giving the plot title
optional argument to set.seed
a formula of the form y ~ group
where y
is
numeric and group
is a factor variable.
a data frame with the variables in the formula.
an optional expression specifying which observations to keep.
permTest(default)
: Permutation test
permTest(formula)
: Permutation test
Laura Chihara
Permutation test to see if a population parameter is the same for two populations. For instance, test \(latex\) where \(latex\) denotes the population mean. The values of the numeric variable are randomly assigned to the two groups and the difference of the statistic for each group is calculated. The command will print the mean and standard error of the distribution of the test statistic as well as a P-value.
Observations with missing values are removed.
Tim Hesteberg's website: https://www.timhesterberg.net/bootstrap-and-resampling
permTest(states03$ViolentCrime, states03$DeathPenalty)
#using formula syntax
permTest(ViolentCrime ~ DeathPenalty, data = states03, alt = "less")
Run the code above in your browser using DataLab