You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardexpand all lines: vignettes/md_functions.Rmd
+26-14
Original file line number
Diff line number
Diff line change
@@ -34,7 +34,7 @@ This vignette shows an overview of the `pipster` package functions for micro dat
34
34
35
35
-`pipmd_watts()`
36
36
37
-
It also provides a series of functions to calculate distributional measures and to select and validate the best Lorenz curve for subsequent estimation:
37
+
It also provides a series of functions to calculate welfare shares, cumulative welfare shares and income thresholds for each quantile:
38
38
39
39
-`pipmd_welfare_share_at()`
40
40
@@ -44,24 +44,24 @@ It also provides a series of functions to calculate distributional measures and
44
44
45
45
## Micro Data Sample
46
46
47
-
In this vignette, we will explore several typical scenarios in which the pipster package can be effectively utilized. In each of these scenario, we will use a sample dataset with 1000 observations, `pip_md`, available with this package. The variables are the following:
47
+
In this vignette, we will explore several typical scenarios in which the `pipster` package can be effectively utilized. In each of these scenario, we will use a sample dataset with 1000 observations, `pip_md`, available with this package. The variables are the following:
48
48
49
-
-**welfare**: welfare (income or consumption)
49
+
-**welfare**: welfare (income or consumption).
50
50
-**weight**: population weights.
51
51
52
-
Here is a preview of the data:
52
+
Here is a preview of the first 10 observations:
53
53
54
54
```{r data, echo=FALSE}
55
55
pip_md |>
56
-
head() |>
56
+
head(n=100) |>
57
57
print()
58
58
```
59
59
60
60
## Case 1: Poverty Profiling
61
61
`pipster` allows the user to estimate poverty measures quickly and accurately. To demonstrate its use, we can manually calculate FGT(0), FGT(1), and FGT(2), and then replicate it using only `pipster` functions. The Foster-Greer-Thorbecke indices are a family of poverty metrics which can be derived by substituting different values of the parameter $\alpha$ into the following equation:
62
62
63
63
$$F G T_\alpha=\frac{1}{N} \sum_{i=1}^H\left(\frac{z-y_i}{z}\right)^\alpha$$
64
-
where $z$ is the povety line, $N$ the total population, and $H$ the number of poor individuals (with income, or $y_i<= z$).
64
+
where $z$ is the povety line, $N$ the total population, and $H$ the number of poor individuals (with income, or $y_i$, $<= z$).
65
65
66
66
### 1.1 Poverty Headcount
67
67
The poverty headcount, or FGT(1) can be calculated as follows:
@@ -134,7 +134,7 @@ print(paste0("The poverty severity index is ", round(pip_FGT2$pov_severity*100,2
134
134
```
135
135
136
136
137
-
## Case 2: Inequality Measures: Additional Inequality and Poverty Measures
137
+
## Case 2: Additional Inequality and Poverty Measures
138
138
`pipster` can also be used to easily calculate additional inequality measures.
139
139
The **Gini coefficient** can be calculated using `pipmd_gini()` like so:
print((paste0("The gini index is ", round(gini$value, 2))))
145
145
```
146
146
147
-
The **Watts Index** can be calculated using `pipgd_watts()` like so:
147
+
148
+
The **MLD (Mean Logarithmic Deviation)** can be calculated using `pipgd_mld()` like so:
149
+
```{r mld}
150
+
mld <- pipmd_mld(welfare = pip_md$welfare,
151
+
weight = pip_md$weight)
152
+
153
+
print((paste0("The MLD is ", round(mld$value,2))))
154
+
```
155
+
156
+
And finally, the **Watts Index** can be calculated using `pipgd_watts()` specifying the poverty line (`povline`) like so:
148
157
```{r watts}
158
+
z <- 3 # set the poverty line
149
159
watts <- pipmd_watts(welfare = pip_md$welfare,
150
160
weight = pip_md$weight,
151
161
povline = z)
162
+
152
163
print((paste0("The Watts index is ", round(watts$watts, 2))))
153
164
```
154
165
155
-
And finally, the **MLD (Mean Logarithmic Deviation)** can be calculated using `pipgd_mld()` like so:
156
-
```{r mld}
157
-
mld <- pipmd_mld(welfare = pip_md$welfare,
158
-
weight = pip_md$weight)
166
+
In alternative, the user can specify the parameter `times_mean`. In this case, the poverty line will be calculated as the mean of the `welfare` vector multiplied by the `times_mean` parameter.
159
167
160
-
print((paste0("The MLD is ", round(mld$value,2))))
161
-
```
168
+
```{r watts}
169
+
watts <- pipmd_watts(welfare = pip_md$welfare,
170
+
weight = pip_md$weight,
171
+
times_mean = 0.8)
162
172
173
+
print((paste0("The Watts index is ", round(watts$watts, 2))))
174
+
```
163
175
## Case 3: Welfare Shares
164
176
165
177
### 3.1 Welfare share for a specific number of quantiles
0 commit comments