permTest {CarletonStats} | R Documentation |
Permutation test
Description
Permutation test to test a hypothesis involving two samples.
Usage
permTest(x, ...)
## Default S3 method:
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 class 'formula'
permTest(formula, data = parent.frame(), subset, ...)
Arguments
x |
a numeric vector. If the function is the mean ( |
... |
further arguments to be passed to or from methods. |
group |
a factor variable with two levels. If |
statistic |
the statistic of interest. |
B |
the number of resamples (positive integer greater than 2). |
alternative |
the alternative hypothesis. Options are
|
plot.hist |
a logical value. If |
plot.qq |
a logical value. If |
xlab |
an optional character string for the x-axis label |
ylab |
an optional character string for the y-axis label |
title |
an optional character string giving the plot title |
seed |
optional argument to |
formula |
a formula of the form |
data |
a data frame with the variables in the formula. |
subset |
an optional expression specifying which observations to keep. |
Details
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.
Value
Returns invisibly a vector of the replicates of the test statistic.
Methods (by class)
-
permTest(default)
: Permutation test -
permTest(formula)
: Permutation test
Author(s)
Laura Chihara
References
Tim Hesteberg's website: https://www.timhesterberg.net/bootstrap-and-resampling
Examples
permTest(states03$ViolentCrime, states03$DeathPenalty)
#using formula syntax
permTest(ViolentCrime ~ DeathPenalty, data = states03, alt = "less")