Title: | A Collection of Nonparametric Hypothesis Tests |
---|---|
Description: | Contains the following 5 nonparametric hypothesis tests: The Sign Test, The 2 Sample Median Test, Miller's Jackknife Procedure, Cochran's Q Test, & The Stuart-Maxwell Test. |
Authors: | D. Lukke Sweet |
Maintainer: | D. Lukke Sweet <[email protected]> |
License: | GPL-3 |
Version: | 1.0.2 |
Built: | 2024-12-13 06:51:04 UTC |
Source: | CRAN |
This function will perform the Cochran's Q Test to test for identical treatment effects in a two-way randomized block design with k treatments.
cochrans.q(x, alpha=NULL)
cochrans.q(x, alpha=NULL)
x |
A b x k matrix, where b is the number of blocking factors and k is the number of treatment factors. |
alpha |
The Significance level, defaults to 0.05. |
Q |
This is the Cochran's Q Test Statistic. |
Degrees of Freedom |
The number of degrees of freedom used in calculating the p-value. |
Significance Level |
Returns the alpha value. |
P-value |
Returns the p-value from the Cochran's Q Test. |
D. Lukke Sweet
https://www.r-bloggers.com/cochran-q-test-for-k-related-samples-in-r/
http://rcompanion.org/handbook/H_07.html
## Run Cochran's Q Test on a matrix. cochrans.q(matrix(c(1,1,1,1,1,1, 1,1,0,1,1,1, 0,0,0,1,0,0, 0,1,0,0,1,1), 6, 4)) ## Cochran's Q Test works for any size matrix. cochrans.q(matrix(c(0,1,0,0,1,0,0,0,1,0,0,0,0,0, 0,1,1,1,1,1,1,1,0,1,1,1,1,1, 0,1,0,0,0,0,0,0,1,0,0,0,0,0, 0,1,1,0,0,1,1,0,0,0,0,1,0,1), 14, 4), alpha=0.01)
## Run Cochran's Q Test on a matrix. cochrans.q(matrix(c(1,1,1,1,1,1, 1,1,0,1,1,1, 0,0,0,1,0,0, 0,1,0,0,1,1), 6, 4)) ## Cochran's Q Test works for any size matrix. cochrans.q(matrix(c(0,1,0,0,1,0,0,0,1,0,0,0,0,0, 0,1,1,1,1,1,1,1,0,1,1,1,1,1, 0,1,0,0,0,0,0,0,1,0,0,0,0,0, 0,1,1,0,0,1,1,0,0,0,0,1,0,1), 14, 4), alpha=0.01)
The 2 sample median test is for testing the medians of 2 samples to see if they are equal.
mediantest(x, y, alpha=NULL, exact=FALSE)
mediantest(x, y, alpha=NULL, exact=FALSE)
x |
A vector containing data from the first sample. |
y |
A vector containing data from the second sample. |
alpha |
The Significance level, defaults to 0.05. |
exact |
Defaults to FALSE. Runs the exact test or a large sample approximation. |
Z |
The test statistic for the large sample approximation. |
P-value |
Returns the p-value from the Median Test. |
D. Lukke Sweet
Higgins, J. J. (2005). An Introduction to modern nonparametric statistics. Belmont: Thomson Brooks/Cole.
Wiley Series in Probability and Statistics: Nonparametric Statistical Methods (3rd Edition). (2013). John Wiley & Sons.
## Run the Median Test on the 2 vectors. mediantest(x = c(5.5, 5.8, 6.8, 6.9, 7.2, 7.3, 7.5, 7.6, 8.0), y = c(5.3, 5.4, 5.6, 5.7, 6.2, 6.4, 6.6, 6.7, 8.2), exact=TRUE)
## Run the Median Test on the 2 vectors. mediantest(x = c(5.5, 5.8, 6.8, 6.9, 7.2, 7.3, 7.5, 7.6, 8.0), y = c(5.3, 5.4, 5.6, 5.7, 6.2, 6.4, 6.6, 6.7, 8.2), exact=TRUE)
This function will perform Miller's Jackknife Procedure to test differences in scale between 2 samples. It is best for large samples.
miller.jack(x, y, alpha = NULL, alternative =c("two.sided", "greater", "less"), exact = FALSE)
miller.jack(x, y, alpha = NULL, alternative =c("two.sided", "greater", "less"), exact = FALSE)
x |
A vector containing data from the first sample. |
y |
A vector containing data from the second sample. |
alpha |
The Significance level, defaults to 0.05. |
alternative |
Defaults to two.sided. Used to determine what type of test to run. |
exact |
Defaults to FALSE. Used to determine whether to run the exact procedure or a large sample approximation. |
J |
The test statistic. |
Significance Level |
Returns the alpha value. |
P-value |
Returns the p-value from Miller's Jackknife Procedure. |
D. Lukke Sweet
Wiley Series in Probability and Statistics: Nonparametric Statistical Methods (3rd Edition). (2013). John Wiley & Sons.
## Run Miller's Jackknife Procedure on the 2 vectors. miller.jack(x= c(6.2, 5.9, 8.9, 6.5, 8.6), y = c(9.5, 9.8, 9.5, 9.6, 10.3), alpha=0.05, alternative="less")
## Run Miller's Jackknife Procedure on the 2 vectors. miller.jack(x= c(6.2, 5.9, 8.9, 6.5, 8.6), y = c(9.5, 9.8, 9.5, 9.6, 10.3), alpha=0.05, alternative="less")
A nonpametric test for center. The sign test compares the median to a value.
signtest(x, m = NULL, alpha = NULL, alternative =c("two.sided", "greater", "less"), conf.level=NULL, exact = FALSE)
signtest(x, m = NULL, alpha = NULL, alternative =c("two.sided", "greater", "less"), conf.level=NULL, exact = FALSE)
x |
A vector of sample data. |
m |
The median to test. Defaults to 0. |
alpha |
The Significance level, defaults to 0.05. |
alternative |
Defaults to two.sided. Used to determine what type of test to run. |
conf.level |
Defaults to NULL. Used to construct a confidence interval. Input as a decimal. |
exact |
Defaults to FALSE. Used to determine whether to run the exact procedure or a large sample approximation. |
B |
The Test Statistic |
Significance Level |
Returns the alpha value. |
P-value |
Returns the p-value from the Sign Test. |
Confidence Interval |
The confidence interval requested. |
D. Lukke Sweet
Higgins, J. J. (2005). An Introduction to modern nonparametric statistics. Belmont: Thomson Brooks/Cole.
Wiley Series in Probability and Statistics: Nonparametric Statistical Methods (3rd Edition). (2013). John Wiley & Sons.
## Run the Sign Test on the vector. signtest(c(1.8, 3.3, 5.65, 2.25, 2.5, 3.5, 2.75, 3.25, 3.10, 2.70, 3, 4.75, 3.4), m=3.5)
## Run the Sign Test on the vector. signtest(c(1.8, 3.3, 5.65, 2.25, 2.5, 3.5, 2.75, 3.25, 3.10, 2.70, 3, 4.75, 3.4), m=3.5)
This function runs the Stuart-Maxwell Test, an extension of McNemar's for a 3x3 matrix.
stuart.maxwell(X, alpha = NULL)
stuart.maxwell(X, alpha = NULL)
X |
A 3x3 matrix of frequencies. |
alpha |
The Significance level, defaults to 0.05. |
Test Statistic |
The Test Statistic for the Stuart-Maxwell Test. |
Significance Level |
Returns the alpha value. |
P-value |
Returns the p-value from the Stuart-Maxwell Test. |
D. Lukke Sweet
## Run the Stuart-Maxwell Test on the 3x3 Matrix. stuart.maxwell(matrix(c(12, 30, 13, 7, 70, 34, 3, 20, 32), 3,3))
## Run the Stuart-Maxwell Test on the 3x3 Matrix. stuart.maxwell(matrix(c(12, 30, 13, 7, 70, 34, 3, 20, 32), 3,3))