
Generate data to use in two-stage COMBO Functions
COMBO_data_2stage.RdGenerate data to use in two-stage COMBO Functions
Arguments
- sample_size
An integer specifying the sample size of the generated data set.
- x_mu
A numeric value specifying the mean of
xpredictors generated from a Normal distribution.- x_sigma
A positive numeric value specifying the standard deviation of
xpredictors generated from a Normal distribution.- z1_shape
A positive numeric value specifying the shape parameter of
z1predictors generated from a Gamma distribution.- z2_shape
A positive numeric value specifying the shape parameter of
z2predictors generated from a Gamma distribution.- beta
A column matrix of \(\beta\) parameter values (intercept, slope) to generate data under in the true outcome mechanism.
- gamma1
A numeric matrix of \(\gamma^{(1)}\) parameters to generate data under in the first-stage observation mechanism. In matrix form, the
gamma1matrix rows correspond to intercept (row 1) and slope (row 2) terms. Thegamma1parameter matrix columns correspond to the true outcome categories \(Y \in \{1, 2\}\).- gamma2
A numeric array of \(\gamma^{(2)}\) parameters to generate data under the second-stage observation mechanism. In array form, the
gamma2matrix rows correspond to intercept (row 1) and slope (row 2) terms. The matrix columns correspond to first-stage observed outcome categories. The third dimension of thegamma2array is indexed by the true outcome categories.
Value
COMBO_data_2stage returns a list of generated data elements:
- obs_Ystar1
A vector of first-stage observed outcomes.
- obs_Ystar2
A vector of second-stage observed outcomes.
- true_Y
A vector of true outcomes.
- obs_Ystar1_matrix
A numeric matrix of indicator variables (0, 1) for the first-stage observed outcome \(Y^{*(1)}\). Rows of the matrix correspond to each subject. Columns of the matrix correspond to each observed outcome category. Each row contains exactly one 0 entry and exactly one 1 entry.
- obs_Ystar2_matrix
A numeric matrix of indicator variables (0, 1) for the second-stage observed outcome \(Y^{*(2)}\). Rows of the matrix correspond to each subject. Columns of the matrix correspond to each observed outcome category. Each row contains exactly one 0 entry and exactly one 1 entry.
- x
A vector of generated predictor values in the true outcome mechanism, from the Normal distribution.
- z1
A vector of generated predictor values in the first-stage observation mechanism from the Gamma distribution.
- z2
A vector of generated predictor values in the second-stage observation mechanism from the Gamma distribution.
- x_design_matrix
The design matrix for the
xpredictor.- z1_design_matrix
The design matrix for the
z1predictor.- z2_design_matrix
The design matrix for the
z2predictor.
Examples
set.seed(123)
n <- 1000
x_mu <- 0
x_sigma <- 1
z1_shape <- 1
z2_shape <- 1
true_beta <- matrix(c(1, -2), ncol = 1)
true_gamma1 <- matrix(c(.5, 1, -.5, -1), nrow = 2, byrow = FALSE)
true_gamma2 <- array(c(1.5, 1, .5, .5, -.5, 0, -1, -1), dim = c(2, 2, 2))
my_data <- COMBO_data_2stage(sample_size = n,
x_mu = x_mu, x_sigma = x_sigma,
z1_shape = z1_shape, z2_shape = z2_shape,
beta = true_beta, gamma1 = true_gamma1, gamma2 = true_gamma2)
table(my_data[["obs_Ystar2"]], my_data[["obs_Ystar1"]], my_data[["true_Y"]])
#> , , = 1
#>
#>
#> 1 2
#> 1 457 113
#> 2 51 38
#>
#> , , = 2
#>
#>
#> 1 2
#> 1 30 40
#> 2 39 232
#>