Learn R Programming

pmwg - Particle Metropolis within Gibbs

Installation

To install the latest stable version you can use the following command to install from CRAN:

install.packages("pmwg")

If you want the (possibly unstable) development version, you can also install the package using devtools as follows:

devtools::install_github('university-of-newcastle-research/pmwg', ref="develop")

This package is tested and should work on all versions of R > 3.5, however instructions on installing to an earlier version of R are included below.

Using the package

The best introduction to the package can be found at the bookdown site located at: https://university-of-newcastle-research.github.io/samplerDoc/ The document there includes the motivation for the approach, several detailed examples of the package in action and a list of common problems and troubleshooting techniques. Also available online is the package documentation at https://university-of-newcastle-research.github.io/pmwg/ which consists of this README, a Reference of help documentation for individual functions, a list of changes to the project over time and more. Finally there is a page containing some frequently asked questions which can be found at https://university-of-newcastle-research.github.io/pmwg/FAQ.html

Included on the pmwg website is also a getting started guide to the package, available from https://university-of-newcastle-research.github.io/pmwg/articles/pmwg.html

Copy Link

Version

Install

install.packages('pmwg')

Monthly Downloads

231

Version

0.2.7

License

GPL-3

Issues

Pull Requests

Stars

Forks

Maintainer

Gavin Cooper

Last Published

January 31st, 2024

Functions in pmwg (0.2.7)

forstmann

Forstmann et al.'s data
run_stage

Run a stage of the PMwG sampler
riwish

The Inverse Wishart Distribution
is.pmwgs

Test whether object is a pmwgs
init

Initialise values for the random effects
gibbs_step_err

Error handler for the gibbs_step call
pmwgs

Create a PMwG sampler and return the created object
relabel_samples

Relabel requested burn-in samples as adaptation
new_sample_err

Error handler forany error in new_sample function call(s)
numbers_from_proportion

Check and normalise the number of each particle type from the mix_proportion
particle_draws

Generate a cloud of particles from a multivariate normal distribution
accept_rate

Return the acceptance rate for new particles across all subjects
new_sample

Generate particles and select one to be the new sample
last_sample

Create a list with the last samples in the pmwgs object
set_mix

Set default values for mix
sample_store

Create a new list for storage samples in the pmwgs object
particle_select_err

Error handler for the particle selection call
pmwg-package

pmwg: Particle Metropolis Within Gibbs.
rwish

The Wishart Distribution
unwind

Unwinds variance matrix to a vector
set_proposal

Setup the proposal distribution arguments (if in sample stage)
update_epsilon

Update the subject specific scaling parameters (epsilon)
test_sampler_adapted

Test that the sampler has successfully adapted
wind

Winds a variance vector back to a vector
update_progress_bar

A function that updates the accept_progress_bar with progress and accept rate
sampled_forstmann

A sampled object of a model of the Forstmann dataset
trim_na

Trim the unneeded NA values from the end of the sampler
set_epsilon

Set default values for epsilon
check_run_stage_args

Test the arguments to the run_stage function for correctness
augment_sampler_epsilon

Augment existing sampler object to have subject specific epsilon storage
as_mcmc

Return a CODA mcmc object with the required samples
gibbs_step

Gibbs step of the Particle Metropolis within Gibbs sampler
accept_progress_bar

An altered version of the utils:txtProgressBar that shows acceptance rate
conditional_parms

Obtain the efficent mu and sigma from the adaptation phase draws
gen_particles

Generate proposal particles
check_adapted

Check whether the adaptation phase has successfully completed
extend_sampler

Extend the main data store with empty space for new samples
check_efficient

Check for efficient proposals if necessary
create_efficient

Create distribution parameters for efficient proposals
extract_samples

Extract relevant samples from the list for conditional dist calc