Description Usage Arguments Details Value Author(s) See Also Examples
View source: R/simulate_diff_tables.R
Generate contingency tables that are first-order, second-order or full-order differential in the joint distribution of row and column variables.
1 2 3 4 | simulate_diff_tables(
K = 2, nrow = 3, ncol = 3, n = 100, B = 100,
type = c("second-order", "first-order", "full-order")
)
|
K |
the number of tables that are differential. It must be an integer greater than one. |
nrow |
the number of rows for all tables to be generated. It must be an integer greater than one. |
ncol |
the number of columns for all tables to be generated. It must be an integer greater than one. |
n |
the sample size for each table to be generated. It must be a positive integer. |
B |
the number of iterations indicating the level of differentiality. It must be a positive integer. The greater the value, the stronger the differentiality across tables. |
type |
the type of differential tables to be generated. Options are |
The function randomly generates contingency tables differential in the joint distribution of the row and column variables. Specifically, three types of differential contingency tables can be simulated:
First-order differential contingency tables only differ in row or column marginal distribution. Such tables are differential in joint distribution, but different from second-order differential tables.
Second-order differential contingency tables differ in joint distribution The difference is not attributed to row or column marginal distributions.
Full-order differential contingency tables are tables that are both first-order and second-order differential.
The simulation starts with randomly generated probability tables where row and column variables are independent. The probability tables are modified to K
tables such that they represent specific distributions that strictly satisfy the type requirement. Finally, contingency tables are generated using multinomial distribution using these probability tables parameters and the required sample size.
A list containing the following components:
contingency.tables |
a list of |
probability.tables |
a list of |
method |
a string that specifies the type of the differential tables. |
Ruby Sharma and Joe Song
Differential tables are simulated to evaluate the following tests for comparing contingency tables:
The Sharma-Song test sharma.song.test
The comparative chi-squared test cp.chisq.test
The heterogeneity test heterogeneity.test
The simulate_tables
function in package FunChisq can generate a variety of tables.
1 2 3 4 5 6 7 8 9 10 11 | # Three first-order differential tables:
res <- simulate_diff_tables(K = 3, nrow = 4, ncol = 3, n = 150, B = 200, type = "first-order")
print(res)
# Two second-order differential tables:
res <- simulate_diff_tables(K = 2, nrow = 2, ncol = 5, n = 100, B = 100, type = "second-order")
print(res)
# Four full-order differential tables:
res <- simulate_diff_tables(K = 4, nrow = 3, ncol = 4, n = 250, B = 200, type = "full-order")
print(res)
|
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.