Description Usage Arguments Value References Examples
Carry out a permutation independence test on a two-way contingency table. The test statistic is Tn, as described in Sections 3.1 and 7.1 of \insertCiteBKS2020USP. This also appears as Un in \insertCiteBS2021USP. The critical value is found by sampling null contingency tables, with the same row and column totals as the input, via Patefield's algorithm, and recomputing the test statistic.
1 |
freq |
Two-way contingency table whose independence is to be tested. |
B |
The number of resampled null tables to be used to calibrate the test. |
ties.method |
If "standard" then calculate the p-value as in (5) of \insertCiteBKS2020USP, which is slightly conservative. If "random" then break ties randomly. This preserves Type I error control. |
nullstats |
If TRUE, returns a vector of the null statistic values. |
Returns the p-value for this independence test and the value of the test statistic, T_n, as defined in \insertCiteBKS2020USP. The third element of the list is the table of expected counts, and the final element is the table of contributions to T_n. If nullstats=TRUE is used, then the function also returns a vector of the null statistics.
BKS2020USP
\insertRefBS2021USP
1 2 3 4 5 6 7 8 9 10 11 12 13 | freq=r2dtable(1,rep(10,5),rep(10,5))[[1]] + 4*diag(rep(1,5))
USP.test(freq,999)
freq=diag(1:5); USP.test(freq,999)
freq=r2dtable(1,rep(10,5),rep(10,5))[[1]];
test=USP.test(freq,999,nullstats=TRUE)
plot(density(test$NullStats,from=0,
to=max(max(test$NullStats),test$TestStat)),
xlim=c(min(test$NullStats),max(max(test$NullStats),test$TestStat)),
main="Test Statistics")
abline(v=test$TestStat,col=2); TestStats=c(test$TestStat,test$NullStats)
abline(v=quantile(TestStats,probs=0.95),lty=2)
|
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.