Title: | Wasserstein Barycenters of Subset Posteriors |
---|---|
Description: | Functions to compute Wasserstein barycenters of subset posteriors using the swapping algorithm developed by Puccetti, Rüschendorf and Vanduffel (2020) <doi:10.1016/j.jmaa.2017.02.003>. The Wasserstein barycenter is a geometric approach for combining subset posteriors. It allows for parallel and distributed computation of the posterior in case of complex models and/or big datasets, thereby increasing computational speed tremendously. |
Authors: | Jolien Cremers [aut, cre] |
Maintainer: | Jolien Cremers <[email protected]> |
License: | GPL-3 |
Version: | 1.0.1 |
Built: | 2024-11-24 06:51:36 UTC |
Source: | CRAN |
This (non-exported) function combines the output from the swapping algorithm (Puccetti, Rüschendorf and Vanduffel, 2020).
combine(x)
combine(x)
x |
a three dimensional array (rows = subsets, columns = par, slices = samples) containing posterior samples for all subsets |
A wasp
object, which can be further analyzed using the
associated function summary.wasp
.
Puccetti, G., Rüschendorf, L. & Vanduffel, S. (2020). On the computation of Wasserstein barycenters, Journal of Multivariate Analysis, 176.
Compute the 95 percent Highest Posterior Density interval
hpd_est(x)
hpd_est(x)
x |
a numeric vector |
A vector containing the lower and upper bound of the 96 Posterior Density interval of a numeric vector as computed by the methods from Venter (1967).
Venter, J.H. (1967). On estimation of the mode, Annals of Mathematical Statistics, 38(5), 1446-1455.
library(waspr) hpd_est(pois_logistic[1,1,])
library(waspr) hpd_est(pois_logistic[1,1,])
Compute the mode
mode_est(x)
mode_est(x)
x |
a numeric vector |
The mode of a numeric vector as computed by the methods from Venter (1967).
Venter, J.H. (1967). On estimation of the mode, Annals of Mathematical Statistics, 38(5), 1446-1455.
library(waspr) mode_est(pois_logistic[1,1,])
library(waspr) mode_est(pois_logistic[1,1,])
A set of mcmc samples from 8 subposteriors from the analysis of a joint model with a logistic and poisson outcome variable.
pois_logistic
pois_logistic
An array with 3 dimensions of which the first represents the subposteriors (size = 8), the second represents the paramters (size = 8) and the third represents the amount of mcmc samples (size = 450).
Prints selected output from a Bayesian circular mixed-effects model.
## S3 method for class 'wasp' print(x, ...)
## S3 method for class 'wasp' print(x, ...)
x |
a |
... |
further arguments passed to or from other methods. |
A print of posterior summaries for the Wasserstein barycenter of subset posteriors
library(waspr) out <- wasp(pois_logistic, par.names = c("beta_s", "alpha_l", "beta_l", "baseline_sigma", "baseline_mu", "correlation", "sigma_s", "sigma_l")) print(out)
library(waspr) out <- wasp(pois_logistic, par.names = c("beta_s", "alpha_l", "beta_l", "baseline_sigma", "baseline_mu", "correlation", "sigma_s", "sigma_l")) print(out)
summary
gives a posterior summary (mean, mode, sd, HPD)
summary(x)
summary(x)
x |
a |
the method summary.wasp has its own help page.
library(waspr)
library(waspr)
Outputs and prints posterior summary statistics (mean, mode, sd, 95 Posterior Density interval)
## S3 method for class 'wasp' summary(x)
## S3 method for class 'wasp' summary(x)
x |
a |
Posterior summary statistics (mean, mode, sd, 95 all the Wasserstein barycenter of subset posteriors of all parameters in the model.
library(waspr) out <- wasp(pois_logistic, par.names = c("beta_s", "alpha_l", "beta_l", "baseline_sigma", "baseline_mu", "correlation", "sigma_s", "sigma_l")) summary(out)
library(waspr) out <- wasp(pois_logistic, par.names = c("beta_s", "alpha_l", "beta_l", "baseline_sigma", "baseline_mu", "correlation", "sigma_s", "sigma_l")) summary(out)
The swapping algorithm for computing Wasserstein barycenters
swap_rcpp(samples, acc = 0.001, iter = 10L, out = FALSE)
swap_rcpp(samples, acc = 0.001, iter = 10L, out = FALSE)
samples |
A cube containing samples for all subset posteriors (rows = subsets, columns = par, slices = samples) |
acc |
accuracy |
iter |
maximum number of iterations of the algorithm |
out |
boolean indicating whether output for each iteration should be displayed (default = false) |
a three dimensional array (rows = subsets, columns = par, slices = samples) containing output from the swapping algorithm.
This function computes Wasserstein Barycenters of subset posteriors and gives posterior summaries for the full posterior.
wasp(mcmc, par.names = NULL, acc = 0.001, iter = 10, out = FALSE)
wasp(mcmc, par.names = NULL, acc = 0.001, iter = 10, out = FALSE)
mcmc |
a three dimensional array (rows = number of subset posteriors, columns = number of parameters of the posterior distribution, slices = samples number of samples for each subset posterior) containing posterior samples for all subsets |
par.names |
optional character vector with parameter names |
acc |
accuracy of the swapping algorithm (default = 0.001) |
iter |
maximum number of iterations of the swapping algorithm (default = 10) |
out |
boolean indicating whether output for each iteration of the swapping algorithm should be displayed (default = false) |
The swapping algorithm developed by Puccetti, Rüschendorf and Vanduffel (2020) is used to compute Wasserstein barycenters of subset posteriors.
A wasp
object, which can be further analyzed using the
associated function summary.wasp
.
A wasp
object contains the following elements (some elements are not
returned if not applicable)
barycenter
A matrix of posterior samples (rows) for all parameters (columns) of the full posterior obtained by the swapping algorithm.
raw
An array (dim = c(subsets, parameters, samples)
)
containing the raw output from the swapping algorithm.
call
The call to the wasp()
function.
subsets
The amount of subset posteriors in mcmc.
parameters
The amount of parameters in mcmc.
samples
The amount of posterior samples for each subset posterior in mcmc.
acc
Accuracy of the swapping algorithm, default = 0.001.
iter
Maximum amount of iterations for the swapping algorithm, default = 10.
Puccetti, G., Rüschendorf, L. & Vanduffel, S. (2020). On the computation of Wasserstein barycenters, Journal of Multivariate Analysis, 176.
library(waspr) out <- wasp(pois_logistic, par.names = c("beta_s", "alpha_l", "beta_l", "baseline_sigma", "baseline_mu", "correlation", "sigma_s", "sigma_l")) summary(out)
library(waspr) out <- wasp(pois_logistic, par.names = c("beta_s", "alpha_l", "beta_l", "baseline_sigma", "baseline_mu", "correlation", "sigma_s", "sigma_l")) summary(out)