sim {attrib} | R Documentation |
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.
sim(fit, data, n_sim)
fit |
A model fit created by fit_attrib |
data |
The data with either observed values or reference values. |
n_sim |
Number of simulations |
vignette("intro", package="attrib")
A dataset with 500 simulations of the expected response for each row in the original dataset.
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)