Skip to content

Commit

Permalink
lintr, examples
Browse files Browse the repository at this point in the history
  • Loading branch information
strengejacke committed Sep 14, 2023
1 parent a4cabd8 commit 99892bb
Show file tree
Hide file tree
Showing 4 changed files with 18 additions and 10 deletions.
8 changes: 5 additions & 3 deletions R/r2_bayes.R
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,9 @@
#' @examples
#' library(performance)
#' if (require("rstanarm") && require("rstantools")) {
#' model <- stan_glm(mpg ~ wt + cyl, data = mtcars, chains = 1, iter = 500, refresh = 0)
#' model <- suppressWarnings(
#' stan_glm(mpg ~ wt + cyl, data = mtcars, chains = 1, iter = 500, refresh = 0)
#' )
#' r2_bayes(model)
#'
#' model <- stan_lmer(
Expand Down Expand Up @@ -424,10 +426,10 @@ as.data.frame.r2_bayes <- function(x, ...) {
residuals.BFBayesFactor <- function(object, ...) {
everything_we_need <- .get_bfbf_predictions(object, verbose = FALSE)

everything_we_need[["y"]] - apply(everything_we_need[["y_pred"]], 2, mean)
everything_we_need[["y"]] - colMeans(everything_we_need[["y_pred"]])
}

#' @export
fitted.BFBayesFactor <- function(object, ...) {
apply(.get_bfbf_predictions(object, verbose = FALSE)[["y_pred"]], 2, mean)
colMeans(.get_bfbf_predictions(object, verbose = FALSE)[["y_pred"]])
}
8 changes: 5 additions & 3 deletions R/r2_loo.R
Original file line number Diff line number Diff line change
Expand Up @@ -20,9 +20,9 @@
#' leave-one-out-adjusted posterior distribution. This is conceptually similar
#' to an adjusted/unbiased R2 estimate in classical regression modeling. See
#' [r2_bayes()] for an "unadjusted" R2.
#' \cr \cr
#'
#' Mixed models are not currently fully supported.
#' \cr \cr
#'
#' `r2_loo_posterior()` is the actual workhorse for `r2_loo()` and
#' returns a posterior sample of LOO-adjusted Bayesian R2 values.
#'
Expand All @@ -31,7 +31,9 @@
#'
#' @examples
#' if (require("rstanarm")) {
#' model <- stan_glm(mpg ~ wt + cyl, data = mtcars, chains = 1, iter = 500, refresh = 0)
#' model <- suppressWarnings(
#' stan_glm(mpg ~ wt + cyl, data = mtcars, chains = 1, iter = 500, refresh = 0)
#' )
#' r2_loo(model)
#' }
#' @export
Expand Down
4 changes: 3 additions & 1 deletion man/r2_bayes.Rd

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

8 changes: 5 additions & 3 deletions man/r2_loo.Rd

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

0 comments on commit 99892bb

Please sign in to comment.