This function simulates Gaussian predictors with mean zero and a covariance structure determined by the "cov_type" argument. Then, `p_b` randomly selected columns are dichotomized.

generate_X(n, p, p_b = 0, cov_type = "cov_ar1", rho = 0.5)

Arguments

n

Number of observations (rows of X).

p

Total number of covariates (columns of X), both continuous and binary.

p_b

Number of binary covariates (0 <= p_b <= p).

cov_type

Character string specifying the covariance function: - "cov_diag" (independent columns). - "cov_equi" (equi-correlated columns). - "cov_ar1" (AR(1)-correlated columns).

rho

Correlation parameter; input to the cov_type function.

Value

A simulated data frame with `n` rows and `p` columns, of which `p_b` are binary and `p - p_b` are Gaussian. Each column is either of class "numeric" or "factor".

Details

This function simulates a data frame whose rows are multivariate Gaussian with mean zero and covariance structure determined by the "cov_type" argument. Then, `p_b` randomly selected columns are dichotomized with the function \(1(x > 0)\). The continuous columns are of class "numeric", and the binary columns are set to class "factor".

See also

Other generate: generate_Weib(), generate_lp(), generate_y()

Examples

# All columns are continuous:
X <- generate_X(n=80, p=100, p_b=0, cov_type="cov_equi", rho=0.5)

# Two of the columns are dichotomized (and set to class factor):
X <- generate_X(n=80, p=100, p_b=2, cov_type="cov_equi", rho=0.5)