Compare nested logistic-regression models via likelihood-ratio test
Source:R/investigation.R
morie_compare_nested_logistic_models.RdMirrors 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.
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
#>