Learn R Programming

SVEMnet (version 3.2.0)

bigexp_train: Build a spec and prepare training data in one call

Description

bigexp_train() is a convenience wrapper around bigexp_terms and bigexp_prepare. It:

  • builds a deterministic expansion spec from the training data; and

  • immediately prepares that same data to match the locked types and levels.

Usage

bigexp_train(formula, data, ...)

Value

An object of class "bigexp_train" which is a list with components:

  • spec: the "bigexp_spec" object returned by bigexp_terms().

  • formula: the expanded formula spec$formula.

  • data: the prepared training data (predictors coerced to match spec), suitable for passing directly to modeling functions such as lm(), glm(), or SVEMnet().

Arguments

formula

Main-effects formula such as y ~ X1 + X2 + G or y ~ .. Only main effects should appear on the right hand side.

data

Training data frame used to lock types and levels.

...

Additional arguments forwarded to bigexp_terms(), such as factorial_order, polynomial_order, include_pc_2way, include_pc_3way, and intercept.

Details

This is handy when you want a single object that contains both the spec and the training data in a form that is ready to pass into a modeling function. For more control, you can call bigexp_terms() and bigexp_prepare() explicitly instead.

Examples

Run this code
set.seed(1)
df5 <- data.frame(
  y  = rnorm(20),
  X1 = rnorm(20),
  X2 = rnorm(20)
)

tr <- bigexp_train(
  y ~ X1 + X2,
  data             = df5,
  factorial_order  = 2,
  polynomial_order = 3
)

## Prepared training data and expanded formula:
str(tr$data)
tr$formula

## Example: fit a model using the expanded formula
fit_lm <- lm(tr$formula, data = tr$data)
summary(fit_lm)

Run the code above in your browser using DataLab