coin (version 1.3-1)

CorrelationTests: Correlation Tests

Description

Testing the independence of two numeric variables.

Usage

# S3 method for formula
spearman_test(formula, data, subset = NULL, weights = NULL, …)
# S3 method for IndependenceProblem
spearman_test(object, distribution = c("asymptotic", "approximate", "none"), …)

# S3 method for formula fisyat_test(formula, data, subset = NULL, weights = NULL, …) # S3 method for IndependenceProblem fisyat_test(object, distribution = c("asymptotic", "approximate", "none"), ties.method = c("mid-ranks", "average-scores"), …)

# S3 method for formula quadrant_test(formula, data, subset = NULL, weights = NULL, …) # S3 method for IndependenceProblem quadrant_test(object, distribution = c("asymptotic", "approximate", "none"), mid.score = c("0", "0.5", "1"), …)

# S3 method for formula koziol_test(formula, data, subset = NULL, weights = NULL, …) # S3 method for IndependenceProblem koziol_test(object, distribution = c("asymptotic", "approximate", "none"), ties.method = c("mid-ranks", "average-scores"), …)

Arguments

formula

a formula of the form y ~ x | block where y and x are numeric variables and block is an optional factor for stratification.

data

an optional data frame containing the variables in the model formula.

subset

an optional vector specifying a subset of observations to be used. Defaults to NULL.

weights

an optional formula of the form ~ w defining integer valued case weights for each observation. Defaults to NULL, implying equal weight for all observations.

object

an object inheriting from class "'>IndependenceProblem".

distribution

a character, the conditional null distribution of the test statistic can be approximated by its asymptotic distribution ("asymptotic", default) or via Monte Carlo resampling ("approximate"). Alternatively, the functions asymptotic or approximate can be used. Computation of the null distribution can be suppressed by specifying "none".

ties.method

a character, the method used to handle ties: the score generating function either uses mid-ranks ("mid-ranks", default) or averages the scores of randomly broken ties ("average-scores").

mid.score

a character, the score assigned to observations exactly equal to the median: either 0 ("0", default), 0.5 ("0.5") or 1 ("1"); see median_test.

further arguments to be passed to independence_test.

Value

An object inheriting from class "'>IndependenceTest".

Details

spearman_test, fisyat_test, quadrant_test and koziol_test provide the Spearman correlation test, the Fisher-Yates correlation test using van der Waerden scores, the quadrant test and the Koziol-Nemec test. A general description of these methods is given by H<U+00E1>jek, <U+0160>id<U+00E1>k and Sen (1999, Sec. 4.6). The Koziol-Nemec test was suggested by Koziol and Nemec (1979). For the adjustment of scores for tied values see H<U+00E1>jek, <U+0160>id<U+00E1>k and Sen (1999, pp. 133--135).

The null hypothesis of independence, or conditional independence given block, between y and x is tested.

The conditional null distribution of the test statistic is used to obtain \(p\)-values and an asymptotic approximation of the exact distribution is used by default (distribution = "asymptotic"). Alternatively, the distribution can be approximated via Monte Carlo resampling by setting distribution to "approximate". See asymptotic and approximate for details.

References

H<U+00E1>jek, J., <U+0160>id<U+00E1>k, Z. and Sen, P. K. (1999). Theory of Rank Tests, Second Edition. San Diego: Academic Press.

Koziol, J. A. and Nemec, A. F. (1979). On a Cram<U+00E9>r-von Mises type statistic for testing bivariate independence. The Canadian Journal of Statistics 7(1), 43--52. 10.2307/3315014

Examples

Run this code
# NOT RUN {
## Asymptotic Spearman test
spearman_test(CONT ~ INTG, data = USJudgeRatings)

## Asymptotic Fisher-Yates test
fisyat_test(CONT ~ INTG, data = USJudgeRatings)

## Asymptotic quadrant test
quadrant_test(CONT ~ INTG, data = USJudgeRatings)

## Asymptotic Koziol-Nemec test
koziol_test(CONT ~ INTG, data = USJudgeRatings)
# }

Run the code above in your browser using DataCamp Workspace