Package 'nonpar'

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

Help Index


Cochran's Q Test

Description

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.

Usage

cochrans.q(x, alpha=NULL)

Arguments

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.

Value

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.

Author(s)

D. Lukke Sweet

References

https://www.r-bloggers.com/cochran-q-test-for-k-related-samples-in-r/

http://rcompanion.org/handbook/H_07.html

Examples

## 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)

2 Sample Median Test

Description

The 2 sample median test is for testing the medians of 2 samples to see if they are equal.

Usage

mediantest(x, y, alpha=NULL, exact=FALSE)

Arguments

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.

Value

Z

The test statistic for the large sample approximation.

P-value

Returns the p-value from the Median Test.

Author(s)

D. Lukke Sweet

References

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.

Examples

## 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)

The Miller Jackknife Procedure

Description

This function will perform Miller's Jackknife Procedure to test differences in scale between 2 samples. It is best for large samples.

Usage

miller.jack(x, y, alpha = NULL,
alternative =c("two.sided", "greater", "less"), exact = FALSE)

Arguments

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.

Value

J

The test statistic.

Significance Level

Returns the alpha value.

P-value

Returns the p-value from Miller's Jackknife Procedure.

Author(s)

D. Lukke Sweet

References

Wiley Series in Probability and Statistics: Nonparametric Statistical Methods (3rd Edition). (2013). John Wiley & Sons.

Examples

## 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")

The Sign Test

Description

A nonpametric test for center. The sign test compares the median to a value.

Usage

signtest(x, m = NULL, alpha = NULL,
alternative =c("two.sided", "greater", "less"), conf.level=NULL, exact = FALSE)

Arguments

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.

Value

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.

Author(s)

D. Lukke Sweet

References

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.

Examples

## 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)

The Stuart-Maxwell Test

Description

This function runs the Stuart-Maxwell Test, an extension of McNemar's for a 3x3 matrix.

Usage

stuart.maxwell(X, alpha = NULL)

Arguments

X

A 3x3 matrix of frequencies.

alpha

The Significance level, defaults to 0.05.

Value

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.

Author(s)

D. Lukke Sweet

Examples

## Run the Stuart-Maxwell Test on the 3x3 Matrix.
  stuart.maxwell(matrix(c(12, 30, 13, 7, 70, 34, 3, 20, 32), 3,3))