logistic_reg_w_interaction: Logistic regression with an interaction term

Description Usage Arguments Value Examples

View source: R/logistic_reg_w_interaction.R

Description

Conduct logistic regression for a model with an interaction between two predictor variables

Usage

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
logistic_reg_w_interaction(
  data = NULL,
  dv_name = NULL,
  iv_1_name = NULL,
  iv_2_name = NULL,
  round_p = 3,
  round_chi_sq = 2,
  dv_ordered_levels = NULL,
  iv_1_ordered_levels = NULL,
  iv_2_ordered_levels = NULL,
  one_line_summary_only = FALSE,
  p_value_interaction_only = FALSE,
  return_dt_w_binary = FALSE
)

Arguments

data

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

dv_name

name of the dependent variable (must be a binary variable)

iv_1_name

name of the first independent variable

iv_2_name

name of the second independent variable

round_p

number of decimal places to which to round p-values (default = 3)

round_chi_sq

number of decimal places to which to round chi square statistics (default = 2)

dv_ordered_levels

a vector with the ordered levels of the dependent variable, the first and second elements of which will be coded as 0 and 1, respectively, to run logistic regression. E.g., dv_ordered_levels = c("fail", "pass")

iv_1_ordered_levels

(only if the first independent variable is a binary variable) a vector with the ordered levels of the first independent variable, the first and second elements of which will be coded as 0 and 1, respectively, to run logistic regression. E.g., iv_1_ordered_levels = c("control", "treatment")

iv_2_ordered_levels

(only if the second independent variable is a binary variable) a vector with the ordered levels of the first independent variable, the first and second elements of which will be coded as 0 and 1, respectively, to run logistic regression. E.g., iv_2_ordered_levels = c("male", "female")

one_line_summary_only

logical. Should the output simply be a printout of a one-line summary on the interaction term? (default = FALSE)

p_value_interaction_only

logical. Should the output simply be a p-value of the interaction term in the logistic regression model? (default = FALSE)

return_dt_w_binary

logical. If return_dt_w_binary = TRUE, the function will return a data.table with binary variables coded as 0 or 1 (default = FALSE)

Value

the output will be a summary of logistic regression results, unless set otherwise by arguments to the function.

Examples

1
2
logistic_reg_w_interaction(data = mtcars, dv_name = "vs",
iv_1_name = "mpg", iv_2_name = "am")

kim documentation built on Oct. 1, 2021, 5:08 p.m.