-
Notifications
You must be signed in to change notification settings - Fork 0
/
fit_model.Rd
161 lines (108 loc) · 8.91 KB
/
fit_model.Rd
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
% Generated by roxygen2: do not edit by hand
% Please edit documentation in R/fit_model.R
\name{fit_model}
\alias{fit_model}
\title{Fit Model}
\usage{
fit_model(model = "BaseLineModel", previous_model_path = NULL,
gen_data = TRUE, run_time = 73, time_scale = "year",
plot_obs = TRUE, sample_priors = TRUE, prior_samples = 1000,
optim = TRUE, nparticles = NULL, adapt_particles = TRUE,
adapt_part_samples = 1000, adapt_part_it = 10,
min_particles = NULL, max_particles = NULL,
proposal_param_block = NULL, proposal_initial_block = NULL,
adapt_proposal = TRUE, adapt_prop_samples = 100, adapt_prop_it = 3,
adapt = "both", adapt_scale = 2, min_acc = 0.04, max_acc = 0.4,
fit = FALSE, posterior_samples = 10000, thin = 1, burn_prop = 0,
time_for_resampling = 0, sample_ess_at = 0.8, rejuv_moves = NULL,
nthreads = parallel::detectCores(), verbose = TRUE,
libbi_verbose = FALSE, fitting_verbose = TRUE, pred_states = TRUE,
browse = FALSE, const_pop = FALSE, no_age = FALSE,
no_disease = FALSE, scale_rate_treat = TRUE,
years_of_data = c(2000:2004), years_of_age = c(2000, 2004),
age_groups = NULL, con_age_groups = NULL,
spacing_of_historic_tb = 10, aggregated_observed = FALSE,
initial_uncertainty = TRUE, noise = TRUE,
scale_transmission = "none", scale_nonukborn_mixing = "none",
save_output = FALSE, dir_path = NULL, dir_name = NULL,
reports = TRUE, seed = 1234)
}
\arguments{
\item{model}{A character string containing the model name. Alternatively a model loaded via \code{rbi::bi_model} may be passed.}
\item{previous_model_path}{A character string giving the path to a previous LiBBi model (saved as an .rds). This will replace the default model and
override initial settings.}
\item{gen_data}{Logical, defaults to /code{TRUE}. Should data be synthesised using the model and priors.}
\item{run_time}{Numeric, the number of years to run the model fitting and simulation for, defaults to 74 (i.e from 1931 until 2005).}
\item{time_scale}{Character, defaults to \code{"year"}. A monthly timescale can also be set with \code{"month" }.}
\item{plot_obs}{Logical, defaults to \code{TRUE}. Should input data be plotted}
\item{sample_priors}{Logical, defaults to \code{FALSE}. Should the model priors be sampled.}
\item{prior_samples}{Numeric, the number of samples to take from the priors. Defaults to 1000.}
\item{optim}{Logical defaults to \code{TRUE}. Should the determinsitic model be optimised prior to other fitting steps.}
\item{nparticles}{Numeric, the initial number of particles to use in the particle filters. Defaults to \code{NULL}, in which case the number of data points
is used as the initial particle number rounded to the nearest power of 2.}
\item{adapt_particles}{Logical, defaults to \code{FALSE}. Should the number of particles be adapted.}
\item{adapt_part_samples}{Numeric, the number of samples to take from the priors when adapting the number of particles. Defaults to 1000.}
\item{adapt_part_it}{Numeric, the number of iterations to use for adapting the number of particles. Defaults to 10.}
\item{min_particles}{Numeric, the starting number of particles to use for adaption. If \code{NULL} uses \code{nparticles}.}
\item{max_particles}{Numeric, the maximum number of particles to use for adaption. If \code{NULL} then defaults to \code{4 * min_particles}}
\item{proposal_param_block}{A character string containing a LiBBi proposal parameter block. Defaults to \code{NULL} in
which case the LiBBi defaults will be used.}
\item{proposal_initial_block}{A character string containing a LiBBi proposal initial block. Defaults to \code{NULL} in
which case the LiBBi defaults will be used.}
\item{adapt_proposal}{Logical, defaults to \code{TRUE}. Should the proposal be adjusted to improve the acceptance rate.}
\item{adapt_prop_samples}{Numeric, the number of samples to take when adapting the proposal distribution. Defaults to 1000. Initially 5 times this number will be sampled
in order to move the chain out of high unlikely parameter regions.}
\item{adapt_prop_it}{Numeric, defaults to 10. The number of iterations to use for adapting the proposal.}
\item{adapt}{Character string, defaults to "both". The type of adaption to use for the proposal see \code{rbi.helpers::adapt_proposal} for details.}
\item{adapt_scale}{Numeric, defaults to 2. The scale to use to adapt the proposal.}
\item{min_acc}{Numeric, defaults to 0.05. The minimum target acceptance rate.}
\item{max_acc}{Numeric, defaults to 0.4. The maximum target acceptance rate.}
\item{fit}{Logical, defaults to \code{TRUE}. Should the model be fitted with 1000 samples extracted.}
\item{posterior_samples}{Numeric, the number of samples to take from the posterior estimated using pmcmc (requires \code{fit = TRUE}). Defaults to 1000.}
\item{thin}{Numeric, the thinning interval to use between posterior samples. May reduce the correlation between samples and reduces memory.}
\item{burn_prop}{Numeric (between 0 and 1). The proportion of the chain to discard as burn-in.}
\item{time_for_resampling}{Numeric, defaults to 0 (i.e off). Overall real time (minutes) to allocate to move steps for the SMC sampler. If set to be non-zero then this will
overvide rejuvernaiton and effective sample size setting.}
\item{sample_ess_at}{Numeric defaults to 0.8. The thresold of the effective sample size (ess) at which to rejuvernate the particles.}
\item{rejuv_moves}{Numeric, defaults to \code{NULL}. The number of MCMC samples to take for each rejuvernation step. If \code{NULL} is set so that
the acceptance rate of each rejuvernation step is at least 1 minus the effective sample size thresold. This is based on the estimated acceptance rate after adaption. If proposal adaption is not used then it assumed that
the accpetance rate is 5\% only usable for testing purposes.}
\item{nthreads}{Numeric, defaults to 4. The number of parallel jobs to run. The most efficient option is likely to be to match the
number of cores available.}
\item{verbose}{Logical, defaults to \code{TRUE}. Should progress messages and output be printed.}
\item{libbi_verbose}{Logical, defaults to \code{FALSE}. Should \code{libbi} produce verbose progress and warnings messages.}
\item{fitting_verbose}{Logical, defaults to \code{FALSE}. Should \code{libbi} produce verbose progress and warnings messages whilst fitting.}
\item{pred_states}{Logical defaults to \code{TRUE}. Should states be predicted over all time (from model initialisation to 35 years ahead of final run time).
If set to \code{FALSE} states will only be estimated for times with observed data points.}
\item{browse}{Logical, defaults to \code{FALSE}. Should the function be run in debug mode using \code{browser}.}
\item{const_pop}{Logical, defaults to \code{FALSE}. Should a constant population be maintained using births equals deaths.}
\item{no_age}{Logical, defaults to \code{FALSE}. Should ageing be disabled.}
\item{no_disease}{Logical, defaults to \code{FALSE}. Should disease be removed from the model}
\item{scale_rate_treat}{Logical, defaults to \code{TRUE}. Scales the rate of treatment over time from introduction in 1952 to assumed modern standard in 1990.}
\item{years_of_data}{Numeric, the years modern case data to filter for. If not given all are returned.}
\item{years_of_age}{Numeric, the years of age distributed cases to fit to. Defaults to all years available.}
\item{age_groups}{Numeric, the numeric age groups to include in the observed data, defaults to \code{NULL} in
which case no age groups are included.}
\item{spacing_of_historic_tb}{Numeric, defaults to 1. Mod to use to identify years of data to use for.}
\item{aggregated_observed}{Logical, defaults to \code{FALSE}. Should aggregated observational data be used.}
\item{initial_uncertainty}{Logical, should initial state and parameter uncertainty be included. Defaults to \code{TRUE}.}
\item{noise}{Logical, should process noise be included. Defaults to \code{TRUE}. If \code{FALSE} then noise will still be included
from the measurement model.}
\item{scale_transmission}{A character string defaults to \code{"none"}. The default ensures that the transmission probability is constant across all age groups. Other options include;
\code{"young_adult"}. These add a modifiying parameter for young adults (15-24).}
\item{save_output}{Logical, defaults to \code{FALSE}. Should the model results be saved as a test dataset.}
\item{reports}{Logical, defaults to \code{TRUE}. Should model reports be generated. Only enabled when \code{save_output = TRUE}.}
\item{seed}{Numeric, the seed to use for random number generation.}
\item{scale_noukborn_mixing}{A character string defaults to \code{"none"}. The default ensures that non-UK born mixing is constant across all age groups. Other options include;
\code{"young_adult"}. These add a modifiying parameter for young adults (15-24).}
}
\value{
A LibBi model object based on the inputed test model.
}
\description{
A function to fit the models in development through the full fitting pipeline based on synthetic data or observed data.
}
\examples{
## Function code:
fit_model
}