threemc_fit_model: Produce TMB model fit with sample, or re-sample from existing...

View source: R/modelling.R

threemc_fit_modelR Documentation

Produce TMB model fit with sample, or re-sample from existing optimised model fit.

Description

Optimises threemc objective function and produces samples from model fit (if so desired). If provided with an existing optimised model fit, can also perform re-sampling.

Usage

threemc_fit_model(
  fit = NULL,
  dat_tmb = NULL,
  mod = NULL,
  parameters = NULL,
  maps = NULL,
  randoms = c("u_time_mmc", "u_age_mmc", "u_space_mmc", "u_agetime_mmc",
    "u_agespace_mmc", "u_spacetime_mmc", "u_age_tmc", "u_space_tmc", "u_agespace_tmc"),
  sample = TRUE,
  smaller_fit_obj = FALSE,
  sdreport = FALSE,
  N = 1000,
  verbose = TRUE,
  ...
)

Arguments

fit

Optional "small" fit object with no sample. Specifying fit means you do not need to specify dat_tmb or parameters, as argument specifications will be overridden by those stored in fit.

dat_tmb

list of data required for model fitting, outputted by threemc_prepare_model_data, which includes:

  • design_matricesIncludesX_fixed_mmc, X_fixed_tmc, X_time_mmc, X_age_mmc, X_age_tmc, X_space_mmc, X_space_tmc, X_agetime_mmc, X_agespace_mmc, X_agespace_tmc, X_spacetime_mmc. Design Create design matrices for fixed effects and temporal, age, space and interaction random effects

  • integration matricesIncludes IntMat1, IntMat2. Integration matrices for selecting the instantaneous hazard rate.

  • survival matricesIncludes A_mmc, A_tmc, A_mc, B, C. Survival matrices for MMC, TMC, censored and left censored

  • Q_spacePrecision/Adjacency matrix for the spatial random effects.

mod

TMB model, one of either "Surv_SpaceAgeTime_ByType_withUnknownType" or "Surv_SpaceAgeTime" if the surveys for the country in question make no distinction between circumcision type (i.e whether they were performed in a medical or traditional setting).

parameters

list of fixed and random model parameters.

maps

list of factors with value NA, the names of which indicate parameters to be kept fixed at their initial value throughout the optimisation process.

randoms

vector of random effects.

sample

If set to TRUE, has function also return N samples for medical, traditional and total circumcisions, Default: TRUE

smaller_fit_obj

Returns a smaller fit object. Useful for saving the fit object for later aggregations.

sdreport

If set to TRUE, produces the standard deviation report for the model, Default: FALSE

N

Number of samples to be generated, Default: 1000

verbose

Boolean specifying whether you want detailed updates on function operations and progress, default = TRUE

...

Further arguments passed to internal functions.

Value

TMB model fit, including optimised parameters, hessian matrix, samples and standard deviation report (if desired).


mrc-ide/threemc documentation built on Feb. 9, 2024, 5:16 p.m.