Learn R Programming

bonsaiforest (version 0.1.1)

simul_covariates: Generation of a Design Matrix for Simulations

Description

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.

Usage

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

Value

The design matrix.

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.

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

Run this code
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)

Run the code above in your browser using DataLab