| interaction | R Documentation |
Create variable interaction
interaction(x, y, z = NULL)
x |
Unquoted symbol. One of the variables for interaction. |
y |
Unquoted symbol. One of the variables for interaction. |
z |
Unquoted symbol. One of the variables for interaction. |
Vector of newly created interaction
require(dplyr) # for the pipe operator
data('bc_train')
setup <- setup(
data_train = bc_train,
target = 'bc',
weight = 'exposure',
family = 'tweedie',
tweedie_p = 1.5,
keep_cols = c('pol_nbr', 'premium')
)
modeling <- setup %>%
factor_add(pol_yr) %>%
factor_add(agecat) %>%
factor_add(gender) %>%
model_fit() %>%
model_save("model1") %>%
factor_modify(agecat_X_gender = interaction(agecat, gender)) %>%
factor_add(agecat_X_gender) %>%
model_fit() %>%
model_save("model2") %>%
# modification of 'agecat' will simplify the base level of interaction (agecat_X_gender_F)
factor_modify(agecat = variate(agecat, type = "non_prop", mapping = 1:6)) %>%
# all other non-base levels need to be simplified separately
factor_modify(agecat_X_gender_M = variate(agecat_X_gender_M, type = "non_prop", mapping = 1:6, degree = 2)) %>%
model_fit()
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.