selOracle | R Documentation |
This function selects a given number of variables, always including those in a pre-specified set.
selOracle(X, Y, target, toSel)
X |
numeric design matrix (excluding the intercept), where columns correspond to variables, and rows to observations. |
Y |
numeric response vector. |
target |
maximum number of variables to be selected. |
toSel |
numeric vector containing the indices of the variables to be always selected. |
An error message is returned if target
is smaller than the length of toSel
.
selOracle
returns a numeric vector containing the indices of the selected variables.
Variables in toSel
are always included.
Anna Vesely.
# generate linear regression data with 20 variables and 10 observations
res <- simData(m1=2, m=20, n=10, rho=0.5, type="toeplitz", SNR=5, seed=42)
X <- res$X # design matrix
Y <- res$Y # response vector
active <- res$active # indices of active variables
# choose target as twice the number of active variables
target <- 2*length(active)
# selection of at most target variables, including the active ones
selOracle(X, Y, target, active)
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.