clusterModel: Calculate cluster model estimates using beta binomial model

View source: R/clusterModel.R

clusterModelR Documentation

Calculate cluster model estimates using beta binomial model

Description

This function calculate smoothed direct estimates at given admin level.

Usage

clusterModel(
  data,
  cluster.info,
  admin.info,
  X = NULL,
  X.unit = NULL,
  X.pixel = NULL,
  admin,
  CI = 0.95,
  model = c("bym2", "iid"),
  stratification = FALSE,
  aggregation = FALSE,
  nested = FALSE,
  interact = FALSE,
  overdisp.mean = 0,
  overdisp.prec = 0.4,
  pc.u = 1,
  pc.alpha = 0.01,
  pc.u.phi = 0.5,
  pc.alpha.phi = 2/3,
  ...
)

Arguments

data

dataframe that contains the indicator of interests(column name is value), output of getDHSindicator function

cluster.info

dataframe that contains admin 1 and admin 2 information and coordinates for each cluster.

admin.info

dataframe that contains population and urban/rural proportion at specific admin level

X

dataframe that contains areal covariates, the first column should be the same admin name as in admin.info$data.

X.unit

dataframe that contains unit covariates, must contain cluster

X.pixel

dataframe that contains pixel covariates, must contain 1. admin1.name or admin2.name.full, 2. Population, 3. strata if stratification==T

admin

admin level for the model

CI

Credible interval to be used. Default to 0.95.

model

smoothing model used in the random effect. Options are independent ("iid") or spatial ("bym2").

stratification

whether or not to include urban/rural stratum.

aggregation

whether or not report aggregation results.

nested

whether or not to fit a nested model.

interact

whether or not to fit a admin1 x urban/rural model.

overdisp.mean

prior mean for logit(d), where d is the intracluster correlation.

overdisp.prec

prior precision for logit(d), where d is the intracluster correlation.

pc.u

pc prior u for iid or bym2 precision.

pc.alpha

pc prior alpha for iid or bym2 precision.

pc.u.phi

pc prior u for bym2 mixing paramete.

pc.alpha.phi

pc prior u for bym2 mixing paramete.

...

additional arguments for internal functions.

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.info1 <- adminInfo(poly.adm = ZambiaAdm1,
                        admin = 1,
                        agg.pop =ZambiaPopWomen$admin1_pop,
                        proportion = ZambiaPopWomen$admin1_urban)
cl_res_ad1 <- clusterModel(data=data,
                  cluster.info = cluster.info,
                  admin.info = admin.info1,
                  stratification = FALSE,
                  model = "bym2",
                  admin = 1,
                  aggregation = TRUE,
                  CI = 0.95)
cl_res_ad1$res.admin1

# compare with the DHS direct estimates
dhs_table <- get_api_table(country = "ZM",
                           survey = "ZM2018DHS",
                           indicator = "RH_ANCN_W_N4P",
                           simplify = TRUE)
subset(dhs_table, ByVariableLabel == "Five years preceding the survey")


## End(Not run)


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