multiple_regression: Multiple regression

View source: R/multiple_regression.R

multiple_regressionR Documentation

Multiple regression

Description

Conduct multiple regression analysis and summarize the results in a data.table.

Usage

multiple_regression(
  data = NULL,
  formula = NULL,
  vars_to_mean_center = NULL,
  mean_center_vars = NULL,
  sigfigs = NULL,
  round_digits_after_decimal = NULL,
  round_p = NULL,
  pretty_round_p_value = TRUE,
  return_table_upper_half = FALSE,
  round_r_squared = 3,
  round_f_stat = 2,
  prettify_reg_table_col_names = TRUE,
  silent = FALSE
)

Arguments

data

a data object (a data frame or a data.table)

formula

a formula object for the regression equation

vars_to_mean_center

(deprecated) a character vector specifying names of variables that will be mean-centered before the regression model is estimated

mean_center_vars

a character vector specifying names of variables that will be mean-centered before the regression model is estimated

sigfigs

number of significant digits to round to

round_digits_after_decimal

round to nth digit after decimal (alternative to sigfigs)

round_p

number of decimal places to round p values (overrides all other rounding arguments)

pretty_round_p_value

logical. Should the p-values be rounded in a pretty format (i.e., lower threshold: "<.001"). By default, pretty_round_p_value = TRUE.

return_table_upper_half

logical. Should only the upper part of the table be returned? By default, return_table_upper_half = FALSE.

round_r_squared

number of digits after the decimal both r-squared and adjusted r-squared values should be rounded to (default 3)

round_f_stat

number of digits after the decimal the f statistic of the regression model should be rounded to (default 2)

prettify_reg_table_col_names

logical. Should the column names of the regression table be made pretty (e.g., change "std_beta" to "Std. Beta")? (Default = TRUE)

silent

If silent = FALSE, a message regarding mean-centered variables will be printed. If silent = TRUE, this message will be suppressed. By default, silent = FALSE.

Details

To include standardized beta(s) in the regression results table, the following package(s) must be installed prior to running the function: Package 'lm.beta' v1.5-1 (or possibly a higher version) by Stefan Behrendt (2014), https://cran.r-project.org/package=lm.beta

Value

the output will be a data.table showing multiple regression results.

Examples


multiple_regression(data = mtcars, formula = mpg ~ gear * cyl)
multiple_regression(
data = mtcars, formula = mpg ~ gear * cyl,
mean_center_vars = "gear",
round_digits_after_decimal = 2)


kim documentation built on Oct. 9, 2023, 5:08 p.m.