Calculate Standard Errors and Variance-Covariance Matrices for DHS Subnational Estimates
Source:R/calculate_SE_data_from_DTA.R
calculate_SE_data_from_DTA.RdThis function reads a DHS dataset, constructs a survey design object, computes weighted estimates of modern contraceptive method sources by sector category, and exports both the proportion matrix and the variance-covariance matrix to Excel files.
Value
A list with two elements (returned invisibly):
- prop_mat
Data frame of weighted estimates with counts
- vcov_matrix
Variance–covariance matrix tibble
Output files are written to disk as a side effect.
Details
The function:
Reads DHS survey microdata.
Constructs derived variables such as modern method, sector, and method source.
Builds a survey design using survey.
Computes weighted proportions using
svyby().Extracts the associated variance–covariance matrix.
Exports both datasets as Excel workbooks.