add_effects | R Documentation |
With the helping function below you can alter a simulation by simply
adding the desired effects to the simulation object from Xy()
.
add_linear(object, p, family = xy_normal())
add_nonlinear(object, p, nlfun = function(x) x^2, family = xy_normal())
add_discrete(object, p, levels = 2)
add_uninformative(object, p, collinearity = FALSE, family = xy_normal())
add_intercept(object)
add_noise(object, collinearity = FALSE, family = xy_normal())
add_interactions(object)
object |
an object of class |
p |
an integer specifying the number of effects to simulate |
family |
a distributional family (see families) |
nlfun |
a function which transforms the simulated variable |
levels |
an integer specifying the number of levels within the simulated discrete variable |
collinearity |
a boolean specifying whether there is collinearity between the features and uninformative variables |
A note on non-linear effects: Depending on the non-linear function
it is highly recommended to adjust the parameters of the family, e.g.
for a nonlinear quadratic function it is recommended to sample from
a uniform distribution with minimum value of 0 and maximum value of
1000 such that the non-linearity is clearly visible in the data.
# nonlinear simulation sim_nl <- Xy(task = "regression") %>% add_nonlinear(p = 5, nlfun = function(x) x^2, family = xy_uniform(min = 0, max = 1000))
an object of class xy_recipe
xy_recipe <- Xy(task = "regression") %>%
# add linear features
add_linear(p = 5)
# add cubic nonlinear features
xy_recipe <- xy_recipe %>%
add_nonlinear(p = 3, nlfun = function(x) x^3, family = xy_uniform(min = 0, max = 1000))
# add discrete features with four unique factor levels
xy_recipe <- xy_recipe %>%
add_discrete(p = 2, levels = 4)
# add uninformative features (they do not influence the target generating process)
xy_recipe <- xy_recipe %>%
add_uninformative(p = 5)
# add features from the cauchy distribution
xy_recipe <- xy_recipe %>%
add_linear(p = 2, family = xy_cauchy(location = 3, scale = 5))
# add random interactions between all informative features
xy_recipe <- xy_recipe %>%
add_interactions()
# add a specific form of noise to your process, e.g. poisson distributed
# noise
xy_recipe <- xy_recipe %>%
add_noise(family = xy_poisson(lambda = 3))
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.