contingency2xt.comb: Combined Kruskal-Wallis Tests for the 2 x t Contingency...

contingency2xt.combR Documentation

Combined Kruskal-Wallis Tests for the 2 x t Contingency Tables

Description

This function uses the Kruskal-Wallis criterion to test the hypothesis of no association between the counts for two responses "A" and "B" across t categories and across M blocks.

Usage

contingency2xt.comb(..., 
	method = c("asymptotic", "simulated", "exact"), 
	dist = FALSE, Nsim = 10000)

Arguments

...

Either several lists L_1,\ldots,L_M, each of two equal length vectors A_i and B_i, i=1,\ldots,M, of counts \ge 0, where the common length t_i of A_i and B_i may vary from list to list

or a list of M such lists

method

= c("asymptotic","simulated","exact"), where

"asymptotic" uses only an asymptotic chi-square approximation with (t_1-1)+\ldots+(t_M-1) degrees of freedom to approximate the P-value, This calculation is always done.

"simulated" uses Nsim simulated counts for the two vectors A_i and B_i in list L_i, with the observed marginal totals, m_i=\sum A_i, n_i = \sum B_i, d_i = A_i+B_i. It does this independently from list to list using the same Nsim each time, adding the resulting Kruskal-Wallis criteria across lists to get Nsim such summed values to estimate the P-value.

"exact" enumerates all counts for A_i and B_i with the respective observed marginal totals to get an exact distribution for each list. These distributions are then convolved to obtain the P-value. It is used only when Nsim is at least as large as the product across blocks of the number choose(m+t-1,t-1) of full enumerations per block, where t = t_1,\ldots, t_M. Otherwise, method reverts to "simulated" using the given Nsim.

dist

FALSE (default) or TRUE. If TRUE, the simulated or fully enumerated null distribution null.dist is returned for the Kruskal-Wallis test statistic. Otherwise null.dist = NULL is returned.

Nsim

=10000 (default), number of simulated A_i splits to use per block. It is only used when method = "simulated", or when method = "exact" reverts to method = "simulated", as previously explained.

Details

For details on the calculation of the Kruskal-Wallis criterion and its exact or simulated distribution for each block see contingency2xt.

Value

A list of class kSamples with components

test.name

"Combined 2 x t Contingency Tables"

t

vector giving the number of classification categories per block

M

number of blocked tables

kw.list

a list of the KW.cont output componenents from contingency2xt for each of the blocks

null.dist

simulated or enumerated null distribution of the combined test statistic. It is given as an L by 2 matrix, where the first column (named KW) gives the L unique ordered values of the combined Kruskal-Wallis statistic and the second column (named prob) gives the corresponding (simulated or exact) probabilities.

null.dist = NULL is returned when dist = FALSE or when method = "asymptotic".

method

the method used.

Nsim

the number of simulations.

warning

method = "exact" should only be used with caution. Computation time is proportional to the number of enumerations. In most cases dist = TRUE should not be used, i.e., when the returned distribution objects become too large for R's work space.

Note

The required level for Nsim in order for method = "exact" to be carried out, is conservative, but there is no transparent way to get a better estimate. The actual dimension L of the realized null.dist will typically be much smaller, since the distribution is compacted to its unique support values.

Examples

out <- contingency2xt.comb(list(c(25,15,20),c(16,6,18)),
list(c(12,4,5),c(13,8,9)),method = "simulated", dist=FALSE, Nsim=1e3)

kSamples documentation built on Oct. 8, 2023, 1:07 a.m.