Conduct multiple regression analysis and summarize the results in a data.table.
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, save_as_png =FALSE, png_name =NULL, width =1600, height =1200, units ="px", res =200)
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.
save_as_png: if save_as_png = TRUE, the regression table will be saved as a PNG file (default = FALSE).
png_name: name of the PNG file to be saved. By default, the name will be "mult_reg_" followed by a timestamp of the current time. The timestamp will be in the format, jan_01_2021_1300_10_000001, where "jan_01_2021" would indicate January 01, 2021; 1300 would indicate 13:00 (i.e., 1 PM); and 10_000001 would indicate 10.000001 seconds after the hour.
width: width of the PNG file (default = 1600)
height: height of the PNG file (default = 1200)
units: the units for the width and height arguments. Can be "px" (pixels), "in" (inches), "cm", or "mm". By default, units = "px".
res: The nominal resolution in ppi which will be recorded in the png file, if a positive integer. Used for units other than the default. By default, res = 200
Returns
the output will be a data.table showing multiple regression results.
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