sim {attrib} | R Documentation |
Generates simulations of expected mortality by simulating the model coefficients.
Description
With the given fit from fit_attrib the function sim, from package arm as described in Gelman, Hill (2012) <doi:10.1017/CBO9780511790942>, is used to generate 500 simulations of all the coefficients, from there respective posterior distributions. This is then used to compute the expected response for all simulations and rows in the input dataset.
Usage
sim(fit, data, n_sim)
Arguments
fit |
A model fit created by fit_attrib |
data |
The data with either observed values or reference values. |
n_sim |
Number of simulations |
Details
vignette("intro", package="attrib")
Value
A dataset with 500 simulations of the expected response for each row in the original dataset.
Examples
response <- "deaths"
fixef <- "pr100_ili_lag_1 + sin(2 * pi * (week - 1) / 52) + cos(2 * pi * (week - 1) / 52)"
ranef <- " (pr100_ili_lag_1| season)"
offset <- "log(pop)"
data <- attrib::data_fake_nation
fit <- fit_attrib(data = data, response = response, fixef = fixef, ranef = ranef, offset = offset)
n_sim <- 5
sim(fit, data, n_sim)
[Package attrib version 2021.1.2 Index]