adapt_particles: Adapt the number of particles

Description Usage Arguments Value Examples

View source: R/adapt_particles.R

Description

This function takes the provided libbi and runs MCMC at a single point (i.e., repeatedly proposing the same parameters), adapting the number of particles distribution until the variance of the log-likelihood crosses the value given as target.variance (1 by default).

Usage

1
2
3
4
5
6
7
8
adapt_particles(
  x,
  min = 1,
  max = 1024,
  target.variance = 1,
  quiet = FALSE,
  ...
)

Arguments

x

a libbi object

min

minimum number of particles

max

maximum number of particles

target.variance

target log-likelihood variance; once this is crossed, the current number of particles will be used

quiet

if set to TRUE, will not provide running output of particle numbers tested

...

parameters for libbi$run

Value

a libbi with the desired proposal distribution

Examples

1
2
3
4
5
6
example_obs <- bi_read(system.file(package="rbi", "example_dataset.nc"))
example_model <- bi_model(system.file(package="rbi", "PZ.bi"))
example_bi <- libbi(model = example_model, obs = example_obs)
obs_states <- var_names(example_model, type = "obs")
max_time <- max(vapply(example_obs[obs_states], function(x) { max(x[["time"]])}, 0))
adapted <- adapt_particles(example_bi, nsamples = 128, end_time = max_time)

rbi.helpers documentation built on July 2, 2020, 4:10 a.m.