Extract {hySAINT} | R Documentation |
Extracting columns and generating required interaction effects from data
Description
This function simplifies the data preparation process by enabling users to
extract specific columns from their dataset X
, and automatically
generating any necessary interaction effects based on varind
.
Usage
Extract(X, varind, interaction.ind = NULL)
Arguments
X |
Input data. An optional data frame, or numeric matrix of dimension
|
varind |
A numeric vector that specifies the indices of variables to be
extracted from |
interaction.ind |
A two-column numeric matrix. Each row represents a unique
interaction pair, with the columns indicating the index numbers of the variables
involved in each interaction. Note that |
Value
A numeric matrix is returned.
Examples
# Generate interaction.ind
interaction.ind <- t(combn(4,2))
# Generate data
set.seed(0)
X <- matrix(rnorm(20), ncol = 4)
y <- X[, 2] + rnorm(5)
# Extract X1 and X1X2 from X1, ..., X4
Extract(X, varind = c(1,5), interaction.ind)
# Extract X5 from X1, ..., X4
Extract(X, varind = 5, interaction.ind)
# Extract using duplicated values
try(Extract(X, varind = c(1,1), interaction.ind)) # this will not run