generate_y_linear | R Documentation |
Generate linear response data with a specified error distribution given the observed and unobserved design matrices.
generate_y_linear( X, U, betas = NULL, betas_unobs = NULL, intercept = 0, err = NULL, return_support = FALSE, ... )
X |
Design data matrix of observed variables. |
U |
Design data matrix of unobserved (omitted) variables. |
betas |
Coefficient vector for observed design matrix. If a scalar is provided, the coefficient vector is constant. If |
betas_unobs |
Coefficient vector for unobserved design matrix. If a scalar is provided, the coefficient vector is constant. If |
intercept |
Scalar intercept term. |
err |
Function from which to generate simulated error vector. Default is
|
return_support |
Logical specifying whether or not to return a vector of
the support column names. If |
... |
Additional arguments to pass to functions that generate betas, betas_unobs, and err. If the argument doesn't exist in one of the functions it is ignored. If two or more of the functions have an argument of the same name but with different values, then use one of the following prefixes in front of the argument name (passed via |
If return_support = TRUE
, returns a list of two:
A response vector of length nrow(X)
.
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
.
X <- generate_X_gaussian(.n = 100, .p = 2) U <- generate_X_gaussian(.n = 100, .p = 2) # generate the response from: y = 3*x_1 - x_2 + N(0, 1) errors y <- generate_y_linear(X = X, betas = c(3, -1), err = rnorm) # generate the response from: y = 3*x_1 - x_2 + u_1 + 2*u_2 y <- generate_y_linear(X = X, U = U, betas = c(3, -1), betas_unobs = c(1, 2))
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.