Learn R Programming

linea (version 0.1.1)

what_trans: 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
)

Value

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

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.

Examples

Run this code
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)

Run the code above in your browser using DataLab