Skip to contents

Mirrors the Python morie.compare_nested_logistic_models(). Fits a reduced and a full logistic model (the reduced model's predictors must be a subset of the full model's), then performs an analysis-of-deviance LRT.

Usage

morie_compare_nested_logistic_models(
  data,
  outcome,
  predictors_full,
  predictors_reduced
)

Arguments

data

A data.frame.

outcome

Column name of the binary outcome.

predictors_full

Character vector: full model's predictors.

predictors_reduced

Character vector: reduced model's predictors. Must be a subset of predictors_full.

Value

A list with chi_sq, df, p_value, aic_full, aic_reduced, n.

Examples

set.seed(1)
df <- data.frame(
  y = rbinom(200, 1, 0.4),
  x1 = rnorm(200), x2 = rnorm(200), x3 = rnorm(200)
)
morie_compare_nested_logistic_models(df,
  outcome = "y",
  predictors_full = c("x1", "x2", "x3"),
  predictors_reduced = c("x1")
)
#> $chi_sq
#> [1] 0.554711
#> 
#> $df
#> [1] 2
#> 
#> $p_value
#> [1] 0.7577851
#> 
#> $aic_full
#> [1] 278.7075
#> 
#> $aic_reduced
#> [1] 275.2622
#> 
#> $n
#> [1] 200
#>