
Test for conditional independence in a contingency table represented as an array.
ciTest_table(x, set = NULL, statistic = "dev", method = "chisq",
adjust.df = TRUE, slice.info = TRUE, L = 20, B = 200, ...)
An array of counts with named dimnames.
A specification of the test to be made. The tests are of the form u
and v are independent condionally on S where u and v are variables and S
is a set of variables. See 'details' for details about specification of
set
.
Possible choices of the test statistic are "dev"
for
deviance and "X2"
for Pearsons X2 statistic.
Method of evaluating the test statistic. Possible choices are
"chisq"
, "mc"
(for Monte Carlo) and "smc"
for
sequential Monte Carlo.
Logical. Should degrees of freedom be adjusted for sparsity?
Logical. Should slice info be stored in the output?
Number of extreme cases as stop criterion if method is "smc"
(sequential Monte Carlo test); ignored otherwise.
Number (maximum) of simulations to make if method is "mc"
or
"smc"
(Monte Carlo test or sequential Monte Carlo test); ignored
otherwise.
Additional arguments.
An object of class 'citest' (which is a list).
set
can be 1) a vector or 2) a right-hand sided formula in
which variables are separated by '+'. In either case, it is tested if the
first two variables in the set
are conditionally independent given
the remaining variables in set
. (Notice an abuse of the '+'
operator in the right-hand sided formula: The order of the variables does
matter.)
If set
is NULL
then it is tested whether the first two
variables are conditionally independent given the remaining variables.
ciTest
, ciTest.data.frame
,
ciTest_df
, ciTest.list
,
ciTest_mvn
, chisq.test
# NOT RUN {
data(lizard)
## lizard is has named dimnames
names( dimnames( lizard ))
## checked with
is.named.array( lizard )
## Testing for conditional independence:
# the following are all equivalent:
ciTest(lizard, set=~diam + height + species)
# ciTest(lizard, set=c("diam", "height", "species"))
# ciTest(lizard, set=1:3)
# ciTest(lizard)
# (The latter because the names in lizard are as given above.)
## Testing for marginal independence
ciTest(lizard, set=~diam + height)
ciTest(lizard, set=1:2)
## Getting slice information:
ciTest(lizard, set=c("diam", "height", "species"), slice.info=TRUE)$slice
## Do Monte Carlo test instead of usual likelihood ratio test. Different
# options:
# 1) Do B*10 simulations divided equally over each slice:
ciTest(lizard, set=c("diam", "height", "species"), method="mc", B=400)
# 2) Do at most B*10 simulations divided equally over each slice, but stop
# when at most L extreme values are found
ciTest(lizard, set=c("diam", "height", "species"), method="smc", B=400)
# }
Run the code above in your browser using DataLab