Package 'waspr'

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-07 04:27:23 UTC
Source: https://github.com/joliencremers/waspr

Help Index


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 wasp object obtained from the function wasp().

...

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 wasp object.

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 wasp object obtained from the function wasp().

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)