Skip to content

Commit e718899

Browse files
committed
More tweaks to md_functions and variation of watts added
1 parent 0c55c9a commit e718899

File tree

1 file changed

+26
-14
lines changed

1 file changed

+26
-14
lines changed

vignettes/md_functions.Rmd

+26-14
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,7 @@ This vignette shows an overview of the `pipster` package functions for micro dat
3434

3535
- `pipmd_watts()`
3636

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:
3838

3939
- `pipmd_welfare_share_at()`
4040

@@ -44,24 +44,24 @@ It also provides a series of functions to calculate distributional measures and
4444

4545
## Micro Data Sample
4646

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:
4848

49-
- **welfare**: welfare (income or consumption)
49+
- **welfare**: welfare (income or consumption).
5050
- **weight**: population weights.
5151

52-
Here is a preview of the data:
52+
Here is a preview of the first 10 observations:
5353

5454
```{r data, echo=FALSE}
5555
pip_md |>
56-
head() |>
56+
head(n=100) |>
5757
print()
5858
```
5959

6060
## Case 1: Poverty Profiling
6161
`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:
6262

6363
$$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$).
6565

6666
### 1.1 Poverty Headcount
6767
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
134134
```
135135

136136

137-
## Case 2: Inequality Measures: Additional Inequality and Poverty Measures
137+
## Case 2: Additional Inequality and Poverty Measures
138138
`pipster` can also be used to easily calculate additional inequality measures.
139139
The **Gini coefficient** can be calculated using `pipmd_gini()` like so:
140140
```{r gini}
@@ -144,22 +144,34 @@ gini <- pipmd_gini(welfare = pip_md$welfare,
144144
print((paste0("The gini index is ", round(gini$value, 2))))
145145
```
146146

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:
148157
```{r watts}
158+
z <- 3 # set the poverty line
149159
watts <- pipmd_watts(welfare = pip_md$welfare,
150160
weight = pip_md$weight,
151161
povline = z)
162+
152163
print((paste0("The Watts index is ", round(watts$watts, 2))))
153164
```
154165

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

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)
162172
173+
print((paste0("The Watts index is ", round(watts$watts, 2))))
174+
```
163175
## Case 3: Welfare Shares
164176

165177
### 3.1 Welfare share for a specific number of quantiles

0 commit comments

Comments
 (0)