Conditions a composed model on an observed time series and samples from the posterior with NUTS.
fit(model, y, method = nuts(), dates = NULL, seed = NULL)A composed model from IDModel(), or a julia() expression
that builds one.
Numeric vector of observations, one per time point. Missing observations are not supported, and neither is a matrix of stratified observations.
Sampler settings from nuts().
Optional vector of dates (Date or POSIXt), one per
observation, used when plotting. Forecasts continue at the spacing of
the last two dates.
Optional integer seed for the Julia random number generator.
An object of class cidm_fit with elements
Posterior draws of the model parameters, a posterior::draws_df.
Sampler diagnostics per draw (e.g. numerical_error for
divergent transitions), a posterior::draws_df.
Named list of draws x time matrices of generated
quantities: Z_t (the latent process), I_t (infections),
expected_y_t (expected observations), predicted_y_t (posterior
predictive observations) and, for renewal models, Rt. It also holds
generated_y_t, which is the observed series repeated for every draw,
because the model was conditioned on it. In expected_y_t and
predicted_y_t, time points the model does not score, such as those
before a reporting delay has elapsed, are NaN.
The inputs.
predict.cidm_fit() to forecast, plot.cidm_fit() to
visualise the fit.
Other inference:
nuts(),
plot.cidm_fit(),
predict.cidm_fit(),
simulate.julia_spec(),
summary.cidm_fit()
if (FALSE) { # \dontrun{
model <- IDModel(
Renewal(generation_time = Gamma(shape = 6.5, scale = 0.62), rt = AR()),
NegativeBinomialError(cluster_factor = HalfNormal(0.1))
)
y <- simulate(model, n = 40, seed = 1)$generated_y_t[1, ]
fitted <- fit(model, y, method = nuts(draws = 250, warmup = 250))
fitted
plot(fitted, type = "Rt")
} # }