what_trans: what_trans

View source: R/model_next_step.R

what_transR Documentation

what_trans

Description

run models with additional (transformed) variables from the data

Usage

what_trans(
  model = NULL,
  trans_df = NULL,
  variable = NULL,
  data = NULL,
  r2_diff = TRUE,
  verbose = FALSE
)

Arguments

model

Model object

trans_df

data.frame

variable

string or character vector of variable names contained in raw_data data.frame

data

data.frame containing data from analysis

r2_diff

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

verbose

A boolean to specify whether to print warnings

Details

Run a separate model for each combination of transformations specified. Then, for each model run, return that model's fit and the variables' statistics.

Value

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

Examples

model = run_model(data = mtcars,dv = 'mpg',ivs = c('disp','cyl'))

trans_df = data.frame(
     name = c('diminish', 'decay', 'lag', 'ma', 'log', 'hill', 'sin', 'exp'),
     ts = c(FALSE,TRUE,TRUE,TRUE,FALSE,FALSE,FALSE,FALSE),
     func = c('linea::diminish(x,a)',
              'linea::decay(x,a)',
              'linea::lag(x,a)',
              'linea::ma(x,a)',
              'log(x,a)',
              "linea::hill_function(x,a,b,c)",
              'sin(x*a)',
              '(x^a)'),order = 1:8) %>%
  dplyr::mutate(val = '') %>%
  dplyr::mutate(val = dplyr::if_else(condition = name == 'hill',
                                     '(1,5,50),(1 ,5,50),(1,5,50)',
                                     val))

variable = 'cyl'

model %>%
 what_trans(variable = variable,trans_df = trans_df)


linea documentation built on Sept. 15, 2022, 9:06 a.m.