COMMA_data {COMMA} | R Documentation |
Generate Data to use in COMMA Functions
Description
Generate Data to use in COMMA Functions
Usage
COMMA_data(
sample_size,
x_mu,
x_sigma,
z_shape,
c_shape,
interaction_indicator,
outcome_distribution,
true_beta,
true_gamma,
true_theta
)
Arguments
sample_size |
An integer specifying the sample size of the generated data set. |
x_mu |
A numeric value specifying the mean of |
x_sigma |
A positive numeric value specifying the standard deviation of
|
z_shape |
A positive numeric value specifying the shape parameter of
|
c_shape |
A positive numeric value specifying the shape parameter of
|
interaction_indicator |
A logical value indicating if an interaction between
|
outcome_distribution |
A character string specifying the distribution of
the outcome variable. Options are |
true_beta |
A column matrix of |
true_gamma |
A numeric matrix of |
true_theta |
A column matrix of |
Value
COMMA_data
returns a list of generated data elements:
obs_mediator |
A vector of observed mediator values. |
true_mediator |
A vector of true mediator values. |
outcome |
A vector of outcome values. |
x |
A vector of generated predictor values in the true mediator mechanism, from the Normal distribution. |
z |
A vector of generated predictor values in the observed mediator mechanism from the Gamma distribution. |
c |
A vector of generated covariates. |
x_design_matrix |
The design matrix for the |
z_design_matrix |
The design matrix for the |
c_design_matrix |
The design matrix for the |
Examples
set.seed(20240709)
sample_size <- 10000
n_cat <- 2 # Number of categories in the binary mediator
# Data generation settings
x_mu <- 0
x_sigma <- 1
z_shape <- 1
c_shape <- 1
# True parameter values (gamma terms set the misclassification rate)
true_beta <- matrix(c(1, -2, .5), ncol = 1)
true_gamma <- matrix(c(1, 1, -.5, -1.5), nrow = 2, byrow = FALSE)
true_theta <- matrix(c(1, 1.5, -2, -.2), ncol = 1)
example_data <- COMMA_data(sample_size, x_mu, x_sigma, z_shape, c_shape,
interaction_indicator = FALSE,
outcome_distribution = "Bernoulli",
true_beta, true_gamma, true_theta)
head(example_data$obs_mediator)
head(example_data$true_mediator)