intervalPlot: Get scatter plot for any two model results

View source: R/intervalPlot.R

intervalPlotR Documentation

Get scatter plot for any two model results

Description

This function return scatter plot at admin 1 level for any two model results

Usage

intervalPlot(
  admin = 0,
  compare = FALSE,
  model = NULL,
  group = FALSE,
  sort_by = NULL,
  decreasing = FALSE
)

Arguments

admin

level of plot

compare

plot for compare multiple plot or not

model

list of model results using surveyPrev

group

plot by group or not

sort_by

the name of the model to sort the areas by. Default to be NULL

decreasing

whether the regions are sorted in decreasing order. Default to be NULL

Value

This function returns the dataset that contain district name and population for given tiff files and polygons of admin level.

Author(s)

Qianyu Dong

Examples

## Not run: 

geo <- getDHSgeo(country = "Zambia", year = 2018)
data(ZambiaAdm1)
data(ZambiaAdm2)
data(ZambiaPopWomen)
cluster.info <- clusterInfo(geo = geo,
                            poly.adm1 = ZambiaAdm1,
                            poly.adm2 = ZambiaAdm2)

# "RH_ANCN_W_N4P" is an indicator for having more than four ANC visits.
#  In previous versions of the package, it is labeled "ancvisit4+".
dhsData <- getDHSdata(country = "Zambia",
                                 indicator = "RH_ANCN_W_N4P",
                                 year = 2018)
data <- getDHSindicator(dhsData, indicator = "RH_ANCN_W_N4P")
admin.info2 <- adminInfo(poly.adm = ZambiaAdm2,
                        admin = 2,
                        agg.pop =ZambiaPopWomen$admin2_pop,
                        proportion = ZambiaPopWomen$admin2_urban)
 # unstratified model
cl_res_ad2_unstrat <- clusterModel(data = data,
                  cluster.info = cluster.info,
                  admin.info = admin.info2,
                  stratification = FALSE,
                  model = "bym2",
                  admin = 2,
                  aggregation = TRUE,
                  CI = 0.95)

head(cl_res_ad2_unstrat$res.admin2)
head(cl_res_ad2_unstrat$agg.admin1)
plots <- intervalPlot(cl_res_ad2_unstrat)
plots[["Central"]]

 # unstratified model
cl_res_ad2 <- clusterModel(data = data,
                  cluster.info = cluster.info,
                  admin.info = admin.info2,
                  stratification = TRUE,
                  model = "bym2",
                  admin = 2,
                  aggregation = TRUE,
                  CI = 0.95)
head(cl_res_ad2$res.admin2)
head(cl_res_ad2$agg.admin1)
plots <- intervalPlot(cl_res_ad2)
plots[["Central"]]

library(patchwork)
wrap_plots(plots, ncol = 5)


## End(Not run)


surveyPrev documentation built on June 19, 2026, 5:06 p.m.