Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
  • Loading branch information
strengejacke committed Aug 19, 2021
1 parent 99edf5b commit a10448c
Show file tree
Hide file tree
Showing 3 changed files with 63 additions and 0 deletions.
2 changes: 2 additions & 0 deletions NAMESPACE
Original file line number Diff line number Diff line change
Expand Up @@ -34,8 +34,10 @@ S3method(check_distribution,numeric)
S3method(check_heteroscedasticity,default)
S3method(check_homogeneity,afex_aov)
S3method(check_homogeneity,default)
S3method(check_model,brmsfit)
S3method(check_model,default)
S3method(check_model,model_fit)
S3method(check_model,stanreg)
S3method(check_multimodal,data.frame)
S3method(check_multimodal,numeric)
S3method(check_normality,afex_aov)
Expand Down
54 changes: 54 additions & 0 deletions R/check_model.R
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,12 @@
#' to the dedicated functions (like `check_collinearity()`,
#' `check_normality()` etc.) to get informative messages and warnings.
#'
#' @details For Bayesian models from packages **rstanarm** or **brms**,
#' models will be "converted" to their frequentist counterpart, using
#' [`bayestestR::bayesian_as_frequentist`](https://easystats.github.io/bayestestR/reference/convert_bayesian_as_frequentist.html).
#' A more advanced model-check for Bayesian models will be implemented at a
#' later stage.
#'
#' @section Linearity Assumption:
#' The plot **Linearity** checks the assumption of linear relationship.
#' However, the spread of dots also indicate possible heteroscedasticity (i.e.
Expand Down Expand Up @@ -124,14 +130,54 @@ check_model.default <- function(x,
}


## TODO for now, convert to freq, see https://github.com/easystats/performance/issues/354
## need to fix this later

#' @export
check_model.stanreg <- function(x,
dot_size = 2,
line_size = .8,
panel = TRUE,
check = "all",
alpha = .2,
dot_alpha = .8,
colors = c("#3aaf85", "#1b6ca8", "#cd201f"),
theme = "see::theme_lucid",
detrend = FALSE,
verbose = TRUE,
...) {
check_model(bayestestR::bayesian_as_frequentist(x),
dot_size = dot_size,
line_size = line_size,
panel = panel,
check = check,
alpha = alpha,
dot_alpha = dot_alpha,
colors = colors,
theme = theme,
detrend = detrend,
verbose = verbose,
...)
}



#' @export
check_model.brmsfit <- check_model.stanreg


#' @export
check_model.model_fit <- function(x,
dot_size = 2,
line_size = .8,
panel = TRUE,
check = "all",
alpha = .2,
dot_alpha = .8,
colors = c("#3aaf85", "#1b6ca8", "#cd201f"),
theme = "see::theme_lucid",
detrend = FALSE,
verbose = TRUE,
...) {
check_model(
x$fit,
Expand All @@ -140,7 +186,11 @@ check_model.model_fit <- function(x,
panel = panel,
check = check,
alpha = alpha,
dot_alpha = dot_alpha,
colors = colors,
theme = theme,
detrend = detrend,
verbose = verbose,
...
)
}
Expand All @@ -149,6 +199,10 @@ check_model.model_fit <- function(x,




# helper ------------------------


.check_assumptions_linear <- function(model, model_info) {
dat <- list()

Expand Down
7 changes: 7 additions & 0 deletions man/check_model.Rd

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

0 comments on commit a10448c

Please sign in to comment.