Skip to content

Commit

Permalink
examplesIf
Browse files Browse the repository at this point in the history
  • Loading branch information
strengejacke committed Sep 14, 2023
1 parent cf2f2f5 commit c602602
Show file tree
Hide file tree
Showing 4 changed files with 62 additions and 48 deletions.
14 changes: 9 additions & 5 deletions R/looic.R
Original file line number Diff line number Diff line change
Expand Up @@ -11,11 +11,15 @@
#'
#' @return A list with four elements, the ELPD, LOOIC and their standard errors.
#'
#' @examples
#' if (require("rstanarm")) {
#' model <- stan_glm(mpg ~ wt + cyl, data = mtcars, chains = 1, iter = 500, refresh = 0)
#' looic(model)
#' }
#' @examplesIf require("rstanarm")
#' model <- rstanarm::stan_glm(
#' mpg ~ wt + cyl,
#' data = mtcars,
#' chains = 1,
#' iter = 500,
#' refresh = 0
#' )
#' looic(model)
#' @export
looic <- function(model, verbose = TRUE) {
insight::check_if_installed("loo")
Expand Down
41 changes: 21 additions & 20 deletions R/model_performance.bayesian.R
Original file line number Diff line number Diff line change
Expand Up @@ -40,30 +40,31 @@
#'
#' - **PCP**: percentage of correct predictions, see [performance_pcp()].
#'
#' @examples
#' @examplesIf require("rstanarm") && require("rstantools") && require("BayesFactor")
#' \dontrun{
#' if (require("rstanarm") && require("rstantools")) {
#' model <- stan_glm(mpg ~ wt + cyl, data = mtcars, chains = 1, iter = 500, refresh = 0)
#' model_performance(model)
#' model <- rstanarm::stan_glm(
#' mpg ~ wt + cyl,
#' data = mtcars,
#' chains = 1,
#' iter = 500,
#' refresh = 0
#' )
#' model_performance(model)
#'
#' model <- stan_glmer(
#' mpg ~ wt + cyl + (1 | gear),
#' data = mtcars,
#' chains = 1,
#' iter = 500,
#' refresh = 0
#' )
#' model_performance(model)
#' }
#'
#' if (require("BayesFactor") && require("rstantools")) {
#' model <- generalTestBF(carb ~ am + mpg, mtcars)
#' model <- stan_glmer(
#' mpg ~ wt + cyl + (1 | gear),
#' data = mtcars,
#' chains = 1,
#' iter = 500,
#' refresh = 0
#' )
#' model_performance(model)
#'
#' model_performance(model)
#' model_performance(model[3])
#' model <- generalTestBF(carb ~ am + mpg, mtcars)
#'
#' model_performance(model, average = TRUE)
#' }
#' model_performance(model)
#' model_performance(model[3])
#' model_performance(model, average = TRUE)
#' }
#' @seealso [r2_bayes]
#' @references Gelman, A., Goodrich, B., Gabry, J., and Vehtari, A. (2018).
Expand Down
14 changes: 10 additions & 4 deletions man/looic.Rd

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

41 changes: 22 additions & 19 deletions man/model_performance.stanreg.Rd

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

0 comments on commit c602602

Please sign in to comment.