Extract {AVGAS}R Documentation

Extracting specific columns from a data

Description

This function extracts specific columns from X based on varind. It provides an efficient procedure for conducting ABC evaluation, especially when working with high-dimensional data.

Usage

Extract(X, varind, interaction.ind = NULL)

Arguments

X

Input data. An optional data frame, or numeric matrix of dimension n by nmain.p. Note that the two-way interaction effects should not be included in X because this function automatically generates the corresponding two-way interaction effects if needed.

varind

A numeric vector of class c() that specifies the indices of variables to be extracted from X. Duplicated values are not allowed. See Example section for details.

interaction.ind

A two-column numeric matrix containing all possible two-way interaction effects. It must be generated outside of this function using t(utils::combn()). See Example section for details.

Details

Please be aware that this function automatically renames column names into a designated format (e.g., X.1, X.2 for main effects, and X.1X.2 for interaction effect, etc), regardless of the original column names in X.

Under no heredity condition, this function can be applied in the context of interaction only linear regression models. See Example section for details.

Value

A numeric matrix is returned.

See Also

ABC, initial.

Examples

# Extract main effect X1 and X2 from X1,...X4
set.seed(0)
X1 <- matrix(rnorm(20), ncol = 4)
y1 <- X1[, 2] + rnorm(5)
interaction.ind <- t(combn(4,2))

# Extract main effect X1 and interaction effect X1X2 from X1,..X4
Extract(X1, varind = c(1,5), interaction.ind)

# Extract interaction effect X1X2 from X1,...X4
Extract(X1, varind = 5, interaction.ind)

# Extract using duplicated values in varind.
try(Extract(X1, varind = c(1,1), interaction.ind)) # this will not run

[Package AVGAS version 0.1.0 Index]