Type: | Package |
Title: | Wasserstein Barycenters of Subset Posteriors |
Version: | 1.0.1 |
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. |
License: | GPL-3 |
URL: | https://github.com/joliencremers/waspr |
BugReports: | https://github.com/joliencremers/waspr/issues |
Encoding: | UTF-8 |
LazyData: | true |
Imports: | Rcpp (≥ 1.0.4.6) |
LinkingTo: | BH, Rcpp, RcppArmadillo, |
RoxygenNote: | 7.2.3 |
Suggests: | knitr, rmarkdown, testthat, spelling |
VignetteBuilder: | knitr |
Language: | en-US |
Biarch: | true |
Depends: | R (≥ 3.5.0) |
NeedsCompilation: | yes |
Packaged: | 2023-09-11 13:09:38 UTC; Jolien |
Author: | Jolien Cremers [aut, cre] |
Maintainer: | Jolien Cremers <joliencremers@gmail.com> |
Repository: | CRAN |
Date/Publication: | 2023-09-11 14:00:03 UTC |
waspr: an R package for computing Wasserstein barycenters of subset posteriors
Description
This package contains functions to compute Wasserstein barycenters of subset posteriors using the swapping algorithm developed by Puccetti, Rüschendorf and Vanduffel (2020). 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.
Functions
The main function of the package is:
wasp
, which runs the swapping algorithm developed by
Puccetti, Rüschendorf and Vanduffel (2020), combines the output from the
swapping algorithm and computes the Wasserstein barycenter. It returns an
S3 object of type wasp
.
Author(s)
Maintainer: Jolien Cremers joliencremers@gmail.com
Source
Puccetti, G., Rüschendorf, L. & Vanduffel, S. (2020). On the computation of Wasserstein barycenters, Journal of Multivariate Analysis, 176.
See Also
Useful links:
Combine output of the swapping algorithm
Description
This (non-exported) function combines the output from the swapping algorithm (Puccetti, Rüschendorf and Vanduffel, 2020).
Usage
combine(x)
Arguments
x |
a three dimensional array (rows = subsets, columns = par, slices = samples) containing posterior samples for all subsets |
Value
A wasp
object, which can be further analyzed using the
associated function summary.wasp
.
Source
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
Description
Compute the 95 percent Highest Posterior Density interval
Usage
hpd_est(x)
Arguments
x |
a numeric vector |
Value
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).
Source
Venter, J.H. (1967). On estimation of the mode, Annals of Mathematical Statistics, 38(5), 1446-1455.
Examples
library(waspr)
hpd_est(pois_logistic[1,1,])
Compute the mode
Description
Compute the mode
Usage
mode_est(x)
Arguments
x |
a numeric vector |
Value
The mode of a numeric vector as computed by the methods from Venter (1967).
Source
Venter, J.H. (1967). On estimation of the mode, Annals of Mathematical Statistics, 38(5), 1446-1455.
Examples
library(waspr)
mode_est(pois_logistic[1,1,])
pois_logistic
Description
A set of mcmc samples from 8 subposteriors from the analysis of a joint model with a logistic and poisson outcome variable.
Usage
pois_logistic
Format
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).
Print posterior summaries for the Wasserstein barycenter of subset posteriors
Description
Prints selected output from a Bayesian circular mixed-effects model.
Usage
## S3 method for class 'wasp'
print(x, ...)
Arguments
x |
a |
... |
further arguments passed to or from other methods. |
Value
A print of posterior summaries for the Wasserstein barycenter of subset posteriors
Examples
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)
Posterior summaries for the Wasserstein barycenter of subset posteriors
Description
summary
gives a posterior summary (mean, mode, sd, HPD)
Usage
summary(x)
Arguments
x |
a |
Details
the method summary.wasp has its own help page.
Examples
library(waspr)
Posterior summaries for the Wasserstein barycenter of subset posteriors
Description
Outputs and prints posterior summary statistics (mean, mode, sd, 95 Posterior Density interval)
Usage
## S3 method for class 'wasp'
summary(x)
Arguments
x |
a |
Value
Posterior summary statistics (mean, mode, sd, 95 all the Wasserstein barycenter of subset posteriors of all parameters in the model.
Examples
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
Description
The swapping algorithm for computing Wasserstein barycenters
Usage
swap_rcpp(samples, acc = 0.001, iter = 10L, out = FALSE)
Arguments
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) |
Value
a three dimensional array (rows = subsets, columns = par, slices = samples) containing output from the swapping algorithm.
Compute Wasserstein barycenters of subset posteriors
Description
This function computes Wasserstein Barycenters of subset posteriors and gives posterior summaries for the full posterior.
Usage
wasp(mcmc, par.names = NULL, acc = 0.001, iter = 10, out = FALSE)
Arguments
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) |
Details
The swapping algorithm developed by Puccetti, Rüschendorf and Vanduffel (2020) is used to compute Wasserstein barycenters of subset posteriors.
Value
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.
Source
Puccetti, G., Rüschendorf, L. & Vanduffel, S. (2020). On the computation of Wasserstein barycenters, Journal of Multivariate Analysis, 176.
Examples
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)