plot {nptest} | R Documentation |
Plots Permutation Distribution for Nonparametric Tests
Description
plot
methods for object classes "np.cor.test", "np.loc.test", and "np.reg.test"
Usage
## S3 method for class 'np.cor.test'
plot(x, alpha = 0.05, col = "grey", col.rr = "red",
col.stat = "black", lty.stat = 2, lwd.stat = 2,
xlab = "Test Statistic", main = "Permutation Distribution",
breaks = "scott", border = NA, box = TRUE, ...)
## S3 method for class 'np.loc.test'
plot(x, alpha = 0.05, col = "grey", col.rr = "red",
col.stat = "black", lty.stat = 2, lwd.stat = 2,
xlab = "Test Statistic", main = "Permutation Distribution",
breaks = "scott", border = NA, box = TRUE, ...)
## S3 method for class 'np.reg.test'
plot(x, alpha = 0.05, col = "grey", col.rr = "red",
col.stat = "black", lty.stat = 2, lwd.stat = 2,
xlab = "Test Statistic", main = "Permutation Distribution",
breaks = "scott", border = NA, box = TRUE, SQRT = TRUE, ...)
Arguments
x |
an object of class "np.cor.test" output by the |
alpha |
significance level of the nonparametric test |
col |
color for plotting the non-rejection region |
col.rr |
color for plotting the rejection region |
col.stat |
color for plotting the observed test statistic |
lty.stat |
line type for plotting the observed test statistic |
lwd.stat |
line width for plotting the observed test statistic |
xlab |
x-axis label for the plot |
main |
title for the plot |
breaks |
defines the breaks of the histogram (see |
border |
color of the border around the bars |
box |
should a box be drawn around the plot? |
SQRT |
for regression tests, should the permutation distribution (and test statistic) be plotted on the square-root scale? |
... |
additional arguments to be passed to |
Details
Plots a histogram of the permutation distribution and the observed test statistic. The argument 'alpha' controls the rejection region of the nonparametric test, which is plotted using a separate color (default is red).
Author(s)
Nathaniel E. Helwig <helwig@umn.edu>
References
Helwig, N. E. (2019). Statistical nonparametric mapping: Multivariate permutation tests for location, correlation, and regression problems in neuroimaging. WIREs Computational Statistics, 11(2), e1457. doi: 10.1002/wics.1457
See Also
np.cor.test
for information on nonparametric correlation tests
np.loc.test
for information on nonparametric location tests
np.reg.test
for information on nonparametric regression tests
Examples
######******###### np.cor.test ######******######
# generate data
rho <- 0.5
val <- c(sqrt(1 + rho), sqrt(1 - rho))
corsqrt <- matrix(c(val[1], -val[2], val), 2, 2) / sqrt(2)
set.seed(1)
n <- 50
z <- cbind(rnorm(n), rnorm(n)) %*% corsqrt
x <- z[,1]
y <- z[,2]
# test H0: rho = 0
set.seed(0)
test <- np.cor.test(x, y)
# plot results
plot(test)
######******###### np.loc.test ######******######
# generate data
set.seed(1)
n <- 50
x <- rnorm(n, mean = 0.5)
# one sample t-test
set.seed(0)
test <- np.loc.test(x)
# plot results
plot(test)
######******###### np.reg.test ######******######
# generate data
set.seed(1)
n <- 50
x <- cbind(rnorm(n), rnorm(n))
beta <- c(0.25, 0.5)
y <- x %*% beta + rnorm(n)
# Wald test (method = "perm")
set.seed(0)
test <- np.reg.test(x, y)
# plot results
plot(test)