Learn R Programming

EcoEnsemble (version 1.1.2)

fit_ensemble_model: Fits the ensemble model

Description

fit_ensemble_model runs an MCMC of the ensemble model. This process can take a long time depending on the size of the datasets.

Usage

fit_ensemble_model(
  observations,
  simulators,
  priors,
  full_sample = TRUE,
  control = list(adapt_delta = 0.95),
  drivers = FALSE,
  MMod,
  ...
)

Value

An EnsembleFit object.

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.

full_sample

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

control

If creating a full sample, this is a named list of paramaters to control Stan's sampling behaviour. See the documentation of the stan() function in the rstan package for details. The default value is list(adapt_delta = 0.95). If optimizing, this value is ignored.

drivers

A logical indicating whether drivers have been used in combination with simulators. Default value is FALSE.

MMod

Not currently implemented.

...

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

References

Stan Development Team (2020). RStan: the R interface to Stan. R package version 2.21.2. https://mc-stan.org

See Also

EnsembleFit, EnsembleSample

Examples

Run this code
# \donttest{

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
# }

Run the code above in your browser using DataLab