permTestCor {CarletonStats} | R Documentation |
Permutation test for the correlation of two variables.
Description
Hypothesis test for a correlation of two variables. The null hypothesis is that the population correlation is 0.
Usage
permTestCor(x, ...)
## Default S3 method:
permTestCor(
x,
y,
B = 999,
alternative = "two.sided",
plot.hist = TRUE,
plot.qq = FALSE,
x.name = deparse(substitute(x)),
y.name = deparse(substitute(y)),
xlab = NULL,
ylab = NULL,
title = NULL,
seed = NULL,
...
)
## S3 method for class 'formula'
permTestCor(formula, data, subset, ...)
Arguments
x |
a numeric vector. |
... |
further arguments to be passed to or from methods. |
y |
a numeric vector. |
B |
the number of resamples to draw (positive integer greater than 2). |
alternative |
alternative hypothesis. Options are |
plot.hist |
a logical value. If |
plot.qq |
a logical value. If |
x.name |
Label for variable x |
y.name |
Label for variable y |
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 |
data |
a data frame that contains the variables given in the formula. |
subset |
an optional expression indicating what observations to use. |
Details
Perform a permutation test to test latex
, where
latex
is the population correlation. The rows of the second
variable are permuted and the correlation is re-computed.
The mean and standard error of the permutation distribution is printed as well as a P-value.
Observations with missing values are removed.
Value
Returns invisibly a vector of the correlations obtained by the randomization.
Methods (by class)
-
permTestCor(default)
: Permutation test for the correlation of two variables. -
permTestCor(formula)
: Permutation test for the correlation of two variables.
Author(s)
Laura Chihara
References
Tim Hesterberg's website: https://www.timhesterberg.net/bootstrap-and-resampling
Examples
plot(states03$HSGrad, states03$TeenBirths)
cor(states03$HSGrad, states03$TeenBirths)
permTestCor(states03$HSGrad, states03$TeenBirths)
permTestCor(TeenBirths ~ HSGrad, data = states03)