directEST: Calculate direct estimates

View source: R/directEST.R

directESTR Documentation

Calculate direct estimates

Description

This function calculate direct estimates at given admin level.

Usage

directEST(
  data,
  cluster.info,
  admin,
  strata = "all",
  CI = 0.95,
  weight = c("population", "survey")[1],
  admin.info = NULL,
  aggregation = FALSE,
  alt.strata = NULL,
  var.fix = FALSE,
  threshold = 1e-12,
  ...
)

Arguments

data

dataframe that contains the indicator of interests, output of getDHSindicator function

cluster.info

list contains data and wrong.points. data contains admin 1 and admin 2 information and coordinates for each cluster. wrong.points. contains cluster id for cluster without coordinates or admin 1 information. Output of getDHSindicator function

admin

admin level for the model.

strata

use only urban or rural data, only for national level model

CI

Credible interval to be used. Default to 0.95.

weight

the weight used for aggregating result, "population" or "survey"

admin.info

list contains data and mat, data contains population and urban/rural proportion at specific admin level and mat is the adjacency matrix, output of adminInfo function

aggregation

whether or not report aggregation results.

alt.strata

the variable name in the data frame that correspond to the stratification variable. Most of the DHS surveys are stratified by admin 1 area crossed with urban/rural, which is the default stratification variable created by the function (when alt.strata = NULL). When a different set of strata is used. The stratification variable should be included in the data and alt.strata should be set to the column name.

var.fix

Whether to add phantom cluster to fix admin 2 direct estimate with variance close to 0.

threshold

the threshold of variance to implement the variance fix method.

...

Additional arguments passed on to the 'smoothSurvey' function

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: 

##
## Direct estimation of ANC visit 4+ proportion
##

geo <- getDHSgeo(country = "Zambia", year = 2018)
data(ZambiaAdm1)
data(ZambiaAdm2)
data(ZambiaPopWomen)
cluster.info<-clusterInfo(geo=geo, poly.adm1=ZambiaAdm1, poly.adm2=ZambiaAdm2,
by.adm1 = "NAME_1",by.adm2 = "NAME_2")
# "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")
res_ad1 <- directEST(data = data,
                  cluster.info = cluster.info,
                  admin = 1,
                  aggregation = FALSE)
res_ad1
# 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")

##
## Changing customized stratification variable
##

data_alt <- data
# Assuming the stratification is done with only admin1 area
# and not stratified by urban and rural
# Note that this is not the correct stratification, but we use
#  this as an illustration to create user-specified strata variable
data_alt$new_strata <- data_alt$v024
res_ad1_wrong <- directEST(data = data_alt,
                  cluster.info = cluster.info,
                  admin = 1,
                  aggregation = FALSE,
                  alt.strata = "new_strata")
res_ad1_wrong

## End(Not run)


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