Convert surveil model results to age standardized rates using a fixed age distribution

standardize(x, label, standard_pop)

Arguments

x

A fitted surveil model

label

Labels (character strings) for the age groups that correspond to the values of stand_pop. All levels of the grouping variable used to fit the model (i.e., names(x$data$cases)) must be present in label.

standard_pop

Standard population values corresponding to the age groups specified by label.

Value

A list, also of class "stand_surveil", containing the entire contents of the user-provided surveil model plus the following:

standard_summary

summary data frame of standardized rates (means and 95 percent credible intervals)

standard_samples

a data frame of Markov chain Monte Carlo (MCMC) samples from the posterior probability distribution for the standardized rates

standard_label

user-provided age-group labels

standard_pop

user-provided standardized population sizes (ordered as standard_label)

Examples

data(cancer)
data(standard)

head(standard)
head(cancer)

cancer2 <- subset(cancer, grepl("55-59|60-64|65-69", Age))
fit <- stan_rw(cancer2, time = Year, group = Age,
              chains = 2, iter = 1e3) # for speed only

stands <- standardize(fit,
                      label = standard$age,
                      standard_pop = standard$standard_pop)
print(stands)
plot(stands, style = "lines")