fhModel: Calculate smoothed direct estimates

View source: R/smthdirectEST.R

fhModelR Documentation

Calculate smoothed direct estimates

Description

This function calculate smoothed direct estimates at given admin level.

Usage

fhModel(
  data,
  cluster.info,
  admin.info = NULL,
  X = NULL,
  nested = FALSE,
  admin,
  CI = 0.95,
  model = c("bym2", "iid"),
  aggregation = FALSE,
  alt.strata = NULL,
  var.fix = FALSE,
  ...
)

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.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

X

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

nested

whether or not to fit a nested model.

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").

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 use fix variance admin 2 direct estimate as input for the model.

...

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: 
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,
                        by.adm = "NAME_1",
                        agg.pop =ZambiaPopWomen$admin1_pop,
                        proportion = ZambiaPopWomen$admin1_urban)
smth_res_ad1 <- fhModel(data,
                       cluster.info = cluster.info,
                       admin.info = admin.info1,
                       admin = 1,
                       model = "bym2",
                       aggregation = F)
smth_res_ad1

## End(Not run)


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