# NOT RUN {
data(DemoData)
deta(DemoMap)
years <- levels(DemoData[[1]]$time)
data <- countrySummary_mult(births = DemoData,
years = years,
regionVar = "region", timeVar = "time",
clusterVar = "~clustid+id",
ageVar = "age", weightsVar = "weights",
geo.recode = NULL)
# obtain maps
geo <- DemoMap$geo
mat <- DemoMap$Amat
# combine data from multiple surveys
data_agg <- aggregateSurvey(data)
# Model fitting with INLA
years.all <- c(years, "15-19")
fit <- fitINLA(data = data_agg, geo = NULL, Amat = NULL,
year_names = years.all, year_range = c(1985, 2019),
rw = 2, is.yearly=TRUE,
m = 5, type.st = 4)
# Projection
out <- projINLA(fit, is.yearly = TRUE)
# National smoothed plot
plot(out, is.yearly=TRUE, is.subnational=FALSE) + ggplot2::ggtitle("National yearly model")
# National smoothed plot with the aggregated direct estimates
plot(out, is.yearly=TRUE, is.subnational=FALSE, data.add = data_agg,
option.add = list(point = "u5m", lower = "lower", upper = "upper"),
color.add = "orange") + ggplot2::ggtitle("National yearly model")
# National smoothed plot with the survey-specific direct estimates
plot(out, is.yearly=TRUE, is.subnational=FALSE, data.add = data,
option.add = list(point = "u5m", by = "surveyYears"),
color.add = "darkblue") + ggplot2::ggtitle ("National yearly model")
fit <- fitINLA(data = data_agg, geo = geo, Amat = mat,
year_names = years.all, year_range = c(1985, 2019),
rw = 2, is.yearly=TRUE,
m = 5, type.st = 4)
# Projection
out <- projINLA(fit, Amat = mat, is.yearly = TRUE)
# Subnational estimates
plot(out, is.yearly=TRUE, is.subnational=TRUE) + ggplot2::ggtitle("Subnational yearly model")
# Subnational estimates with the aggregated direct estimates
plot(out, is.yearly=TRUE, is.subnational=TRUE, data.add = data_agg, option.add =
list(point = "u5m", lower = "lower", upper = "upper")) +
ggplot2::ggtitle("Subnational yearly model") + facet_wrap(~region)
# Subnational estimates with survey-specific direct estimates
plot(out, is.yearly=TRUE, is.subnational=TRUE, data.add = data, option.add =
list(point = "u5m", by = "surveyYears")) +
ggplot2::ggtitle("Subnational yearly model") + facet_wrap(~region)
# }
Run the code above in your browser using DataLab