Skip to content

Commit 1b5756c

Browse files
committed
Add Deviances to LRT output
1 parent 9b7e865 commit 1b5756c

File tree

5 files changed

+6
-317
lines changed

5 files changed

+6
-317
lines changed

R/test_likelihoodratio.R

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -71,6 +71,9 @@ print.test_likelihoodratio <- function(x, digits = 2, ...) {
7171
if ("LogLik" %in% names(x)) {
7272
best <- which.max(x$LogLik)
7373
footer <- c(sprintf("\nModel '%s' seems to have the best model fit.\n", x$Model[best]), "yellow")
74+
} else if ("Dev" %in% names(x)) {
75+
best <- which.min(x$Dev)
76+
footer <- c(sprintf("\nModel '%s' seems to have the best model fit.\n", x$Name[best]), "yellow")
7477
} else {
7578
footer <- NULL
7679
}
@@ -118,10 +121,12 @@ test_likelihoodratio.ListNestedRegressions <- function(objects, estimator = "ML"
118121
} else {
119122
# lmtest::lrtest()
120123
lls <- sapply(objects, insight::get_loglikelihood, REML = REML, check_response = TRUE)
121-
chi2 <- abs(c(NA, -2 * diff(lls)))
124+
devs <- -2 * lls
125+
chi2 <- abs(c(NA, diff(devs)))
122126
p <- stats::pchisq(chi2, abs(dfs_diff), lower.tail = FALSE)
123127

124128
out <- data.frame(
129+
Dev = devs,
125130
df = dfs,
126131
df_diff = dfs_diff,
127132
Chi2 = chi2,

tests/testthat/_snaps/check_dag.md

Lines changed: 0 additions & 275 deletions
This file was deleted.

tests/testthat/_snaps/mclogit.md

Lines changed: 0 additions & 22 deletions
This file was deleted.

tests/testthat/_snaps/model_performance.rma.md

Lines changed: 0 additions & 7 deletions
This file was deleted.

tests/testthat/_snaps/nestedLogit.md

Lines changed: 0 additions & 12 deletions
This file was deleted.

0 commit comments

Comments
 (0)