Compute the p-value of a Fisher randomization test.
fisher_pv(value, group, Tfun, nsim = 1000)
value | Vector of length |
---|---|
group | Vector of length |
Tfun | Function taking vector arguments |
nsim | Number of randomizations to perform. |
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
.
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.