simul_covariates function

Generation of a Design Matrix for Simulations

Generation of a Design Matrix for Simulations

This function uses a block diagonal covariance matrix for the underlying multivariate normal data to create the design matrix in blocks of 10, see the details.

simul_covariates(n, p_catvar = 10, add_contvars = FALSE, arm_factor = FALSE)

Arguments

  • n: (count)

    number of rows (observations).

  • p_catvar: (count)

    number of covariates (excluding treatment arm).

  • add_contvars: (flag)

    whether to add continuous covariates.

  • arm_factor: (flag)

    whether to make the arm variable a factor.

Returns

The design matrix.

Details

The following pattern is repeated for the covariate blocks:

  • The first 5 covariates are uncorrelated with everything.
  • The covariates 6 to 8 have "moderate" correlation (0.25) between each other.
  • The covariates 9 and 10 have "high" correlation (0.5).

By default, only the resulting categorical covariates obtained by thresholding are included. Optionally also the original continuous covariates are included in the returned design matrix.

Examples

simul_covariates(n = 10, p_catvar = 3, add_contvars = FALSE) simul_covariates(n = 10, p_catvar = 3, add_contvars = TRUE) simul_covariates(n = 10, p_catvar = 3, add_contvars = TRUE, arm_factor = TRUE)