forked from NoraWuerz/povmap
-
Notifications
You must be signed in to change notification settings - Fork 5
/
README.Rmd
160 lines (106 loc) · 4.54 KB
/
README.Rmd
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
---
output: github_document
---
<!-- README.md is generated from README.Rmd. Please edit that file -->
```{r, include = FALSE}
knitr::opts_chunk$set(
collapse = TRUE,
comment = "#>",
fig.path = "man/figures/README-",
out.width = "100%"
)
pacman::p_load(povmap)
```
# povmap: Extension to the package emdi <img src="man/figures/logo.png" align="right" height="139" />
<!-- badges: start -->
[![R-CMD-check](https://github.com/SSA-Statistical-Team-Projects/povmap/actions/workflows/R-CMD-check.yaml/badge.svg)](https://github.com/SSA-Statistical-Team-Projects/povmap/actions/workflows/R-CMD-check.yaml)
<!-- badges: end -->
## Overview
The R package povmap is designed to facilitate the production
of small area estimates of means and poverty headcount rates. It adds several
new features to the [emdi](https://cran.r-project.org/web/packages/emdi/index.html) package.
These include new options for:
* incorporating survey weights,
* ex-post benchmarking of estimates,
* two additional outcome variable transformations,
* and several new convenience functions to assist with reporting results.
## Installation
```{r, eval = FALSE}
## To install the package from CRAN, run the following in R:
install.packages("povmap")
```
## Development Version
```{r, eval = FALSE}
## To get a bug fix or to use a feature from the development version, you can install
## the development version of povmap from GitHub. Sometimes, povmap maybe unavailable in CRAN (although this is typically ## unlikely)
devtools::install_github("SSA-Statistical-Team-Projects/povmap")
## alternatively,
remotes::install_github("SSA-Statistical-Team-Projects/povmap")
```
## Usage
```{r, message = FALSE}
library(povmap)
### estimate a unit level model with sample and population weights
ebp_model <- ebp(fixed = eqIncome ~ gender + eqsize + cash +
self_empl + unempl_ben + age_ben + surv_ben + sick_ben +
dis_ben + rent + fam_allow + house_allow + cap_inv +
tax_adj,
pop_data = eusilcA_pop,
pop_domains = "district",
smp_data = eusilcA_smp,
smp_domains = "district",
na.rm = TRUE,
weights = "weight",
pop_weights = "hhsize",
MSE = TRUE,
weights_type = "nlme",
B = 2,
L = 2)
summary(ebp_model)
### showcasing the actual poverty map
load_shapeaustria() ## reading in the shapefile
## the new `map_plot` now requires sf shapefile objects
## rather than the older `sp` (it's dependencies are being phased out)
map_plot(object = ebp_model,
MSE = FALSE,
CV = FALSE,
map_obj = shape_austria_dis,
indicator = c("Head_Count"),
map_dom_id = "PB")
###### ---------------------------------------------------- #######
# compute direct estimates
direct_est <- direct(y = "eqIncome",
smp_data = eusilcA_smp,
smp_domains = "district",
weights = "weight",
var = TRUE,
B = 2)
### some general pre-estimation statistics
ebp_reportdescriptives(model = ebp_model,
direct = direct_est,
smp_data = eusilcA_smp,
weights = "weight",
pop_weights = "hhsize",
CV_level = "state",
pop_data = eusilcA_pop,
pop_domains = "district")
### compare the means between survey and census prior to model estimation
variables <- c("gender", "eqsize", "cash", "self_empl",
"unempl_ben", "age_ben", "surv_ben",
"sick_ben", "dis_ben", "rent", "fam_allow",
"house_allow", "cap_inv", "tax_adj")
ebp_test_means(varlist = variables,
pop_data = eusilcA_pop,
smp_data = eusilcA_smp,
weights = "weight")
### report EBP model coefficients with significance levels
ebp_reportcoef_table(ebp_model, 4)
### compute the CVs (several CV types are estimated including
### Horowitz Thompson CVs, CVs accounting for the design effect,
### bootstraped CVs i.e. calibrated or naive)
head(ebp_compute_cv(model = ebp_model, calibvar = "gender"))
### report the model fit and normality assumptions
ebp_normalityfit(model = ebp_model)
```
## Getting help
If you encounter a clear bug, please file an issue with a minimal reproducible example on [GitHub](https://github.com/SSA-Statistical-Team-Projects/povmap/issues)