count: Fisher (or paired sample) randomization test with complete...

View source: R/count.R

countR Documentation

Fisher (or paired sample) randomization test with complete enumerations

Description

Carries out the Fisher randomization test or the paired comparison randomization test. It is a convenience function invoked by the fuller function RT1SAMP.

Usage

count(x, mu = 0)

Arguments

x

a (non-empty) numeric vector of data values.

mu

an scalar used in Fisher's one-sample randomization test, where only a single sample is concerned rather than paired comparisons, and the question of interest is whether this sample could have come from a population with a mean equal to a particular value μ.

Details

The function calculates the sum of elements in x as the test statistic; then the full set of 2^n elements (n = length(x)) in the randomization distribution of the test statistic are generated by consecutively changing the sign of each element in x. In this way all possible signs of all elements in x occur by the time the 2^n-th calculation is made. The assumption made is that the significance level of the observed statistic Sobs is the proportion of randomized values greater than or equal to Sobs. For a lower tail test, the proportion is incremented if the randomized values of the test statistic are less than or equal Sobs. For a two-tailed test, the proportion is incremented if the absolute value of the values attained by the randomized test statistic are greater than or equal the absolute value of the observed test statistic.

Value

The function returns a RT result object (list).

Sobs

Observed sum of elements in x (the observed value of the test statistic)

name

A character string giving the name of the test.

P

A numeric vector, giving the p-value for the lower-, upper-, and two-tailed tests, respectively

nperm

An scalar, namely 2^n, the number of elements in the full randomization distribution

Author(s)

Jorge Navarro-Alberto

References

Manly, B.F.J. and Navarro-Alberto, J.A. (2021) Randomization, Bootstrap and Monte Carlo Methods in Biology. 4th Edition. CRC Press.

See Also

RT1SAMP, the main function for Fisher's (or paired sample) randomization test.

Examples


# Example in Manly and Navarro Alberto (2021), Section 5.1
Dif <- cornheight[,"Cross"] - cornheight[,"Self"]
Results.count <- count(Dif)
Results.count


ganava4/rbmc documentation built on April 24, 2022, 12:14 a.m.