sample_prior {EcoEnsemble}R Documentation

Generate samples of latent variables from prior predictive distribution

Description

Methods to generates samples of the latent variables from the prior predictive distribution of the ensemble model.

Usage

sample_prior(
  observations,
  simulators,
  priors,
  sam_priors,
  num_samples = 1,
  full_sample = TRUE,
  ...
)

Arguments

observations

A list of length 2 containing observations and a covariance matrix. The first element is a data.frame or matrix with each column giving observations of each output of interest and each row a time. Rows should be named with the times and columns should be named the variables. The second element is is a d \times d matrix where d is the number of columns of the observations data frame / matrix. This matrix is the covariance matrix of the observations.

simulators

A list with length equal to the number of simulators. For each simulator, there is a list of 2 objects containing the simulator output and covariance matrix. The first element is a data.frame or matrix with each column giving a simulator outputs of interest and each row a time. Rows should be named with the times and columns should be named the variables. The second element is a n_k \times n_k matrix where n_k is the number of columns of the simulators output data frame / matrix. This matrix is the covariance matrix of the simulator outputs.

priors

An EnsemblePrior object specifying the prior distributions for the ensemble.

sam_priors

A list containing two items named samples and point_estimate. samples is either a NULL or a stanfit object containing the samples drawn from the prior distribution of the ensemble model and point_estimate is either a NULL or a list object containing the optimised prior distribution of the ensemble model. If this object is missing then sample_prior generates it.

num_samples

A numeric specifying the number of samples to be generated. The default is 1.

full_sample

A logical that runs a full sampling of the prior density of the ensemble model if TRUE. If FALSE, returns the point estimate which maximises the prior density of the ensemble model.

...

Additional arguments passed to the function rstan::sampling or rstan::optimizing.

Details

The samples are created using the methods described in Strickland et. al. (2009) and Durbin and Koopman (2002).

Value

An EnsembleSample object.

References

J. Durbin, S. J. Koopman (2002) A simple and efficient simulation smoother for state space time series analysis Biometrika, Volume 89, Issue 3, August 2002, Pages 603-616,

Chris M.Strickland, Ian. W.Turner, RobertDenhamb, Kerrie L.Mengersena. Efficient Bayesian estimation of multivariate state space models Computational Statistics & Data Analysis Volume 53, Issue 12, 1 October 2009, Pages 4116-4125

See Also

EnsembleFit, EnsembleSample, generate_sample, prior_ensemble_model

Examples


priors <- EnsemblePrior(4)
prior_density <- prior_ensemble_model(priors, M = 4)
samples <- sample_prior(observations = list(SSB_obs, Sigma_obs),
             simulators = list(list(SSB_miz, Sigma_miz),
                               list(SSB_ewe, Sigma_ewe),
                               list(SSB_fs, Sigma_fs),
                               list(SSB_lm, Sigma_lm)),
             priors = priors,
             sam_priors = prior_density)
plot(samples) #Plot the prior predictive density.


[Package EcoEnsemble version 1.0.5 Index]