Title: | R functionality for posteriordb |
---|---|
Description: | R functionality of easy handling of the posteriordb posteriors. |
Authors: | Mans Magnusson [cre, aut], Paul-Christian Bürkner [aut], Aki Vehtari [aut] |
Maintainer: | Mans Magnusson <[email protected]> |
License: | BSD_3_clause + file LICENSE |
Version: | 0.3.2 |
Built: | 2024-08-18 05:19:10 UTC |
Source: | https://github.com/stan-dev/posteriordb-r |
Get all existing alias names from a posterior database
alias_names(type, pdb = pdb_default())
alias_names(type, pdb = pdb_default())
type |
type of alias names. Cureently only posteriors. |
pdb |
a |
Coerce a [pdb_posterior] to a Data Frame
## S3 method for class 'pdb_posterior' as.data.frame(x, row.names = NULL, optional = FALSE, ...) ## S3 method for class 'pdb_posteriors' as.data.frame(x, row.names = NULL, optional = FALSE, ...)
## S3 method for class 'pdb_posterior' as.data.frame(x, row.names = NULL, optional = FALSE, ...) ## S3 method for class 'pdb_posteriors' as.data.frame(x, row.names = NULL, optional = FALSE, ...)
x |
a [pdb_posterior] object. |
row.names |
NULL or a character vector giving the row names for the data frame. Missing values are not allowed. |
optional |
Not used. |
... |
further arguments to |
The dataframe will consist of one row per keyword.
Reference Posterior draws and summary statistics
## S3 method for class 'stanfit' as.reference_posterior_draws(x, info, pdb = pdb_default(), ...) reference_posterior_draws(x, ...) as.reference_posterior_draws(x, ...) pdb_reference_posterior_draws(x, ...) as.pdb_reference_posterior_draws(x, ...) ## S3 method for class 'character' reference_posterior_draws(x, pdb = pdb_default(), ...) ## S3 method for class 'pdb_posterior' reference_posterior_draws(x, ...) ## S3 method for class 'pdb_reference_posterior_info' reference_posterior_draws(x, pdb = pdb_default(), ...) ## S3 method for class 'draws_list' as.reference_posterior_draws(x, info, ...) assert_reference_posterior_draws(x)
## S3 method for class 'stanfit' as.reference_posterior_draws(x, info, pdb = pdb_default(), ...) reference_posterior_draws(x, ...) as.reference_posterior_draws(x, ...) pdb_reference_posterior_draws(x, ...) as.pdb_reference_posterior_draws(x, ...) ## S3 method for class 'character' reference_posterior_draws(x, pdb = pdb_default(), ...) ## S3 method for class 'pdb_posterior' reference_posterior_draws(x, ...) ## S3 method for class 'pdb_reference_posterior_info' reference_posterior_draws(x, pdb = pdb_default(), ...) ## S3 method for class 'draws_list' as.reference_posterior_draws(x, info, ...) assert_reference_posterior_draws(x)
x |
a [posterior] object or a posterior name. |
info |
a [pdb_reference_posterior_info] object |
pdb |
a [pdb] object (if [x] is a posterior name) |
... |
further arguments supplied to specific methods. |
a [pdb_reference_posterior] object.
Assert that all checks of the reference posterior draws are true
assert_checked_reference_posterior_draws(x) ## S3 method for class 'pdb_reference_posterior_draws' assert_checked_reference_posterior_draws(x) ## S3 method for class 'pdb_reference_posterior_info' assert_checked_reference_posterior_draws(x) assert_checked_summary_statistics_draws(x) ## S3 method for class 'pdb_reference_posterior_draws' assert_checked_summary_statistics_draws(x) ## S3 method for class 'pdb_reference_posterior_summary_statistic' assert_checked_summary_statistics_draws(x) ## S3 method for class 'pdb_reference_posterior_info' assert_checked_summary_statistics_draws(x)
assert_checked_reference_posterior_draws(x) ## S3 method for class 'pdb_reference_posterior_draws' assert_checked_reference_posterior_draws(x) ## S3 method for class 'pdb_reference_posterior_info' assert_checked_reference_posterior_draws(x) assert_checked_summary_statistics_draws(x) ## S3 method for class 'pdb_reference_posterior_draws' assert_checked_summary_statistics_draws(x) ## S3 method for class 'pdb_reference_posterior_summary_statistic' assert_checked_summary_statistics_draws(x) ## S3 method for class 'pdb_reference_posterior_info' assert_checked_summary_statistics_draws(x)
x |
a [pdb_reference_posterior_draws] object |
This functionasserts that the reference posterior draws comply with the criterias of the reference posterior draws.
See https://github.com/stan-dev/posteriordb/blob/master/doc/REFERENCE_POSTERIOR_DEFINITION.md for details.
Get the bibliography of a posterior database
bibliography(pdb, ...) pdb_bibliography(pdb, ...)
bibliography(pdb, ...) pdb_bibliography(pdb, ...)
pdb |
a posterior database connection |
... |
further arguments passed to [bibtex::read.bib] |
Check the content a posterior database
check_pdb( pdb, posterior_names_to_check = NULL, run_stan_code_checks = FALSE, verbose = TRUE ) check_pdb_read_model_code(posterior_list) check_pdb_aliases(pdb) check_pdb_read_data(posterior_list) check_pdb_read_reference_posterior_draws(posterior_list) check_pdb_posterior_run_stan(po) check_pdb_references(pdb) check_pdb_posterior_references(posterior_list) check_pdb_all_models_have_posterior(pdb) check_pdb_all_data_have_posterior(pdb) check_pdb_all_reference_posteriors_have_posterior(pdb)
check_pdb( pdb, posterior_names_to_check = NULL, run_stan_code_checks = FALSE, verbose = TRUE ) check_pdb_read_model_code(posterior_list) check_pdb_aliases(pdb) check_pdb_read_data(posterior_list) check_pdb_read_reference_posterior_draws(posterior_list) check_pdb_posterior_run_stan(po) check_pdb_references(pdb) check_pdb_posterior_references(posterior_list) check_pdb_all_models_have_posterior(pdb) check_pdb_all_data_have_posterior(pdb) check_pdb_all_reference_posteriors_have_posterior(pdb)
pdb |
a |
posterior_names_to_check |
an vector indicating what posteriors to check in the pdb. Default is NULL (all). |
run_stan_code_checks |
should checks using Stan be run? |
verbose |
should check results be printed? |
posterior_list |
a list of |
po |
a |
[check_pdb()] checks that the content exists as specified [check_pdb_run_stan()] test to run all posteriors with stan models. [check_pdb_stan_syntax()] check that all stan model code files can be parsed. [check_pdb_aliases()] check that all alias are correct. [check_pdb_read_model_code()] check that posteriors can be read. [check_pdb_posteriors()] check a vector of posterior names. [check_pdb_references()] check that all references in posteriors also exist in bibtex. [check_pdb_all_models_have_posterior()] check that all models belong to a posterior [check_pdb_all_data_have_posterior()] check that all datasets belong to a posterior [check_pdb_all_reference_posteriors_have_posterior()] check that all reference posteriors belong to a posterior
a boolean indicating if the pdb works as it should.
Test a posterior
check_pdb_posterior(po, run_stan_code_checks = TRUE, verbose = TRUE)
check_pdb_posterior(po, run_stan_code_checks = TRUE, verbose = TRUE)
po |
a [pdb_posterior] to check. |
run_stan_code_checks |
should checks using Stan be run? |
verbose |
should check results be printed? |
The function checks that a posterior is consistent.
Check that reference posterior draws follows the reference posterior draws definition.
check_reference_posterior_draws(x, ...) ## S3 method for class 'character' check_reference_posterior_draws(x, ...) ## S3 method for class 'pdb_posterior' check_reference_posterior_draws(x, ...) ## S3 method for class 'pdb_reference_posterior_draws' check_reference_posterior_draws(x, ...)
check_reference_posterior_draws(x, ...) ## S3 method for class 'character' check_reference_posterior_draws(x, ...) ## S3 method for class 'pdb_posterior' check_reference_posterior_draws(x, ...) ## S3 method for class 'pdb_reference_posterior_draws' check_reference_posterior_draws(x, ...)
x |
a posterior name, posterior object or reference_posterior_draws object |
... |
currently not used. |
Check that reference posterior draws follows the reference posterior summary definition.
check_summary_statistics_draws(x, ...) ## S3 method for class 'character' check_summary_statistics_draws(x, ...) ## S3 method for class 'pdb_posterior' check_summary_statistics_draws(x, ...) ## S3 method for class 'pdb_reference_posterior_draws' check_summary_statistics_draws(x, ...)
check_summary_statistics_draws(x, ...) ## S3 method for class 'character' check_summary_statistics_draws(x, ...) ## S3 method for class 'pdb_posterior' check_summary_statistics_draws(x, ...) ## S3 method for class 'pdb_reference_posterior_draws' check_summary_statistics_draws(x, ...)
x |
a posterior name, posterior object or reference_posterior_draws object |
... |
currently not used. |
Compute a Reference Posteriors for a reference posterior info object
compute_reference_posterior_draws(rpi, pdb = pdb_default())
compute_reference_posterior_draws(rpi, pdb = pdb_default())
rpi |
a [reference_posterior_info] object. |
pdb |
a [pdb] object. |
Compute a Reference Posteriors using Rstan
compute_reference_posterior_draws_stan_sampling(rpi, pdb)
compute_reference_posterior_draws_stan_sampling(rpi, pdb)
rpi |
a [reference_posterior_info] object. |
pdb |
a [pdb] object. |
Compute Summary statistics from a reference posterior
compute_reference_posterior_summary_statistic(rpd, summary_statistic = "mean") compute_summary_statistic(rpd, summary_statistic = "mean")
compute_reference_posterior_summary_statistic(rpd, summary_statistic = "mean") compute_summary_statistic(rpd, summary_statistic = "mean")
rpd |
a [reference_posterior_summary_statistic] object |
summary_statistic |
summary statistic to compute |
Extract data for posterior
data_file_path(x, ...) stan_data_file_path(x, ...) stan_data(x)
data_file_path(x, ...) stan_data_file_path(x, ...) stan_data(x)
x |
an object to access file path to. |
... |
further arguments supplied to methods. |
Access data and model information
data_info(x, ...) as.data_info(x, ...) ## S3 method for class 'pdb_posterior' data_info(x, ...) ## S3 method for class 'character' data_info(x, pdb = pdb_default(), ...) ## S3 method for class 'list' as.data_info(x, pdb = NULL, ...) pdb_data_info(x, ...) as.pdb_data_info(x, ...) model_info(x, ...) as.model_info(x, ...) pdb_model_info(x, ...) as.pdb_model_info(x, ...) ## S3 method for class 'pdb_posterior' model_info(x, ...) ## S3 method for class 'character' model_info(x, pdb = pdb_default(), ...) ## S3 method for class 'list' as.model_info(x, pdb = NULL, ...)
data_info(x, ...) as.data_info(x, ...) ## S3 method for class 'pdb_posterior' data_info(x, ...) ## S3 method for class 'character' data_info(x, pdb = pdb_default(), ...) ## S3 method for class 'list' as.data_info(x, pdb = NULL, ...) pdb_data_info(x, ...) as.pdb_data_info(x, ...) model_info(x, ...) as.model_info(x, ...) pdb_model_info(x, ...) as.pdb_model_info(x, ...) ## S3 method for class 'pdb_posterior' model_info(x, ...) ## S3 method for class 'character' model_info(x, pdb = pdb_default(), ...) ## S3 method for class 'list' as.model_info(x, pdb = NULL, ...)
x |
a object to access information for. |
... |
further arguments to methods. |
pdb |
a |
Get all existing data names from a posterior database
data_names(pdb = pdb_default(), ...) ## S3 method for class 'pdb_local' data_names(pdb = pdb_default(), ...) ## S3 method for class 'pdb_github' data_names(pdb, ...) ## S3 method for class 'pdb_github' model_names(pdb, ...) ## S3 method for class 'pdb_github' reference_posterior_names(pdb, ...)
data_names(pdb = pdb_default(), ...) ## S3 method for class 'pdb_local' data_names(pdb = pdb_default(), ...) ## S3 method for class 'pdb_github' data_names(pdb, ...) ## S3 method for class 'pdb_github' model_names(pdb, ...) ## S3 method for class 'pdb_github' reference_posterior_names(pdb, ...)
pdb |
a |
... |
Further argument to methods. |
Filter Posteriors in Database
filter_posteriors(pdb = pdb_default(), ...)
filter_posteriors(pdb = pdb_default(), ...)
pdb |
a |
... |
further arguments to supply to |
Filter posteriors in the database and return list of posteriors/models/data to work with as a list.
The function is built upon the dplyr filter function and follows the exact same syntax. All elements in the 'posteriors/[posterior_name].json', 'models/info/[model_name].json' and 'data/info/[data_name].json' can be used to filter the posterior database. See examples below.
Identify the framework for a given [model_code]
framework(x) ## S3 method for class 'pdb_model_code' framework(x) framework(x) <- value ## S3 replacement method for class 'character' framework(x) <- value ## S3 replacement method for class 'pdb_model_code' framework(x) <- value
framework(x) ## S3 method for class 'pdb_model_code' framework(x) framework(x) <- value ## S3 replacement method for class 'character' framework(x) <- value ## S3 replacement method for class 'pdb_model_code' framework(x) <- value
x |
a [pdb_model_code] object. |
value |
a supported framework. |
Posterior Data Sets
get_data(x, ...) as.pdb_data(x, ...) ## S3 method for class 'pdb_posterior' get_data(x, ...) ## S3 method for class 'character' get_data(x, pdb = pdb_default(), ...) ## S3 method for class 'pdb_data_info' get_data(x, pdb = pdb_default(), ...) ## S3 method for class 'list' as.pdb_data(x, info, ...) pdb_data(x, ...)
get_data(x, ...) as.pdb_data(x, ...) ## S3 method for class 'pdb_posterior' get_data(x, ...) ## S3 method for class 'character' get_data(x, pdb = pdb_default(), ...) ## S3 method for class 'pdb_data_info' get_data(x, pdb = pdb_default(), ...) ## S3 method for class 'list' as.pdb_data(x, info, ...) pdb_data(x, ...)
x |
an object to access data from. |
... |
Currently not used. |
pdb |
a |
info |
a |
A github personal access token Looks in env var 'GITHUB_PAT'
github_pat(pdb = NULL)
github_pat(pdb = NULL)
pdb |
A posterior datasbase object to extract pat from. |
Return the name that the alias points to
handle_aliases(x, type, pdb)
handle_aliases(x, type, pdb)
x |
a name to lookup in alias list |
type |
type of alias names. Cureently only posteriors. |
pdb |
a |
Extract information from a pdb object
info(x)
info(x)
x |
a [pdb_data], [pdb_model_code] and [pdb_reference_posterior] |
info |
a [pdb_] |
Set information to a pdb object
info(x) <- value
info(x) <- value
x |
a [pdb_data], [pdb_model_code] and [pdb_reference_posterior] |
value |
an info object |
Extract and construct model code objects
model_code(x, ...) as.model_code(x, info, ...) ## S3 method for class 'pdb_posterior' model_code(x, framework, ...) ## S3 method for class 'character' model_code(x, framework, pdb = pdb_default(), ...) ## S3 method for class 'pdb_model_info' model_code(x, framework, pdb = pdb_default(), ...) ## S3 method for class 'stanmodel' as.model_code(x, info, ...) ## S3 method for class 'character' as.model_code(x, info, framework, ...) pdb_model_code(x, ...) as.pdb_model_code(x, info, ...) model_code_file_path(x, ...) ## S3 method for class 'pdb_posterior' model_code_file_path(x, framework, ...) ## S3 method for class 'pdb_model_info' model_code_file_path(x, framework, pdb = pdb_default(), ...) ## S3 method for class 'character' model_code_file_path(x, framework, pdb = pdb_default(), ...) stan_code_file_path(x) stan_code(x, ...) as.stan_code(x, info, ...) pdb_stan_code(x, ...)
model_code(x, ...) as.model_code(x, info, ...) ## S3 method for class 'pdb_posterior' model_code(x, framework, ...) ## S3 method for class 'character' model_code(x, framework, pdb = pdb_default(), ...) ## S3 method for class 'pdb_model_info' model_code(x, framework, pdb = pdb_default(), ...) ## S3 method for class 'stanmodel' as.model_code(x, info, ...) ## S3 method for class 'character' as.model_code(x, info, framework, ...) pdb_model_code(x, ...) as.pdb_model_code(x, info, ...) model_code_file_path(x, ...) ## S3 method for class 'pdb_posterior' model_code_file_path(x, framework, ...) ## S3 method for class 'pdb_model_info' model_code_file_path(x, framework, pdb = pdb_default(), ...) ## S3 method for class 'character' model_code_file_path(x, framework, pdb = pdb_default(), ...) stan_code_file_path(x) stan_code(x, ...) as.stan_code(x, info, ...) pdb_stan_code(x, ...)
x |
an object to access file path to. |
... |
further arguments supplied to methods. |
info |
a |
framework |
model code framework (e.g. |
pdb |
a |
framework()
Get all existing model names from a posterior database
model_names(pdb = pdb_default(), ...) ## S3 method for class 'pdb_local' model_names(pdb = pdb_default(), ...)
model_names(pdb = pdb_default(), ...) ## S3 method for class 'pdb_local' model_names(pdb = pdb_default(), ...)
pdb |
a |
... |
Further argument to methods. |
Extract aliases list from posterior database
pdb_aliases(type, pdb)
pdb_aliases(type, pdb)
type |
type of alias names. Cureently only posteriors. |
pdb |
a |
Assert that a file exists
pdb_assert_file_exist(pdb, path, ...) ## S3 method for class 'pdb_local' pdb_assert_file_exist(pdb, path, ...)
pdb_assert_file_exist(pdb, path, ...) ## S3 method for class 'pdb_local' pdb_assert_file_exist(pdb, path, ...)
pdb |
a |
path |
a |
... |
further arguments supplied to methods. |
Returns a writable cache path for a pdb and a path It will create the directory if it does not exist.
pdb_cache_path(pdb, path)
pdb_cache_path(pdb, path)
pdb |
a |
path |
a |
Remove object from cache
pdb_cache_rm(x, ...) ## S3 method for class 'pdb_reference_posterior_draws' pdb_cache_rm(x, ...) ## S3 method for class 'pdb_data' pdb_cache_rm(x, ...)
pdb_cache_rm(x, ...) ## S3 method for class 'pdb_reference_posterior_draws' pdb_cache_rm(x, ...) ## S3 method for class 'pdb_data' pdb_cache_rm(x, ...)
x |
an object to remove from cache |
... |
Currently not in use. |
path
Read json file from path
pdb_cached_local_file_path(pdb, path, unzip = FALSE)
pdb_cached_local_file_path(pdb, path, unzip = FALSE)
pdb |
a |
path |
a |
unzip |
if true, path is zipped and should be unzipped to cache. |
Copies the file to the cache and return path
Compare two stan models for the same data
pdb_compare_stan_models(po, new_stan_model_code_file, upar_values = NULL)
pdb_compare_stan_models(po, new_stan_model_code_file, upar_values = NULL)
po |
a 'pdb_posterior' object |
new_stan_model_code_file |
a file path to another stan code to compare with |
upar_values |
a list of values on the constrained space to use for comparisons. Defaults to 100 samples from a standard normal. |
Copy a file from a pdb to a local path
pdb_file_copy(pdb, from, to, overwrite = FALSE, ...) ## S3 method for class 'pdb_local' pdb_file_copy(pdb, from, to, overwrite = FALSE, ...) ## S3 method for class 'pdb_github' pdb_file_copy(pdb, from, to, overwrite = FALSE, ...)
pdb_file_copy(pdb, from, to, overwrite = FALSE, ...) ## S3 method for class 'pdb_local' pdb_file_copy(pdb, from, to, overwrite = FALSE, ...) ## S3 method for class 'pdb_github' pdb_file_copy(pdb, from, to, overwrite = FALSE, ...)
pdb |
a |
from |
a path in the pdb |
to |
a local file path |
overwrite |
overwrite local file. |
... |
further argument supplied to methods |
a boolean indicator as file.copy indicating success.
Create a Posterior Database (pdb) connection
pdb_local( path = getOption("pdb_path", Sys.getenv("PDB_PATH")), cache_path = tempdir() ) pdb(x, ...) ## Default S3 method: pdb(x, ...) ## S3 method for class 'pdb_model_code' pdb(x, ...) ## S3 method for class 'character' pdb(x, pdb_type = "local", cache_path = tempdir(), ...) pdb_default(cache_path = tempdir()) pdb_config(directory = getwd()) pdb_github( repo = getOption("pdb_repo", "stan-dev/posteriordb"), cache_path = tempdir(), ref = "master", subdir = NULL, auth_token = github_pat(), host = "https://api.github.com" )
pdb_local( path = getOption("pdb_path", Sys.getenv("PDB_PATH")), cache_path = tempdir() ) pdb(x, ...) ## Default S3 method: pdb(x, ...) ## S3 method for class 'pdb_model_code' pdb(x, ...) ## S3 method for class 'character' pdb(x, pdb_type = "local", cache_path = tempdir(), ...) pdb_default(cache_path = tempdir()) pdb_config(directory = getwd()) pdb_github( repo = getOption("pdb_repo", "stan-dev/posteriordb"), cache_path = tempdir(), ref = "master", subdir = NULL, auth_token = github_pat(), host = "https://api.github.com" )
path |
a local path to a posterior database. Defaults to 'pdb_path' option or PDB_PATH environment variable. |
cache_path |
The path to the pdb cache. Default is R temporary directory. This is used to store files locally and without affecting the database. |
x |
an object to access a pdb for, if character this is how to identify the pdb (path for local pdb, repo for github pdb) |
... |
further arguments for specific methods to setup a pdb. |
pdb_type |
Type of posterior database connection. Either |
directory |
the directory to look for the [.pdb_config.yml] file |
repo |
Repository address in the format 'username/repo[/subdir][@ref|#pull]'. Alternatively, you can specify 'subdir' and/or 'ref' using the respective parameters (see below); if both is specified, the values in 'repo' take precedence. |
ref |
Desired git reference. Could be a commit, tag, or branch name. Defaults to '"master"'. |
subdir |
subdirectory within repo that contains the posterior database. |
auth_token |
To use a private repo, generate a personal access token (PAT) in "https://github.com/settings/tokens" and supply to this argument. This is safer than using a password because you can easily delete a PAT without affecting any others. Defaults to the 'GITHUB_PAT' environment variable. |
host |
GitHub API host to use. Override with your GitHub enterprise hostname, for example, '"github.hostname.com/api/v3"'. |
Connect to a posterior database locally or in a github repo.
[pdb_config()] read [.pdb_config.yml] in [directory] and use that to setup a pdb connection.
The connection [pdb_default()] first checks if there exists a [.pdb_config.yml] file in the working directory. If it exist, [pdb_config()] is used to setup, the connection. If no [.pdb_config.yml] file is found, [pdb_local()] is used to setup a pdb. If no local pdb is found, [pdb_github()] is used.
a pdb
object
Extract relevant stan versions
pdb_stan_sampling_versions()
pdb_stan_sampling_versions()
pdb
Get version of the pdb
pdb_version(pdb, ...) ## S3 method for class 'pdb_local' pdb_version(pdb, ...) ## S3 method for class 'pdb_github' pdb_version(pdb, ...)
pdb_version(pdb, ...) ## S3 method for class 'pdb_local' pdb_version(pdb, ...) ## S3 method for class 'pdb_github' pdb_version(pdb, ...)
pdb |
a |
... |
Further argument to methods. |
the git sha for the posterior database.
Set pdb slot
pdb(x) <- value
pdb(x) <- value
x |
a [pdb_data], [pdb_model_code] and [pdb_reference_posterior] |
value |
a pdb object |
Access a posterior in the posterior database
posterior(x, pdb = pdb_default(), ...) as.posterior(x, pdb = pdb_default(), ...) ## S3 method for class 'character' posterior(x, pdb = pdb_default(), ...) ## S3 method for class 'list' as.posterior(x, pdb = pdb_default(), ...) pdb_posterior(x, pdb = pdb_default(), ...) as.pdb_posterior(x, pdb = pdb_default(), ...)
posterior(x, pdb = pdb_default(), ...) as.posterior(x, pdb = pdb_default(), ...) ## S3 method for class 'character' posterior(x, pdb = pdb_default(), ...) ## S3 method for class 'list' as.posterior(x, pdb = pdb_default(), ...) pdb_posterior(x, pdb = pdb_default(), ...) as.pdb_posterior(x, pdb = pdb_default(), ...)
x |
a posterior name that exist in the posterior database or a list used to construct a posterior object. |
pdb |
a |
... |
currently not in use. |
To setup a posterior object from a list, a minimum och a 'pdb_model', 'pdb_data', and a 'dimension' element need to be included. See 'posterior("eight_schools")$dimensions' for an example.
Construct dimension names from a posterior dimension list
posterior_dimension_names(x)
posterior_dimension_names(x)
x |
a dimensions slot from a [pdb_posterior] |
Get all existing posterior names from a posterior database or posterior objects.
posterior_names(x = pdb_default(), ...) posterior_name(x = pdb_default(), ...)
posterior_names(x = pdb_default(), ...) posterior_name(x = pdb_default(), ...)
x |
a |
... |
further arguments supplied to specific methods (not in use) |
If a pdb_model_code
or a pdb_data
object is supplied, the
function returns the name of all posteriors that uses the data or the model.
Create Posterior Database tibbles
posteriors_tbl_df(pdb = pdb_default(), ...)
posteriors_tbl_df(pdb = pdb_default(), ...)
pdb |
a |
... |
further arguments to supply to |
Generates a tibble data frame of all posteriors in the database and their side information
Read JSON objects from the posterior database
read_json_from_pdb(fn, path, pdb, ...)
read_json_from_pdb(fn, path, pdb, ...)
fn |
file name |
path |
path to file name in pdb |
pdb |
a [pdb] object |
... |
further arguments supplied to [jsonlite::read_json()] |
Extract data for posterior
reference_posterior_draws_file_path(x, ...) ## S3 method for class 'pdb_posterior' reference_posterior_draws_file_path(x, ...) ## S3 method for class 'character' reference_posterior_draws_file_path(x, pdb = pdb_default(), ...) ## S3 method for class 'pdb_reference_posterior_info' reference_posterior_draws_file_path(x, pdb = pdb_default(), ...)
reference_posterior_draws_file_path(x, ...) ## S3 method for class 'pdb_posterior' reference_posterior_draws_file_path(x, ...) ## S3 method for class 'character' reference_posterior_draws_file_path(x, pdb = pdb_default(), ...) ## S3 method for class 'pdb_reference_posterior_info' reference_posterior_draws_file_path(x, pdb = pdb_default(), ...)
x |
an object to access file path to. |
... |
further arguments supplied to methods. |
pdb |
a |
Reference posterior information
reference_posterior_info(x, type, pdb = pdb_default(), ...) as.reference_posterior_info(x, type, pdb = pdb_default(), ...) pdb_reference_posterior_info(x, type, pdb = pdb_default(), ...) as.pdb_reference_posterior_info(x, type, pdb = pdb_default(), ...) reference_posterior_draws_info(x, pdb = pdb_default(), ...) pdb_reference_posterior_draws_info(x, pdb = pdb_default(), ...) ## S3 method for class 'pdb_posterior' reference_posterior_info(x, type, ...) ## S3 method for class 'character' reference_posterior_info(x, type, pdb = pdb_default(), ...) ## S3 method for class 'list' as.reference_posterior_info(x, type = NULL, pdb = NULL, ...)
reference_posterior_info(x, type, pdb = pdb_default(), ...) as.reference_posterior_info(x, type, pdb = pdb_default(), ...) pdb_reference_posterior_info(x, type, pdb = pdb_default(), ...) as.pdb_reference_posterior_info(x, type, pdb = pdb_default(), ...) reference_posterior_draws_info(x, pdb = pdb_default(), ...) pdb_reference_posterior_draws_info(x, pdb = pdb_default(), ...) ## S3 method for class 'pdb_posterior' reference_posterior_info(x, type, ...) ## S3 method for class 'character' reference_posterior_info(x, type, pdb = pdb_default(), ...) ## S3 method for class 'list' as.reference_posterior_info(x, type = NULL, pdb = NULL, ...)
x |
a |
type |
Type of reference posterior [draws] or [summary_statistic]. |
pdb |
a |
... |
Currently not used. |
Reference posterior information on how, when and by whom the reference posterior was computed.
reference_posterior_draws
Get all existing reference posterior names from a posterior database
reference_posterior_names(pdb = pdb_default(), type, ...) ## S3 method for class 'pdb_local' reference_posterior_names(pdb = pdb_default(), type, ...)
reference_posterior_names(pdb = pdb_default(), type, ...) ## S3 method for class 'pdb_local' reference_posterior_names(pdb = pdb_default(), type, ...)
pdb |
a |
type |
supported reference posterior types. |
... |
Further argument to methods. |
Reference posterior summary statistics
reference_posterior_summary_statistic(x, ...) pdb_reference_posterior_summary_statistic(x, ...) ## S3 method for class 'character' reference_posterior_summary_statistic(x, pdb = pdb_default(), type, ...) ## S3 method for class 'pdb_posterior' reference_posterior_summary_statistic(x, type, ...) ## S3 method for class 'pdb_reference_posterior_info' reference_posterior_summary_statistic(x, pdb = pdb_default(), type, ...) ## S3 method for class 'list' reference_posterior_summary_statistic(x, info, type, ...) reference_posterior_summary_statistics(x, ...) pdb_reference_posterior_summary_statistics(x, ...) ## S3 method for class 'character' reference_posterior_summary_statistics(x, pdb = pdb_default(), ...) ## S3 method for class 'pdb_posterior' reference_posterior_summary_statistics(x, ...)
reference_posterior_summary_statistic(x, ...) pdb_reference_posterior_summary_statistic(x, ...) ## S3 method for class 'character' reference_posterior_summary_statistic(x, pdb = pdb_default(), type, ...) ## S3 method for class 'pdb_posterior' reference_posterior_summary_statistic(x, type, ...) ## S3 method for class 'pdb_reference_posterior_info' reference_posterior_summary_statistic(x, pdb = pdb_default(), type, ...) ## S3 method for class 'list' reference_posterior_summary_statistic(x, info, type, ...) reference_posterior_summary_statistics(x, ...) pdb_reference_posterior_summary_statistics(x, ...) ## S3 method for class 'character' reference_posterior_summary_statistics(x, pdb = pdb_default(), ...) ## S3 method for class 'pdb_posterior' reference_posterior_summary_statistics(x, ...)
x |
a [posterior] object or a posterior name. |
... |
further arguments supplied to specific methods. |
pdb |
a [pdb] object (if [x] is a posterior name) |
type |
the type of summary statistic to extract |
info |
a [pdb_reference_posterior_info] object |
a [pdb_reference_posterior_summary_statistic] object.
a function to simplify removing object from a local pdb.
remove_pdb(x, pdb, ...) ## S3 method for class 'character' remove_pdb(x, pdb, ...) ## S3 method for class 'pdb_data' remove_pdb(x, pdb, remove_info = TRUE, ...) ## S3 method for class 'pdb_data_info' remove_pdb(x, pdb, ...) ## S3 method for class 'pdb_model_code' remove_pdb(x, pdb, remove_info = TRUE, ...) ## S3 method for class 'pdb_model_info' remove_pdb(x, pdb, ...) ## S3 method for class 'pdb_posterior' remove_pdb(x, pdb, ...) ## S3 method for class 'pdb_reference_posterior_draws' remove_pdb(x, pdb, remove_info = TRUE, ...) ## S3 method for class 'pdb_reference_posterior_info' remove_pdb(x, pdb, type, ...) ## S3 method for class 'pdb_reference_posterior_summary_statistic' remove_pdb(x, pdb, remove_info = TRUE, ...)
remove_pdb(x, pdb, ...) ## S3 method for class 'character' remove_pdb(x, pdb, ...) ## S3 method for class 'pdb_data' remove_pdb(x, pdb, remove_info = TRUE, ...) ## S3 method for class 'pdb_data_info' remove_pdb(x, pdb, ...) ## S3 method for class 'pdb_model_code' remove_pdb(x, pdb, remove_info = TRUE, ...) ## S3 method for class 'pdb_model_info' remove_pdb(x, pdb, ...) ## S3 method for class 'pdb_posterior' remove_pdb(x, pdb, ...) ## S3 method for class 'pdb_reference_posterior_draws' remove_pdb(x, pdb, remove_info = TRUE, ...) ## S3 method for class 'pdb_reference_posterior_info' remove_pdb(x, pdb, type, ...) ## S3 method for class 'pdb_reference_posterior_summary_statistic' remove_pdb(x, pdb, remove_info = TRUE, ...)
x |
an object to remove to the pdb. |
pdb |
the pdb to remove from. Currently only a local pdb. |
... |
further arguments supplied to methods. |
remove_info |
should the information JSON be removed as well? |
type |
supported reference posterior types. |
Rename a pdb object
rename_pdb(x, new_name, ...) ## S3 method for class 'pdb_data' rename_pdb(x, new_name, ...) ## S3 method for class 'pdb_posterior' rename_pdb(x, new_name, ...)
rename_pdb(x, new_name, ...) ## S3 method for class 'pdb_data' rename_pdb(x, new_name, ...) ## S3 method for class 'pdb_posterior' rename_pdb(x, new_name, ...)
x |
an object to rename |
new_name |
the new name of the object |
... |
further arguments (not in use) |
Run Stan on a posterior
run_stan(x, stan_args, ...) ## S3 method for class 'pdb_posterior' run_stan(x, stan_args, ...)
run_stan(x, stan_args, ...) ## S3 method for class 'pdb_posterior' run_stan(x, stan_args, ...)
x |
a [pdb_posterior] object. |
stan_args |
Arguments supplied to [rstan::stan] to compute the posterior |
... |
currently not in use. |
Subset a [pdb_reference_posterior_draws] object
## S3 method for class 'pdb_reference_posterior_draws' subset(x, variable, ...)
## S3 method for class 'pdb_reference_posterior_draws' subset(x, variable, ...)
x |
a [pdb_reference_posterior_draws] to subest |
variable |
parameter names to subset. |
... |
Further arguments (not used). |
Extract the type of summary statistic
summary_statistic_type(x)
summary_statistic_type(x)
x |
a [pdb_reference_posterior_summary_statistic] |
Thin [pdb_reference_posterior_draws] objects to reduce their size and autocorrelation of the chains.
thin_draws.pdb_reference_posterior_draws(x, thin, ...)
thin_draws.pdb_reference_posterior_draws(x, thin, ...)
x |
An R object for which the methods are defined. |
thin |
A positive integer specifying the period for selecting draws. |
... |
Arguments passed to individual methods (if applicable). |
A thinned [pdb_reference_posterior_draws] object.
a function to simplify writing to a local pdb.
write_pdb(x, pdb, overwrite = FALSE, ...) ## S3 method for class 'pdb_reference_posterior_info' write_pdb(x, pdb, overwrite = FALSE, type, ...) ## S3 method for class 'pdb_reference_posterior_draws' write_pdb(x, pdb, overwrite = FALSE, ...) ## S3 method for class 'pdb_reference_posterior_summary_statistic' write_pdb(x, pdb, overwrite = FALSE, ...) ## S3 method for class 'pdb_data' write_pdb(x, pdb, overwrite = FALSE, ...) ## S3 method for class 'pdb_data_info' write_pdb(x, pdb, overwrite = FALSE, ...) ## S3 method for class 'stanmodel' write_pdb(x, pdb, overwrite = FALSE, ...) ## S3 method for class 'pdb_model_code' write_pdb(x, pdb, overwrite = FALSE, ...) ## S3 method for class 'pdb_model_info' write_pdb(x, pdb, overwrite = FALSE, ...) ## S3 method for class 'pdb_posterior' write_pdb(x, pdb, overwrite = FALSE, ...)
write_pdb(x, pdb, overwrite = FALSE, ...) ## S3 method for class 'pdb_reference_posterior_info' write_pdb(x, pdb, overwrite = FALSE, type, ...) ## S3 method for class 'pdb_reference_posterior_draws' write_pdb(x, pdb, overwrite = FALSE, ...) ## S3 method for class 'pdb_reference_posterior_summary_statistic' write_pdb(x, pdb, overwrite = FALSE, ...) ## S3 method for class 'pdb_data' write_pdb(x, pdb, overwrite = FALSE, ...) ## S3 method for class 'pdb_data_info' write_pdb(x, pdb, overwrite = FALSE, ...) ## S3 method for class 'stanmodel' write_pdb(x, pdb, overwrite = FALSE, ...) ## S3 method for class 'pdb_model_code' write_pdb(x, pdb, overwrite = FALSE, ...) ## S3 method for class 'pdb_model_info' write_pdb(x, pdb, overwrite = FALSE, ...) ## S3 method for class 'pdb_posterior' write_pdb(x, pdb, overwrite = FALSE, ...)
x |
an object to write to the pdb. |
pdb |
the pdb to write to. Currently only a local pdb. |
overwrite |
overwrite existing file? |
... |
further arguments supplied to methods. |
type |
supported reference posterior types. |