generate_sample {EcoEnsemble}R Documentation

Generate samples from a fitted ensemble model.

Description

Methods to generates samples of the latent variables from a fitted ensemble model.

Usage

generate_sample(fit, num_samples = 1)

get_transformed_data(fit)

get_parameters(ex.fit, x = 1)

get_mle(x = 1, ex.fit, transformed_data, time)

gen_sample(x = 1, ex.fit, transformed_data, time)

get_transformed_data_dri(fit)

Arguments

fit

An EnsembleFit object.

num_samples

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

ex.fit

A list containing the samples / point estimate from the EnsembleFit object.

x

A numeric specifying which sample from the posterior to use. The default is 1.

transformed_data

A list of transformed input data.

time

A numeric specifying the time for which the ensemble model was run.

Details

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

Value

generate_sample gives a list of length 2, the first element being the MLE of latent variables and the second element being a set of samples of the latent variables.

get_transformed_data gives a list of transformed input data.

get_parameters gives a list of ensemble parameters from the requested sample.

get_mle If fit is a sampling of the ensemble model parameters, then this is a time\times (3M + 2) \times num_samples array. If fit is a point estimate of the ensemble model parameters, then this is a time\times (3M + 2) \times 1 array giving the MLE of the latent variables for the point estimate of the ensemble model.

gen_sample If fit is a sampling of the ensemble model parameters, then this is a time\times (3M + 2) \times num_samples array, giving a sample of the latent variables for each available sample of the ensemble model. If fit is a point estimate of the ensemble model parameters, then this is a time\times (3M + 2) \times num_samples array.

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, Robert Denhamb, 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

Examples


fit <- fit_ensemble_model(observations = list(SSB_obs, Sigma_obs),
               simulators = list(list(SSB_ewe, Sigma_ewe, "EwE"),
                                 list(SSB_fs,  Sigma_fs, "FishSUMS"),
                                 list(SSB_lm,  Sigma_lm, "LeMans"),
                                 list(SSB_miz, Sigma_miz, "Mizer")),
               priors = EnsemblePrior(4,
               ind_st_params = IndSTPrior(parametrisation_form = "lkj",
               var_params= list(1,1), cor_params = 10, AR_params = c(2, 2))),
               full_sample = FALSE) #Only optimise in this case
samples <- generate_sample(fit, num_samples = 2000)


[Package EcoEnsemble version 1.1.0 Index]