fisher_pv: Compute the p-value of a Fisher randomization test.

View source: R/fisher_pv.R

fisher_pvR Documentation

Compute the p-value of a Fisher randomization test.

Description

Compute the p-value of a Fisher randomization test.

Usage

fisher_pv(value, group, Tfun, nsim = 1000, strict = TRUE)

Arguments

value

Vector of length nobs corresponding to the values from which the test statistics is computed. That is, value[i] is the value corresponding to observation i.

group

Vector of length nobs indicating to which group each observation belongs. Group membership is determined from the elements of unique(group).

Tfun

Function taking vector arguments value and group, returning ntest test statistics.

nsim

Number of randomizations to perform.

strict

Whether the p-value is "strictly greater" or just "greater than or equal" (see 'Details').

Details

Suppose there is only one test statistic ntest = 1. Then the Fisher randomization test calculates

Pr(Tsim > Tobs),

where Tobs = Tfun(value, group) is the observed value of the test statistic, and Tsim = Tfun(value[irand], group), where irand is a random permutation of the nobs observations. When ntest > 1, fisher_pv() performs the calculation above for each test statistic.

When strict = FALSE the p-value is Pr(Tsim >= Tobs).

Value

A two column matrix with ntest rows and columns:

Tobs

A vector of length ntest, where Tobs[t] is the observed value of test statistic t.

pval

A vector of ntest p-values of the form Pr(Tsim[t] > Tobs[t]), where Tobs[t] = Tfun(value, group)[t] and Tsim[t] is computed by randomly reallocating value to the given vector group.


mlysy/aq2020 documentation built on April 14, 2022, 12:43 a.m.