Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Revising check_model() #698

Open
wants to merge 25 commits into
base: main
Choose a base branch
from
Open
Changes from all commits
Commits
Show all changes
25 commits
Select commit Hold shift + click to select a range
cb26681
Revising `check_model()`
strengejacke Mar 18, 2024
8137ac3
docs
strengejacke Mar 18, 2024
3b72ffa
Merge branch 'main' into strengejacke/issue697
strengejacke Mar 19, 2024
dcd6139
Merge branch 'main' into strengejacke/issue697
strengejacke Mar 24, 2024
0936c5e
version bump
strengejacke Mar 25, 2024
2e8636f
Merge branch 'main' into strengejacke/issue697
strengejacke Mar 26, 2024
cc913ac
Merge branch 'main' into strengejacke/issue697
strengejacke Mar 26, 2024
d10c7c6
version
strengejacke Mar 26, 2024
6518a4d
debug mode
strengejacke Mar 26, 2024
0e29423
Merge branch 'main' into strengejacke/issue697
strengejacke Mar 27, 2024
1ac50ea
Merge branch 'main' into strengejacke/issue697
strengejacke Mar 30, 2024
7eb41af
Merge branch 'main' into strengejacke/issue697
strengejacke Apr 1, 2024
535c419
Merge branch 'main' into strengejacke/issue697
strengejacke Apr 5, 2024
c1eaa76
Merge branch 'main' into strengejacke/issue697
strengejacke Apr 29, 2024
5fa72a2
Merge branch 'main' into strengejacke/issue697
strengejacke Apr 29, 2024
dda4683
Merge branch 'main' into strengejacke/issue697
strengejacke Jun 5, 2024
17b81ee
Merge branch 'main' into strengejacke/issue697
strengejacke Jun 7, 2024
29e27bb
Merge branch 'main' into strengejacke/issue697
strengejacke Jun 18, 2024
e1082a9
Merge branch 'main' into strengejacke/issue697
strengejacke Jul 13, 2024
2c61214
Merge branch 'main' into strengejacke/issue697
strengejacke Jul 13, 2024
2be53b8
Merge branch 'main' into strengejacke/issue697
strengejacke Jul 14, 2024
20087d6
Merge branch 'main' into strengejacke/issue697
strengejacke Jul 18, 2024
7cd93a8
Merge branch 'main' into strengejacke/issue697
strengejacke Sep 23, 2024
a8aa04d
Merge branch 'main' into strengejacke/issue697
strengejacke Oct 22, 2024
af17c05
Merge branch 'main' into strengejacke/issue697
strengejacke Nov 24, 2024
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
19 changes: 18 additions & 1 deletion R/check_model_diagnostics.R
Original file line number Diff line number Diff line change
Expand Up @@ -300,10 +300,20 @@
predicted <- simres$fittedPredictedResponse
d <- data.frame(Predicted = predicted)

# extract sigma, we scale the residuals by dividing by sigma
sig <- if (faminfo$is_mixed) {
sqrt(insight::get_variance_residual(model))
} else if (inherits(model, "glmmTMB")) {
.sigma_glmmTMB_nonmixed(model, faminfo)
} else {
insight::get_sigma(model)
}

# residuals based on simulated residuals - but we want normally distributed residuals
d$Residuals <- stats::residuals(simres, quantile_function = stats::qnorm, ...)
d$Res2 <- d$Residuals^2
d$StdRes <- insight::get_residuals(model, type = "pearson")
# d$StdRes <- insight::get_residuals(model, type = "pearson")
d$StdRes <- d$Residuals / sig

# data for poisson models
if (faminfo$is_poisson && !faminfo$is_zero_inflated) {
Expand Down Expand Up @@ -368,6 +378,13 @@


.model_diagnostic_overdispersion <- function(model, ...) {
## TODO: remove this code later -it's just to test the ".new_diag_overdispersion"
## function. Set options(performance_new_overdispersion = TRUE) to use the new
## function.
if (isTRUE(getOption("performance_new_overdispersion"))) {
return(.new_diag_overdispersion(model, ...))
}

faminfo <- insight::model_info(model)

# data for poisson models
Expand Down
Loading