Skip to content

Commit

Permalink
real world examples cleanup
Browse files Browse the repository at this point in the history
  • Loading branch information
ajdamico committed Dec 3, 2023
1 parent 5b89057 commit 5a326ea
Show file tree
Hide file tree
Showing 2 changed files with 28 additions and 44 deletions.
37 changes: 15 additions & 22 deletions 02-poverty.Rmd
Original file line number Diff line number Diff line change
Expand Up @@ -190,24 +190,23 @@ For additional usage examples of `svyarpt`, type `?convey::svyarpt` in the R con

### Real World Examples


This section displays example results using nationally-representative surveys from both the United States and Brazil. We present a variety of surveys, levels of analysis, and subpopulation breakouts to provide users with a point of reference for the range of plausible values of the `svyarpt` function.

#### CPS-ASEC Household Income

```{r}
(
cps_household_arpt <- svyarpt(~ htotval , cps_household_design)
)
svyarpt(~ htotval , cps_household_design)
(cps_household_arpt_by_sex <- svyby( ~ htotval , ~ sex , cps_household_design , svyarpt ) )
svyby(~ htotval , ~ sex , cps_household_design , svyarpt)
```

#### CPS-ASEC Family Income

```{r}
(
cps_family_arpt <- svyarpt(~ ftotval , cps_family_design)
)
svyarpt(~ ftotval , cps_family_design)
(cps_family_arpt_by_sex <- svyby( ~ ftotval , ~ sex , cps_family_design , svyarpt ) )
svyby(~ ftotval , ~ sex , cps_family_design , svyarpt)
```

#### CPS-ASEC Worker Earnings
Expand All @@ -226,27 +225,21 @@ svyby(~ pearnval , ~ sex , cps_ftfy_worker_design , svyarpt)
#### PNAD-Contínua Per Capita Income

```{r}
(
pnadc_per_capita_arpt <-
svyarpt(~ deflated_per_capita_income , pnadc_design , na.rm = TRUE)
)
svyarpt( ~ deflated_per_capita_income , pnadc_design , na.rm = TRUE)
(
pnadc_per_capita_arpt_by_sex <-
svyby( ~ deflated_per_capita_income , ~ sex , pnadc_design , svyarpt , na.rm = TRUE)
)
svyby(~ deflated_per_capita_income ,
~ sex ,
pnadc_design ,
svyarpt ,
na.rm = TRUE)
```

#### PNAD-Contínua Worker Earnings

```{r}
(
pnadc_earnings_arpt <-
svyarpt(~ deflated_labor_income , pnadc_design , na.rm = TRUE)
)
svyarpt( ~ deflated_labor_income , pnadc_design , na.rm = TRUE)
(pnadc_earnings_arpt_by_sex <-
svyby( ~ deflated_labor_income , ~ sex , pnadc_design , svyarpt , na.rm = TRUE))
svyby( ~ deflated_labor_income , ~ sex , pnadc_design , svyarpt , na.rm = TRUE)
```


Expand Down
35 changes: 13 additions & 22 deletions docs/3.1-at-risk-of-poverty-threshold-svyarpt.html
Original file line number Diff line number Diff line change
Expand Up @@ -424,26 +424,23 @@ <h3><span class="header-section-number">3.1.1</span> Replication Example</h3>
</div>
<div id="real-world-examples" class="section level3" number="3.1.2">
<h3><span class="header-section-number">3.1.2</span> Real World Examples</h3>
<p>This section displays example results using nationally-representative surveys from both the United States and Brazil. We present a variety of surveys, levels of analysis, and subpopulation breakouts to provide users with a point of reference for the range of plausible values of the <code>svyarpt</code> function.</p>
<div id="cps-asec-household-income" class="section level4" number="3.1.2.1">
<h4><span class="header-section-number">3.1.2.1</span> CPS-ASEC Household Income</h4>
<div class="sourceCode" id="cb116"><pre class="sourceCode r"><code class="sourceCode r"><span id="cb116-1"><a href="3.1-at-risk-of-poverty-threshold-svyarpt.html#cb116-1" tabindex="-1"></a>(</span>
<span id="cb116-2"><a href="3.1-at-risk-of-poverty-threshold-svyarpt.html#cb116-2" tabindex="-1"></a> cps_household_arpt <span class="ot">&lt;-</span> <span class="fu">svyarpt</span>(<span class="sc">~</span> htotval , cps_household_design)</span>
<span id="cb116-3"><a href="3.1-at-risk-of-poverty-threshold-svyarpt.html#cb116-3" tabindex="-1"></a>)</span></code></pre></div>
<div class="sourceCode" id="cb116"><pre class="sourceCode r"><code class="sourceCode r"><span id="cb116-1"><a href="3.1-at-risk-of-poverty-threshold-svyarpt.html#cb116-1" tabindex="-1"></a><span class="fu">svyarpt</span>(<span class="sc">~</span> htotval , cps_household_design)</span></code></pre></div>
<pre><code>## arpt SE
## htotval 44521 391.72</code></pre>
<div class="sourceCode" id="cb118"><pre class="sourceCode r"><code class="sourceCode r"><span id="cb118-1"><a href="3.1-at-risk-of-poverty-threshold-svyarpt.html#cb118-1" tabindex="-1"></a>(cps_household_arpt_by_sex <span class="ot">&lt;-</span> <span class="fu">svyby</span>( <span class="sc">~</span> htotval , <span class="sc">~</span> sex , cps_household_design , svyarpt ) )</span></code></pre></div>
<div class="sourceCode" id="cb118"><pre class="sourceCode r"><code class="sourceCode r"><span id="cb118-1"><a href="3.1-at-risk-of-poverty-threshold-svyarpt.html#cb118-1" tabindex="-1"></a><span class="fu">svyby</span>(<span class="sc">~</span> htotval , <span class="sc">~</span> sex , cps_household_design , svyarpt)</span></code></pre></div>
<pre><code>## sex htotval se.htotval
## male male 50623.2 455.4800
## female female 39000.0 185.2314</code></pre>
</div>
<div id="cps-asec-family-income" class="section level4" number="3.1.2.2">
<h4><span class="header-section-number">3.1.2.2</span> CPS-ASEC Family Income</h4>
<div class="sourceCode" id="cb120"><pre class="sourceCode r"><code class="sourceCode r"><span id="cb120-1"><a href="3.1-at-risk-of-poverty-threshold-svyarpt.html#cb120-1" tabindex="-1"></a>(</span>
<span id="cb120-2"><a href="3.1-at-risk-of-poverty-threshold-svyarpt.html#cb120-2" tabindex="-1"></a> cps_family_arpt <span class="ot">&lt;-</span> <span class="fu">svyarpt</span>(<span class="sc">~</span> ftotval , cps_family_design)</span>
<span id="cb120-3"><a href="3.1-at-risk-of-poverty-threshold-svyarpt.html#cb120-3" tabindex="-1"></a>)</span></code></pre></div>
<div class="sourceCode" id="cb120"><pre class="sourceCode r"><code class="sourceCode r"><span id="cb120-1"><a href="3.1-at-risk-of-poverty-threshold-svyarpt.html#cb120-1" tabindex="-1"></a><span class="fu">svyarpt</span>(<span class="sc">~</span> ftotval , cps_family_design)</span></code></pre></div>
<pre><code>## arpt SE
## ftotval 55680 473.82</code></pre>
<div class="sourceCode" id="cb122"><pre class="sourceCode r"><code class="sourceCode r"><span id="cb122-1"><a href="3.1-at-risk-of-poverty-threshold-svyarpt.html#cb122-1" tabindex="-1"></a>(cps_family_arpt_by_sex <span class="ot">&lt;-</span> <span class="fu">svyby</span>( <span class="sc">~</span> ftotval , <span class="sc">~</span> sex , cps_family_design , svyarpt ) )</span></code></pre></div>
<div class="sourceCode" id="cb122"><pre class="sourceCode r"><code class="sourceCode r"><span id="cb122-1"><a href="3.1-at-risk-of-poverty-threshold-svyarpt.html#cb122-1" tabindex="-1"></a><span class="fu">svyby</span>(<span class="sc">~</span> ftotval , <span class="sc">~</span> sex , cps_family_design , svyarpt)</span></code></pre></div>
<pre><code>## sex ftotval se.ftotval
## male male 61320.0 504.0308
## female female 48856.2 453.7270</code></pre>
Expand All @@ -467,30 +464,24 @@ <h4><span class="header-section-number">3.1.2.3</span> CPS-ASEC Worker Earnings<
</div>
<div id="pnad-contínua-per-capita-income" class="section level4" number="3.1.2.4">
<h4><span class="header-section-number">3.1.2.4</span> PNAD-Contínua Per Capita Income</h4>
<div class="sourceCode" id="cb132"><pre class="sourceCode r"><code class="sourceCode r"><span id="cb132-1"><a href="3.1-at-risk-of-poverty-threshold-svyarpt.html#cb132-1" tabindex="-1"></a>(</span>
<span id="cb132-2"><a href="3.1-at-risk-of-poverty-threshold-svyarpt.html#cb132-2" tabindex="-1"></a> pnadc_per_capita_arpt <span class="ot">&lt;-</span></span>
<span id="cb132-3"><a href="3.1-at-risk-of-poverty-threshold-svyarpt.html#cb132-3" tabindex="-1"></a> <span class="fu">svyarpt</span>(<span class="sc">~</span> deflated_per_capita_income , pnadc_design , <span class="at">na.rm =</span> <span class="cn">TRUE</span>)</span>
<span id="cb132-4"><a href="3.1-at-risk-of-poverty-threshold-svyarpt.html#cb132-4" tabindex="-1"></a>)</span></code></pre></div>
<div class="sourceCode" id="cb132"><pre class="sourceCode r"><code class="sourceCode r"><span id="cb132-1"><a href="3.1-at-risk-of-poverty-threshold-svyarpt.html#cb132-1" tabindex="-1"></a><span class="fu">svyarpt</span>( <span class="sc">~</span> deflated_per_capita_income , pnadc_design , <span class="at">na.rm =</span> <span class="cn">TRUE</span>)</span></code></pre></div>
<pre><code>## arpt SE
## deflated_per_capita_income 598.16 1.8529</code></pre>
<div class="sourceCode" id="cb134"><pre class="sourceCode r"><code class="sourceCode r"><span id="cb134-1"><a href="3.1-at-risk-of-poverty-threshold-svyarpt.html#cb134-1" tabindex="-1"></a>(</span>
<span id="cb134-2"><a href="3.1-at-risk-of-poverty-threshold-svyarpt.html#cb134-2" tabindex="-1"></a> pnadc_per_capita_arpt_by_sex <span class="ot">&lt;-</span></span>
<span id="cb134-3"><a href="3.1-at-risk-of-poverty-threshold-svyarpt.html#cb134-3" tabindex="-1"></a> <span class="fu">svyby</span>( <span class="sc">~</span> deflated_per_capita_income , <span class="sc">~</span> sex , pnadc_design , svyarpt , <span class="at">na.rm =</span> <span class="cn">TRUE</span>)</span>
<span id="cb134-4"><a href="3.1-at-risk-of-poverty-threshold-svyarpt.html#cb134-4" tabindex="-1"></a>)</span></code></pre></div>
<div class="sourceCode" id="cb134"><pre class="sourceCode r"><code class="sourceCode r"><span id="cb134-1"><a href="3.1-at-risk-of-poverty-threshold-svyarpt.html#cb134-1" tabindex="-1"></a><span class="fu">svyby</span>(<span class="sc">~</span> deflated_per_capita_income ,</span>
<span id="cb134-2"><a href="3.1-at-risk-of-poverty-threshold-svyarpt.html#cb134-2" tabindex="-1"></a> <span class="sc">~</span> sex ,</span>
<span id="cb134-3"><a href="3.1-at-risk-of-poverty-threshold-svyarpt.html#cb134-3" tabindex="-1"></a> pnadc_design ,</span>
<span id="cb134-4"><a href="3.1-at-risk-of-poverty-threshold-svyarpt.html#cb134-4" tabindex="-1"></a> svyarpt ,</span>
<span id="cb134-5"><a href="3.1-at-risk-of-poverty-threshold-svyarpt.html#cb134-5" tabindex="-1"></a> <span class="at">na.rm =</span> <span class="cn">TRUE</span>)</span></code></pre></div>
<pre><code>## sex deflated_per_capita_income se.deflated_per_capita_income
## male male 607.2863 4.266030
## female female 593.8436 2.711941</code></pre>
</div>
<div id="pnad-contínua-worker-earnings" class="section level4" number="3.1.2.5">
<h4><span class="header-section-number">3.1.2.5</span> PNAD-Contínua Worker Earnings</h4>
<div class="sourceCode" id="cb136"><pre class="sourceCode r"><code class="sourceCode r"><span id="cb136-1"><a href="3.1-at-risk-of-poverty-threshold-svyarpt.html#cb136-1" tabindex="-1"></a>(</span>
<span id="cb136-2"><a href="3.1-at-risk-of-poverty-threshold-svyarpt.html#cb136-2" tabindex="-1"></a> pnadc_earnings_arpt <span class="ot">&lt;-</span></span>
<span id="cb136-3"><a href="3.1-at-risk-of-poverty-threshold-svyarpt.html#cb136-3" tabindex="-1"></a> <span class="fu">svyarpt</span>(<span class="sc">~</span> deflated_labor_income , pnadc_design , <span class="at">na.rm =</span> <span class="cn">TRUE</span>)</span>
<span id="cb136-4"><a href="3.1-at-risk-of-poverty-threshold-svyarpt.html#cb136-4" tabindex="-1"></a>)</span></code></pre></div>
<div class="sourceCode" id="cb136"><pre class="sourceCode r"><code class="sourceCode r"><span id="cb136-1"><a href="3.1-at-risk-of-poverty-threshold-svyarpt.html#cb136-1" tabindex="-1"></a><span class="fu">svyarpt</span>( <span class="sc">~</span> deflated_labor_income , pnadc_design , <span class="at">na.rm =</span> <span class="cn">TRUE</span>)</span></code></pre></div>
<pre><code>## arpt SE
## deflated_labor_income 955.28 1.9433</code></pre>
<div class="sourceCode" id="cb138"><pre class="sourceCode r"><code class="sourceCode r"><span id="cb138-1"><a href="3.1-at-risk-of-poverty-threshold-svyarpt.html#cb138-1" tabindex="-1"></a>(pnadc_earnings_arpt_by_sex <span class="ot">&lt;-</span></span>
<span id="cb138-2"><a href="3.1-at-risk-of-poverty-threshold-svyarpt.html#cb138-2" tabindex="-1"></a> <span class="fu">svyby</span>( <span class="sc">~</span> deflated_labor_income , <span class="sc">~</span> sex , pnadc_design , svyarpt , <span class="at">na.rm =</span> <span class="cn">TRUE</span>))</span></code></pre></div>
<div class="sourceCode" id="cb138"><pre class="sourceCode r"><code class="sourceCode r"><span id="cb138-1"><a href="3.1-at-risk-of-poverty-threshold-svyarpt.html#cb138-1" tabindex="-1"></a><span class="fu">svyby</span>( <span class="sc">~</span> deflated_labor_income , <span class="sc">~</span> sex , pnadc_design , svyarpt , <span class="at">na.rm =</span> <span class="cn">TRUE</span>)</span></code></pre></div>
<pre><code>## sex deflated_labor_income se.deflated_labor_income
## male male 1074.9787 1.88908
## female female 890.7655 1.51126</code></pre>
Expand Down

0 comments on commit 5a326ea

Please sign in to comment.