Description Usage Arguments Details Value Examples
multiple_binary_test
is used to preform goodness-of-fit tests on
multiple binary chains of data of the same length to see if a Markov chain
model is appropriate.
1 2 | multiple_binary_test(binary_chains, swaps = 1000, n = 1000, run = 4,
bins = 30, success = NULL)
|
binary_chains |
A two dimensional matrix, in which there are two unique values. |
swaps |
A positive nonzero integer value for the number of swaps to be
attempted on the chain. Larger values will tend to yield "more independent"
data. Generally, the number of swaps should be much larger then the number of
elements in the matrix |
n |
A positive nonzero integer representing the number of new sets of chains to be generated. |
run |
The length of the run to test for if one is interested in run test statistics. |
bins |
The number of bins to be displayed in histograms of test
statistics when one plots objects generated by |
success |
Denotes the data entry to be counted for run statistics. |
multiple_binary_test
works by taking the supplied binary_chains
parameter, counting the transitions between different elements, and then
generating n
new sets of chains with the same number of transitions.
It generates these new sets of chains by attempting to swap random elements
of the chains swaps
times, only doing so if the attempted swap
preserves the number of transitions between the two unique elements of the
chains. multiple_binary_test
then saves the chain generated by this
process, then preforms a number of swaps equivalent to the value of
swaps
on that chain again, then recording the result in a new entry in
a list of data. multiple_binary_test
does this n
times to
generate the n
new sets of chains. These new sets of chains are
effectively independent of the original one.
Once multiple_binary_test
has generated new data, it preforms various
tests of that data. included in the function are the likelihood ratio test,
the Pearson's chi square test, and a run test for a run of length specified
by the argument run
.
multiple_binary_test
returns a list of class
"multiple_binary_test"
with the following elements:
data
, a list of matrices, the first of which is binary_chains, and
the rest of which are the generated data.
test_stats_lrt
, vector of likelihood ratio test statistics for each
element of list data
.
test_stats_chi_sq
, a vector of Pearson's chi square test statistics
for each element of list data
.
test_stats_run
, a vector of run test statistics for a run of length
run
for each element of list data
.
p_value_lrt
, the p-value of binary_chain
, calculated exactly
from the distribution of test_stats_lrt
.
p_value_chi_sq
, the p-value of binary_chain
, calculated exactly
from the distribution of test_stats_chi_sq
.
p_value_run
, the p-value of binary_chain
, calculated exactly
from the distribution of test_stats_run
.
call
, the function call.
bins
, the number of bins specified in the function call.
run
, the length of run specified in the function call.
1 2 3 | data <- as.matrix(maRkov::snoqualmie)
foo <- multiple_binary_test(binary_chains = data, swaps = 10000, n = 10000,
run = 3, bins = 50)
|
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.