sim.chisq.ind {simitation} | R Documentation |
sim.chisq.ind
Description
sim.chisq.ind
Usage
sim.chisq.ind(
n,
values,
probs,
num.experiments = 2,
experiment.name = "experiment",
group.name = "group",
group.values = NULL,
value.name = "value",
seed = 8272,
vstr = 3.6
)
Arguments
n |
A vector of sample sizes for the different groups. |
values |
A vector of values specifying the sample space. |
probs |
A matrix of probabilities used to simulate the values in each group. The rows of the probs matrix correspond to the groups, while the columns correspond to the values. |
num.experiments |
A numeric value representing the number of simulated experiments. |
experiment.name |
A character value providing the name for the column identifying the experiment. |
group.name |
A character value providing the name of the column of the group labels. |
group.values |
A vector of unique values that identify the different groups, e.g. c("x", "y", "z"). If NULL, then values "x1", "x2", ..., "xk" will be assigned for the k groups specified. |
value.name |
A character value providing the name for the simulated values. |
seed |
A single numeric value, interpreted as an integer, or NULL. See help(set.seed). |
vstr |
A character string containing a version number, e.g., "1.6.2". The default RNG configuration of the current R version is used if vstr is greater than the current version. See help(set.seed). |
Value
A data table with the following columns:
-
experiment.name
: The name of the experiment, repeated according to the number of experiments and group sample sizes. -
group.name
: The name of the group for each observation. -
value.name
: The simulated value for each observation.
Examples
n <- c(50, 75, 100)
values <- LETTERS[1:4]
group.names <- paste0("group_", 1:3)
probs <- matrix(data =
c(0.25, 0.25, 0.25, 0.25, 0.4, 0.3, 0.2, 0.1, 0.2, 0.4, 0.2, 0.2),
nrow = length(n), byrow = TRUE)
simdat.chisq.ind <- sim.chisq.ind(n = c(50, 75, 100),
values = LETTERS[1:4], probs = probs, num.experiments = 2,
experiment.name = "exp_id", group.name = "treatment_group",
group.values = paste0("group_", 1:3), value.name = "category", seed = 31)