simulate: Cook a simulation recipe of 'Xy()'

View source: R/simulate.R

simulateR Documentation

Cook a simulation recipe of Xy()

Description

A function which simulates linear and nonlinear X and a corresponding target. The composition of the target is highly customizable. Furthermore, the polynomial degree as well as the functional shape of nonlinearity can be specified by the user. Additionally coviarance structure of the X can either be sampled by the function or specifically determined by the user.

Usage

simulate(
  object,
  n = 1000,
  r_squared = 0.8,
  cor_interval = c(-0.5, 0.5),
  cor_matrix = NULL,
  ...
)

Arguments

object

an object of class xy_recipe.

n

an integer specifying the desired number of obervations.

r_squared

a numeric value between 0 and 1.

cor_interval

a vector of length 2, which provides the correlation sample interval for the correlation matrix.

cor_matrix

a (positive semidefinite) correlation matrix. This matrix inherits the desired correlation structure of the simulated effects. Defaults to NULL, which means the structure will be sampled from cor

...

additional parameters

Details

The simulation uses a copula backend and can simulate effects from various distributions.

  • r_squared: The simulation adjusts the noise of the target generating process according to the user specified input of the R^2. Hence, if the user chooses to set a high R^2 then the noise will have little to no effect on the target generating process. Choosing lower R^2 yields to a stronger noise. Thus, when fitting an ML model, the r_squared is the upper bound of achievable adjusted r_squared.

Value

An object of class xy_sim, which contains meta information about the simulation. The user can manipulate this object with methods from the class xy_sim, e.g. importance().

Author(s)

Andre Bleier (andre.bleier@statworx.com)

Examples

# create a recipe
recipe <- Xy() %>%
  add_linear(p = 5, family = xy_weibull())
# cook the recipe
recipe %>% simulate(n = 10)

andrebleier/Xy documentation built on March 29, 2023, 12:41 p.m.