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.
contingency2xt.comb(...,
method = c("asymptotic", "simulated", "exact"),
dist = FALSE, Nsim = 10000)
A list of class kSamples
with components
"Combined 2 x t Contingency Tables"
vector giving the number of classification categories per block
number of blocked tables
a list of the KW.cont
output componenents from
contingency2xt
for each of the blocks
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"
.
the method
used.
the number of simulations.
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
= 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
.
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.
=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.
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.
For details on the calculation of the Kruskal-Wallis criterion and its exact or simulated
distribution for each block see contingency2xt
.
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)
Run the code above in your browser using DataLab