Learn R Programming

linea (version 0.1.1)

what_combo: what_combo

Description

run models across combinations of transformations and variables

Usage

what_combo(
  model = NULL,
  trans_df = NULL,
  data = NULL,
  dv = NULL,
  r2_diff = TRUE,
  return_model_objects = FALSE,
  verbose = FALSE
)

Value

list of two data.frame mapping variables' transformations to the respective model's statistics.

Arguments

model

Model object

trans_df

data.frame containing the transformations, variables and parameter values

data

data.frame containing data from analysis

dv

string specifying the dependent variable name

r2_diff

A boolean to determine whether to add a column to compare new and original model R2

return_model_objects

A boolean to specify whether to return model objects

verbose

A boolean to specify whether to print warnings

Details

Run a separate model for each combination of transformations specified. The combinations are defined by the possible transformation parameters specified in the trans_df. Then, for each model run, return that model's fit and the variables' statistics.

Examples

Run this code

# using a model object
data = read_xcsv("https://raw.githubusercontent.com/paladinic/data/main/ecomm_data.csv")
dv = 'ecommerce'
ivs = c('christmas','black.friday')


trans_df = data.frame(
  name = c('diminish', 'decay', 'hill', 'exp'),
  ts = c(FALSE,TRUE,FALSE,FALSE),
  func = c(
    'linea::diminish(x,a)',
    'linea::decay(x,a)',
    "linea::hill_function(x,a,b,c)",
    '(x^a)'
  ),
  order = 1:4
) %>%
  dplyr::mutate(offline_media = dplyr::if_else(condition = name == 'hill',
                                               '(1,50),(1),(1,100)',
                                               '')) %>%
  dplyr::mutate(offline_media = dplyr::if_else(condition = name == 'decay',
                                              '.1,.7 ',
                                              offline_media)) %>%
  dplyr::mutate(promo = '')

model = run_model(data = data,dv = dv,ivs = ivs, trans_df = trans_df)

combos = what_combo(model = model,trans_df = trans_df)

#using the trans_df, data, and dv
what_combo(trans_df = trans_df, data = data, dv = dv)

Run the code above in your browser using DataLab