initialise_particle_sets: Initialise particle sets from a list of samples

View source: R/importance_sampling_functions.R

initialise_particle_setsR Documentation

Initialise particle sets from a list of samples

Description

Function to initialise particle sets from a list of samples

Usage

initialise_particle_sets(samples_to_fuse, multivariate, number_of_steps = 2)

Arguments

samples_to_fuse

a list of samples that you wish to perform fusion with

multivariate

logical value indicating if the samples are multivariate (TRUE) or not (FALSE)

number_of_steps

integer value for number of steps in the Fusion algorithm (default is 2 for Monte Carlo Fusion)

Value

A list of particles to fuse, where the cth component is the particle for sub-posterior c. In particular, each item in the list is an environment with components

y_samples

samples for y in particle set (initialised as the samples given)

x_samples

a list where x_samples[[i]] is the ith x sample for in particle set (all initialised as NA)

x_mean

the corresponding means for x_samples (initialised as NA)

log_weights

associated logarithm of the weights (initialised as the logarithm of 1/number of samples)

normalised_weights

associated normalised weights (initialised as 1/number of samples)

ESS

effective sample size of particles (initialised as the number of samples)

CESS

conditional effective sample size of particles after each step of the algorithm (initialised as NA for each step)

resampled

logical value to indicate if particles have been resampled after each step (initialised as FALSE for each step besides the last step, which is set to TRUE)

number_of_steps

number of steps in the Fusion algorithm (initialised as the number_of_steps provided)

N

Number of particles

Examples

# univariate
uni_samples <- lapply(1:2, function(i) rnorm(100, 0, 1))
particles <- initialise_particle_sets(samples_to_fuse = uni_samples, multivariate = FALSE)

# multivariate
multi_samples <- lapply(1:2, function(i) mvrnormArma(100, c(0, 0), diag(2)))
particles <- initialise_particle_sets(samples_to_fuse = multi_samples, multivariate = TRUE)


rchan26/hierarchicalFusion documentation built on Sept. 11, 2022, 10:30 p.m.