sim: Generates simulations of expected mortality by simulating the...

Description Usage Arguments Details Value Examples

View source: R/sim.R

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

1
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

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
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)

attrib documentation built on March 30, 2021, 5:11 p.m.