Skip to content

Commit

Permalink
fix
Browse files Browse the repository at this point in the history
  • Loading branch information
strengejacke committed Nov 22, 2023
1 parent 8329231 commit 4df5682
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 5 deletions.
8 changes: 4 additions & 4 deletions R/r2.R
Original file line number Diff line number Diff line change
Expand Up @@ -496,11 +496,11 @@ r2.glmmTMB <- function(model, ci = NULL, tolerance = 1e-5, verbose = TRUE, ...)
if (!is.null(ci) && !is.na(ci)) {
return(.r2_ci(model, ci = ci, ...))
}
mi <- insight::model_info(model, verbose = FALSE)
if (mi$is_linear) {
info <- insight::model_info(model, verbose = FALSE)
if (info$is_linear) {
out <- .safe(.r2_lm_manual(model))
} else if (mi$is_logit && mi$is_bernoulli) {
out <- list(R2_Tjur = r2_tjur(model, model_info = mi, ...))
} else if (info$is_logit && info$is_bernoulli) {
out <- list(R2_Tjur = r2_tjur(model, model_info = info, ...))
attr(out, "model_type") <- "Logistic"
names(out$R2_Tjur) <- "Tjur's R2"
class(out) <- c("r2_pseudo", class(out))
Expand Down
2 changes: 1 addition & 1 deletion R/r2_nagelkerke.R
Original file line number Diff line number Diff line change
Expand Up @@ -96,7 +96,7 @@ r2_nagelkerke.glmmTMB <- function(model, verbose = TRUE, ...) {
return(NULL)
}
null_dev <- stats::deviance(insight::null_model(model))
r2_cox <- (1 - exp((dev - null_dev) / insight::n_obs(model, disaggregate = TRUE)))
r2cox <- (1 - exp((dev - null_dev) / insight::n_obs(model, disaggregate = TRUE)))
if (is.na(r2cox) || is.null(r2cox)) {
return(NULL)
}
Expand Down

0 comments on commit 4df5682

Please sign in to comment.