-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Make extract_samples a method of coevfit
- Loading branch information
1 parent
106cc38
commit fd0e063
Showing
5 changed files
with
26 additions
and
38 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 was deleted.
Oops, something went wrong.
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,19 @@ | ||
#' Extract samples (draws) from a fitted \code{coevfit} object | ||
#' | ||
#' @param object An object of class \code{coevfit} | ||
#' | ||
#' @return Samples in 'rethinking' style list format | ||
#' @export | ||
extract_samples <- function(object) { | ||
UseMethod("extract_samples") | ||
} | ||
|
||
#' @export | ||
extract_samples.coevfit <- function(object) { | ||
vars <- object$fit$metadata()$stan_variables | ||
draws <- posterior::as_draws_rvars(object$fit$draws()) | ||
|
||
return(lapply(vars, \(var_name){ | ||
posterior::draws_of(draws[[var_name]], with_chains = FALSE) | ||
}) |> setNames(vars)) | ||
} |
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.