Skip to content

Commit

Permalink
fixes
Browse files Browse the repository at this point in the history
  • Loading branch information
strengejacke committed Feb 5, 2024
1 parent dcbc21e commit 43c71b1
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 5 deletions.
5 changes: 5 additions & 0 deletions R/check_collinearity.R
Original file line number Diff line number Diff line change
Expand Up @@ -487,6 +487,11 @@ check_collinearity.zerocount <- function(x,
result <- vector("numeric")
na_terms <- vector("numeric")

# sanity check - models with offset(?) may contain too many term assignments
if (length(term_assign) > ncol(v)) {
term_assign <- term_assign[seq_len(ncol(v))]

Check warning on line 492 in R/check_collinearity.R

View check run for this annotation

Codecov / codecov/patch

R/check_collinearity.R#L492

Added line #L492 was not covered by tests
}

for (term in 1:n.terms) {
subs <- which(term_assign == term)
if (length(subs)) {
Expand Down
18 changes: 13 additions & 5 deletions R/check_model_diagnostics.R
Original file line number Diff line number Diff line change
Expand Up @@ -296,11 +296,19 @@

# data for negative binomial models
if (faminfo$is_negbin && !faminfo$is_zero_inflated) {
d <- data.frame(Predicted = stats::predict(model, type = "response"))
d$Residuals <- insight::get_response(model) - as.vector(d$Predicted)
d$Res2 <- d$Residuals^2
d$V <- d$Predicted * (1 + d$Predicted / insight::get_sigma(model))
d$StdRes <- insight::get_residuals(model, type = "pearson")
if (inherits(model, "glmmTMB")) {
d <- data.frame(Predicted = stats::predict(model, type = "response"))
d$Residuals <- insight::get_residuals(model, type = "pearson")
d$Res2 <- d$Residuals^2
d$V <- insight::get_sigma(model)^2 * stats::family(model)$variance(d$Predicted)
d$StdRes <- insight::get_residuals(model, type = "pearson")

Check warning on line 304 in R/check_model_diagnostics.R

View check run for this annotation

Codecov / codecov/patch

R/check_model_diagnostics.R#L299-L304

Added lines #L299 - L304 were not covered by tests
} else {
d <- data.frame(Predicted = stats::predict(model, type = "response"))
d$Residuals <- insight::get_response(model) - as.vector(d$Predicted)
d$Res2 <- d$Residuals^2
d$V <- d$Predicted * (1 + d$Predicted / insight::get_sigma(model))
d$StdRes <- insight::get_residuals(model, type = "pearson")

Check warning on line 310 in R/check_model_diagnostics.R

View check run for this annotation

Codecov / codecov/patch

R/check_model_diagnostics.R#L306-L310

Added lines #L306 - L310 were not covered by tests
}
}

# data for zero-inflated poisson models
Expand Down

0 comments on commit 43c71b1

Please sign in to comment.