Description Usage Arguments Details Value Likelihood function
Build a function that given a set of model parameters runs the model and computes the log-likelihood for the model.
1 2 3 4 5 6 7 | gen_likelihood(
hparms,
fixed_parms = NULL,
maxdate = NULL,
verbose = FALSE,
waicmode = FALSE
)
|
hparms |
Hyperparameters for the calculation, as described in |
fixed_parms |
A named vector of parameters to use as fixed values for parameters not passed to the likelihood function. Note these "fixed" parameters can still be overridden by passing an explicit value. |
maxdate |
Last date to use in the calibration. Default is 2020-06-30 |
verbose |
If |
waicmode |
If |
The observational data is the daily county-by-county reports of new confirmed
COVID-19 cases. We are using the New York Times dataset
(https://github.com/nytimes/covid-19-data
), which is based on reports
from state departments of health, including the VDH. For statistics on COVID-19
testing, we use the vacovdata
dataset, which was compiled
by the COVID Tracking project (https://covidtracking.com/
).
The model parameters currently recognized are:
(real) Log of the baseline transmissibility
(real) Coefficient of population density in log-transmissibility
(real > 0) The initial average infection duration
(real > 0) The average incubation time
(real > 0) The average time from infection to symptom onset. Note that this parameter is probably not identifiable with our current data.
(real > 0) The testing bias factor. That is, the positive test rate divided by the true infection rate. b can be different from 1 because of false positives or because testing is targeted to people suspected of having the disease. (Generally, we expect b>1, but we don't require this.)
(real > 0) The initial number of infected people, once the infection starts. This is taken to be the same in all counties.
For the time being, we start tracking the infection in Fairfax county on day 30, and all of the counties are delayed relative to Fairfax by a number of days equal to the difference between their first observed case and the first case observed in Fairfax.
To compute the likelihood, our assumption is that the output of the model represents an average infection rate. The average observation rate is then
\bar{N}_o = \bar{N}_I f_t b,
where f_t is the fraction of the total population tested. We then assume that the actual observations are distributed as
N_o \sim Pois(\bar{N}_o).
A function that takes a named list of model parameters and returns a log-likelihood value. See details for the parameters recognized and the output of the function returned.
By default, the function produced will return a single value, which is the sum of
The log-likelihood function, summed over all data points
A correction for the hospitalization fraction
A correction for the symptomatic fraction
Technically, the latter two are priors, since they don't depend on the observations, but the model must be run in order to compute them, so they are computed here.
If the waicmode
flag is set, then the function will return detailed information
on the contribution of each data point to the log-likelihood. The result will be a
data frame containing
date
locality
expected counts
observed counts
Hypergeometric parameters x, m, n, and k
log likelihood
Additionally, the antibody prevalence and symptomatic fraction corrections
will be attached to the data frame as attributes (hfadjust
and
fsadjust
).
The default mode output can be used in optimizations or Markov chain Monte Carlo. The waicmode output is useful for computing the WAIC, or for diagnosing which counties and/or days are favoring one model over another.
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.