This function fits two linear regression models: a base model without the main predictor of interest and a full model including the main predictor. It then compares these models using ANOVA to test the significance of adding the main predictor. Additionally, it calculates the effect sizes for the predictor in the full model. This function is designed to facilitate the analysis of data. NOTE: this function will scale variables internally to aid coefficient estimate visualization.

lm_anv_p_and_d(
  data,
  outcome,
  predictor,
  fixed_effects,
  predictoroperator = "*",
  verbose = FALSE
)

Arguments

data

A data frame containing the variables referenced in the model formulas.

outcome

The name of the dependent variable (outcome) as a string.

predictor

The name of the main predictor variable as a string.

fixed_effects

A string specifying the fixed effects to be included in the model, excluding the main predictor.

predictoroperator

either a + or *

verbose

boolean

Value

A list containing the fitted full model object, ANOVA model comparison, calculated effect sizes for the predictor, coefficients of the full model, and the sample size (n).

Examples

# Assuming 'data' is your dataset with columns 'outcome', 'predictor', and 'fixed_var1', ...
# results <- lm_anv_p_and_d(data, "outcome", "predictor", "fixed_var1 + fixed_var2")
# summary(results$full_model) # Full model summary
# results$model_comparison # ANOVA comparison
# results$effect_sizes # Effect sizes