-
-
Notifications
You must be signed in to change notification settings - Fork 69
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
7c948b1
commit 02223d2
Showing
10 changed files
with
557 additions
and
117 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,63 @@ | ||
#' Report priors of Bayesian models | ||
#' | ||
#' Reports priors of Bayesian models (see list of supported objects in \code{\link{report}}). | ||
#' | ||
#' @inheritParams report | ||
#' @inheritParams report_table | ||
#' @inheritParams report_text | ||
#' @inheritParams as.report | ||
#' | ||
#' @return A \code{character} string. | ||
#' | ||
#' @examples | ||
#' library(report) | ||
#' | ||
#' # Bayesian models | ||
#' if(require("rstanarm")){ | ||
#' model <- stan_glm(mpg ~ disp, data = mtcars, refresh=0, iter=1000) | ||
#' r <- report_priors(model) | ||
#' r | ||
#' summary(r) | ||
#' } | ||
#' @export | ||
report_priors <- function(x, ...) { | ||
UseMethod("report_priors") | ||
} | ||
|
||
|
||
#' @export | ||
report_priors.default <- function(x, ...) { | ||
stop(paste0("report_priors() is not available for objects of class ", class(x))) | ||
} | ||
|
||
# METHODS ----------------------------------------------------------------- | ||
|
||
|
||
#' @rdname as.report | ||
#' @export | ||
as.report_priors <- function(x, summary = NULL, ...) { | ||
class(x) <- unique(c("report_priors", class(x))) | ||
attributes(x) <- c(attributes(x), list(...)) | ||
|
||
if (!is.null(summary)) { | ||
attr(x, "summary") <- summary | ||
} | ||
x | ||
} | ||
|
||
|
||
#' @export | ||
summary.report_priors <- function(object, ...) { | ||
if(is.null(attributes(object)$summary)){ | ||
object | ||
} else{ | ||
attributes(object)$summary | ||
} | ||
} | ||
|
||
#' @export | ||
print.report_priors <- function(x, ...) { | ||
cat(paste0(x, collapse = "\n")) | ||
} | ||
|
||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.