Skip to contents

Generate (binary) logistic response data given the observed design matrices.

Usage

generate_y_logistic(X, betas = 0, intercept = 0, return_support = FALSE, ...)

Arguments

X

Design data matrix of observed variables.

betas

Coefficient vector for observed design matrix. If a scalar is provided, the coefficient vector is constant. If NULL (default), entries in the coefficient vector are drawn iid from N(0, betas_sd^2). Can also be a function that generates the coefficient vector; see generate_coef().

intercept

Scalar intercept term.

return_support

Logical specifying whether or not to return a vector of the support column names. If X has no column names, then the indices of the support are used.

...

Not used.

Value

If return_support = TRUE, returns a list of two:

y

A response vector of length nrow(X).

support

A vector of feature indices indicating all features used in the true support of the DGP.

If return_support = FALSE, returns only the response vector y.

Examples

X <- generate_X_gaussian(.n = 100, .p = 2)

# generate the response from: log(p / (1 - p)) = 3*x_1 - x_2
# where p = P(y  = 1 | x)
y <- generate_y_logistic(X = X, betas = c(3, -1))