## specify model
mod <- mod_pois(divorces ~ age + sex + time,
data = nzl_divorces,
exposure = population) |>
set_n_draw(n_draw = 100) ## smaller sample, so 'augment' faster
## draw from the prior distribution
mod |> augment()
## fit model
mod <- mod |>
fit()
## draw from the posterior distribution
mod |> augment()
## insert a missing value into outcome variable
divorces_missing <- nzl_divorces
divorces_missing$divorces[1] <- NA
## fitting model and calling 'augument'
## creates a new variable called '.divorces'
## holding observed and imputed values
mod_pois(divorces ~ age + sex + time,
data = divorces_missing,
exposure = population) |>
fit() |>
augment()
## specifying a data model for the
## original data also leads to a new
## variable called '.divorces'
mod_pois(divorces ~ age + sex + time,
data = nzl_divorces,
exposure = population) |>
set_datamod_outcome_rr3() |>
fit() |>
augment()
Run the code above in your browser using DataLab