Skip to content

Commit

Permalink
remove the progress()
Browse files Browse the repository at this point in the history
  • Loading branch information
ajdamico committed Nov 7, 2023
1 parent fa49bfb commit fe1c5c2
Show file tree
Hide file tree
Showing 37 changed files with 2,494 additions and 2,817 deletions.
2 changes: 1 addition & 1 deletion docs/1.1-install.html
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@

<meta name="author" content="By Guilherme Jacob, Anthony Damico, and Djalma Pessoa. The authors received no external funding for the convey software and this accompanying textbook." />

<meta name="date" content="2023-11-04" />
<meta name="date" content="2023-11-07" />

<script type="text/x-mathjax-config">
MathJax.Hub.Config({
Expand Down
2 changes: 1 addition & 1 deletion docs/1.2-survey.html
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@

<meta name="author" content="By Guilherme Jacob, Anthony Damico, and Djalma Pessoa. The authors received no external funding for the convey software and this accompanying textbook." />

<meta name="date" content="2023-11-04" />
<meta name="date" content="2023-11-07" />

<script type="text/x-mathjax-config">
MathJax.Hub.Config({
Expand Down
2 changes: 1 addition & 1 deletion docs/1.3-usage-examples.html
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@

<meta name="author" content="By Guilherme Jacob, Anthony Damico, and Djalma Pessoa. The authors received no external funding for the convey software and this accompanying textbook." />

<meta name="date" content="2023-11-04" />
<meta name="date" content="2023-11-07" />

<script type="text/x-mathjax-config">
MathJax.Hub.Config({
Expand Down
473 changes: 75 additions & 398 deletions docs/1.4-the-current-population-survey-cps.html

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion docs/2-var.html
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@

<meta name="author" content="By Guilherme Jacob, Anthony Damico, and Djalma Pessoa. The authors received no external funding for the convey software and this accompanying textbook." />

<meta name="date" content="2023-11-04" />
<meta name="date" content="2023-11-07" />

<script type="text/x-mathjax-config">
MathJax.Hub.Config({
Expand Down
2 changes: 1 addition & 1 deletion docs/2.1-lin.html
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@

<meta name="author" content="By Guilherme Jacob, Anthony Damico, and Djalma Pessoa. The authors received no external funding for the convey software and this accompanying textbook." />

<meta name="date" content="2023-11-04" />
<meta name="date" content="2023-11-07" />

<script type="text/x-mathjax-config">
MathJax.Hub.Config({
Expand Down
66 changes: 33 additions & 33 deletions docs/2.2-replication-based-variance-estimation.html
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@

<meta name="author" content="By Guilherme Jacob, Anthony Damico, and Djalma Pessoa. The authors received no external funding for the convey software and this accompanying textbook." />

<meta name="date" content="2023-11-04" />
<meta name="date" content="2023-11-07" />

<script type="text/x-mathjax-config">
MathJax.Hub.Config({
Expand Down Expand Up @@ -258,34 +258,34 @@ <h2><span class="header-section-number">2.2</span> Replication-Based Variance Es
<p>The function <code>bootVar</code> from the <code>laeken</code> library <span class="citation">(<label for="tufte-mn-12" class="margin-toggle">&#8853;</label><input type="checkbox" id="tufte-mn-12" class="margin-toggle">Alfons and Templ 2013<span class="marginnote">Alfons, Andreas, and Matthias Templ. 2013. <span>“Estimation of Social Exclusion Indicators from Complex Surveys: The <span>R</span> Package <span class="nocase">laeken</span>.”</span> <em>Journal of Statistical Software</em> 54 (15): 1–25. <a href="http://www.jstatsoft.org/v54/i15/">http://www.jstatsoft.org/v54/i15/</a>.</span>)</span>, also uses the bootstrap method to estimate variances.</p>
<div id="replication-design-example" class="section level3" number="2.2.1">
<h3><span class="header-section-number">2.2.1</span> Replication Design Example</h3>
<div class="sourceCode" id="cb46"><pre class="sourceCode r"><code class="sourceCode r"><span id="cb46-1"><a href="2.2-replication-based-variance-estimation.html#cb46-1" tabindex="-1"></a><span class="co"># load libraries</span></span>
<span id="cb46-2"><a href="2.2-replication-based-variance-estimation.html#cb46-2" tabindex="-1"></a><span class="fu">library</span>( survey )</span>
<span id="cb46-3"><a href="2.2-replication-based-variance-estimation.html#cb46-3" tabindex="-1"></a><span class="fu">library</span>( convey )</span>
<span id="cb46-4"><a href="2.2-replication-based-variance-estimation.html#cb46-4" tabindex="-1"></a><span class="fu">library</span>( laeken ) <span class="co"># for the dataset</span></span>
<span id="cb46-5"><a href="2.2-replication-based-variance-estimation.html#cb46-5" tabindex="-1"></a></span>
<span id="cb46-6"><a href="2.2-replication-based-variance-estimation.html#cb46-6" tabindex="-1"></a><span class="co"># get laeken eusilc data</span></span>
<span id="cb46-7"><a href="2.2-replication-based-variance-estimation.html#cb46-7" tabindex="-1"></a><span class="fu">data</span>( eusilc ) ; <span class="fu">names</span>( eusilc ) <span class="ot">&lt;-</span> <span class="fu">tolower</span>( <span class="fu">names</span>( eusilc ) )</span>
<span id="cb46-8"><a href="2.2-replication-based-variance-estimation.html#cb46-8" tabindex="-1"></a></span>
<span id="cb46-9"><a href="2.2-replication-based-variance-estimation.html#cb46-9" tabindex="-1"></a><span class="co"># survey design object for TSL/ifluence function variance estimation</span></span>
<span id="cb46-10"><a href="2.2-replication-based-variance-estimation.html#cb46-10" tabindex="-1"></a>des_eusilc <span class="ot">&lt;-</span> <span class="fu">svydesign</span>( <span class="at">ids =</span> <span class="sc">~</span>rb030 , <span class="at">strata =</span> <span class="sc">~</span>db040 , <span class="at">weights =</span> <span class="sc">~</span>rb050 , <span class="at">data =</span> eusilc )</span>
<span id="cb46-11"><a href="2.2-replication-based-variance-estimation.html#cb46-11" tabindex="-1"></a>des_eusilc <span class="ot">&lt;-</span> <span class="fu">convey_prep</span>( des_eusilc )</span>
<span id="cb46-12"><a href="2.2-replication-based-variance-estimation.html#cb46-12" tabindex="-1"></a></span>
<span id="cb46-13"><a href="2.2-replication-based-variance-estimation.html#cb46-13" tabindex="-1"></a><span class="co"># influence function SE estimate for the gini index</span></span>
<span id="cb46-14"><a href="2.2-replication-based-variance-estimation.html#cb46-14" tabindex="-1"></a>convey<span class="sc">:::</span><span class="fu">svygini.survey.design</span>( <span class="sc">~</span>eqincome , <span class="at">design =</span> des_eusilc )</span></code></pre></div>
<div class="sourceCode" id="cb45"><pre class="sourceCode r"><code class="sourceCode r"><span id="cb45-1"><a href="2.2-replication-based-variance-estimation.html#cb45-1" tabindex="-1"></a><span class="co"># load libraries</span></span>
<span id="cb45-2"><a href="2.2-replication-based-variance-estimation.html#cb45-2" tabindex="-1"></a><span class="fu">library</span>( survey )</span>
<span id="cb45-3"><a href="2.2-replication-based-variance-estimation.html#cb45-3" tabindex="-1"></a><span class="fu">library</span>( convey )</span>
<span id="cb45-4"><a href="2.2-replication-based-variance-estimation.html#cb45-4" tabindex="-1"></a><span class="fu">library</span>( laeken ) <span class="co"># for the dataset</span></span>
<span id="cb45-5"><a href="2.2-replication-based-variance-estimation.html#cb45-5" tabindex="-1"></a></span>
<span id="cb45-6"><a href="2.2-replication-based-variance-estimation.html#cb45-6" tabindex="-1"></a><span class="co"># get laeken eusilc data</span></span>
<span id="cb45-7"><a href="2.2-replication-based-variance-estimation.html#cb45-7" tabindex="-1"></a><span class="fu">data</span>( eusilc ) ; <span class="fu">names</span>( eusilc ) <span class="ot">&lt;-</span> <span class="fu">tolower</span>( <span class="fu">names</span>( eusilc ) )</span>
<span id="cb45-8"><a href="2.2-replication-based-variance-estimation.html#cb45-8" tabindex="-1"></a></span>
<span id="cb45-9"><a href="2.2-replication-based-variance-estimation.html#cb45-9" tabindex="-1"></a><span class="co"># survey design object for TSL/ifluence function variance estimation</span></span>
<span id="cb45-10"><a href="2.2-replication-based-variance-estimation.html#cb45-10" tabindex="-1"></a>des_eusilc <span class="ot">&lt;-</span> <span class="fu">svydesign</span>( <span class="at">ids =</span> <span class="sc">~</span>rb030 , <span class="at">strata =</span> <span class="sc">~</span>db040 , <span class="at">weights =</span> <span class="sc">~</span>rb050 , <span class="at">data =</span> eusilc )</span>
<span id="cb45-11"><a href="2.2-replication-based-variance-estimation.html#cb45-11" tabindex="-1"></a>des_eusilc <span class="ot">&lt;-</span> <span class="fu">convey_prep</span>( des_eusilc )</span>
<span id="cb45-12"><a href="2.2-replication-based-variance-estimation.html#cb45-12" tabindex="-1"></a></span>
<span id="cb45-13"><a href="2.2-replication-based-variance-estimation.html#cb45-13" tabindex="-1"></a><span class="co"># influence function SE estimate for the gini index</span></span>
<span id="cb45-14"><a href="2.2-replication-based-variance-estimation.html#cb45-14" tabindex="-1"></a>convey<span class="sc">:::</span><span class="fu">svygini.survey.design</span>( <span class="sc">~</span>eqincome , <span class="at">design =</span> des_eusilc )</span></code></pre></div>
<pre><code>## gini SE
## eqincome 0.26497 0.0019</code></pre>
<div class="sourceCode" id="cb48"><pre class="sourceCode r"><code class="sourceCode r"><span id="cb48-1"><a href="2.2-replication-based-variance-estimation.html#cb48-1" tabindex="-1"></a><span class="co"># create survey design object for replicate-based variance estimation</span></span>
<span id="cb48-2"><a href="2.2-replication-based-variance-estimation.html#cb48-2" tabindex="-1"></a>des_eusilc_rep <span class="ot">&lt;-</span> <span class="fu">as.svrepdesign</span>( des_eusilc , <span class="at">type =</span> <span class="st">&quot;bootstrap&quot;</span> )</span>
<span id="cb48-3"><a href="2.2-replication-based-variance-estimation.html#cb48-3" tabindex="-1"></a>des_eusilc_rep <span class="ot">&lt;-</span> <span class="fu">convey_prep</span>( des_eusilc_rep )</span>
<span id="cb48-4"><a href="2.2-replication-based-variance-estimation.html#cb48-4" tabindex="-1"></a></span>
<span id="cb48-5"><a href="2.2-replication-based-variance-estimation.html#cb48-5" tabindex="-1"></a><span class="co"># replicate-based (bootstrao) SE estimate for the gini index</span></span>
<span id="cb48-6"><a href="2.2-replication-based-variance-estimation.html#cb48-6" tabindex="-1"></a><span class="co"># with option to keep replicates</span></span>
<span id="cb48-7"><a href="2.2-replication-based-variance-estimation.html#cb48-7" tabindex="-1"></a>( gini.repstat <span class="ot">&lt;-</span> convey<span class="sc">:::</span><span class="fu">svygini.svyrep.design</span>( <span class="sc">~</span>eqincome , <span class="at">design =</span> des_eusilc_rep , <span class="at">return.replicates =</span> <span class="cn">TRUE</span> ) )</span></code></pre></div>
<div class="sourceCode" id="cb47"><pre class="sourceCode r"><code class="sourceCode r"><span id="cb47-1"><a href="2.2-replication-based-variance-estimation.html#cb47-1" tabindex="-1"></a><span class="co"># create survey design object for replicate-based variance estimation</span></span>
<span id="cb47-2"><a href="2.2-replication-based-variance-estimation.html#cb47-2" tabindex="-1"></a>des_eusilc_rep <span class="ot">&lt;-</span> <span class="fu">as.svrepdesign</span>( des_eusilc , <span class="at">type =</span> <span class="st">&quot;bootstrap&quot;</span> )</span>
<span id="cb47-3"><a href="2.2-replication-based-variance-estimation.html#cb47-3" tabindex="-1"></a>des_eusilc_rep <span class="ot">&lt;-</span> <span class="fu">convey_prep</span>( des_eusilc_rep )</span>
<span id="cb47-4"><a href="2.2-replication-based-variance-estimation.html#cb47-4" tabindex="-1"></a></span>
<span id="cb47-5"><a href="2.2-replication-based-variance-estimation.html#cb47-5" tabindex="-1"></a><span class="co"># replicate-based (bootstrao) SE estimate for the gini index</span></span>
<span id="cb47-6"><a href="2.2-replication-based-variance-estimation.html#cb47-6" tabindex="-1"></a><span class="co"># with option to keep replicates</span></span>
<span id="cb47-7"><a href="2.2-replication-based-variance-estimation.html#cb47-7" tabindex="-1"></a>( gini.repstat <span class="ot">&lt;-</span> convey<span class="sc">:::</span><span class="fu">svygini.svyrep.design</span>( <span class="sc">~</span>eqincome , <span class="at">design =</span> des_eusilc_rep , <span class="at">return.replicates =</span> <span class="cn">TRUE</span> ) )</span></code></pre></div>
<pre><code>## gini SE
## eqincome 0.26497 0.0022</code></pre>
<p>To understand how that variance is estimated, we can look at the replicates:</p>
<div class="sourceCode" id="cb50"><pre class="sourceCode r"><code class="sourceCode r"><span id="cb50-1"><a href="2.2-replication-based-variance-estimation.html#cb50-1" tabindex="-1"></a><span class="co"># collect gini bootstrap replicates</span></span>
<span id="cb50-2"><a href="2.2-replication-based-variance-estimation.html#cb50-2" tabindex="-1"></a>( gini.reps <span class="ot">&lt;-</span> gini.repstat<span class="sc">$</span>replicates )</span></code></pre></div>
<div class="sourceCode" id="cb49"><pre class="sourceCode r"><code class="sourceCode r"><span id="cb49-1"><a href="2.2-replication-based-variance-estimation.html#cb49-1" tabindex="-1"></a><span class="co"># collect gini bootstrap replicates</span></span>
<span id="cb49-2"><a href="2.2-replication-based-variance-estimation.html#cb49-2" tabindex="-1"></a>( gini.reps <span class="ot">&lt;-</span> gini.repstat<span class="sc">$</span>replicates )</span></code></pre></div>
<pre><code>## [1] 0.2628816 0.2653672 0.2663951 0.2646311 0.2660021 0.2648396 0.2633737
## [8] 0.2611656 0.2613233 0.2647174 0.2638256 0.2621616 0.2646830 0.2587950
## [15] 0.2642947 0.2651559 0.2663231 0.2673018 0.2687169 0.2671058 0.2654078
Expand All @@ -302,16 +302,16 @@ <h3><span class="header-section-number">2.2.1</span> Replication Design Example<
## attr(,&quot;mse&quot;)
## [1] FALSE</code></pre>
<p>These are resampling (bootstrap) replicates. With them, we can look at the variance of these replicates to get an estimate the gini estimator’s variance:</p>
<div class="sourceCode" id="cb52"><pre class="sourceCode r"><code class="sourceCode r"><span id="cb52-1"><a href="2.2-replication-based-variance-estimation.html#cb52-1" tabindex="-1"></a><span class="co"># variance estimate</span></span>
<span id="cb52-2"><a href="2.2-replication-based-variance-estimation.html#cb52-2" tabindex="-1"></a>des.scale <span class="ot">&lt;-</span> des_eusilc_rep<span class="sc">$</span>scale</span>
<span id="cb52-3"><a href="2.2-replication-based-variance-estimation.html#cb52-3" tabindex="-1"></a>meantheta <span class="ot">&lt;-</span> <span class="fu">mean</span>( gini.reps )[[<span class="dv">1</span>]]</span>
<span id="cb52-4"><a href="2.2-replication-based-variance-estimation.html#cb52-4" tabindex="-1"></a>v <span class="ot">&lt;-</span> <span class="fu">sum</span>( ( gini.reps <span class="sc">-</span> meantheta )<span class="sc">^</span><span class="dv">2</span> ) <span class="sc">*</span> des.scale</span>
<span id="cb52-5"><a href="2.2-replication-based-variance-estimation.html#cb52-5" tabindex="-1"></a></span>
<span id="cb52-6"><a href="2.2-replication-based-variance-estimation.html#cb52-6" tabindex="-1"></a><span class="co"># SE estimate</span></span>
<span id="cb52-7"><a href="2.2-replication-based-variance-estimation.html#cb52-7" tabindex="-1"></a>( gini.se <span class="ot">&lt;-</span> ( <span class="fu">sqrt</span>( v ) ) )</span></code></pre></div>
<div class="sourceCode" id="cb51"><pre class="sourceCode r"><code class="sourceCode r"><span id="cb51-1"><a href="2.2-replication-based-variance-estimation.html#cb51-1" tabindex="-1"></a><span class="co"># variance estimate</span></span>
<span id="cb51-2"><a href="2.2-replication-based-variance-estimation.html#cb51-2" tabindex="-1"></a>des.scale <span class="ot">&lt;-</span> des_eusilc_rep<span class="sc">$</span>scale</span>
<span id="cb51-3"><a href="2.2-replication-based-variance-estimation.html#cb51-3" tabindex="-1"></a>meantheta <span class="ot">&lt;-</span> <span class="fu">mean</span>( gini.reps )[[<span class="dv">1</span>]]</span>
<span id="cb51-4"><a href="2.2-replication-based-variance-estimation.html#cb51-4" tabindex="-1"></a>v <span class="ot">&lt;-</span> <span class="fu">sum</span>( ( gini.reps <span class="sc">-</span> meantheta )<span class="sc">^</span><span class="dv">2</span> ) <span class="sc">*</span> des.scale</span>
<span id="cb51-5"><a href="2.2-replication-based-variance-estimation.html#cb51-5" tabindex="-1"></a></span>
<span id="cb51-6"><a href="2.2-replication-based-variance-estimation.html#cb51-6" tabindex="-1"></a><span class="co"># SE estimate</span></span>
<span id="cb51-7"><a href="2.2-replication-based-variance-estimation.html#cb51-7" tabindex="-1"></a>( gini.se <span class="ot">&lt;-</span> ( <span class="fu">sqrt</span>( v ) ) )</span></code></pre></div>
<pre><code>## [1] 0.002226009</code></pre>
<div class="sourceCode" id="cb54"><pre class="sourceCode r"><code class="sourceCode r"><span id="cb54-1"><a href="2.2-replication-based-variance-estimation.html#cb54-1" tabindex="-1"></a><span class="co"># compare estimates</span></span>
<span id="cb54-2"><a href="2.2-replication-based-variance-estimation.html#cb54-2" tabindex="-1"></a><span class="fu">identical</span>( gini.se , <span class="fu">SE</span>( gini.repstat )[[<span class="dv">1</span>]] )</span></code></pre></div>
<div class="sourceCode" id="cb53"><pre class="sourceCode r"><code class="sourceCode r"><span id="cb53-1"><a href="2.2-replication-based-variance-estimation.html#cb53-1" tabindex="-1"></a><span class="co"># compare estimates</span></span>
<span id="cb53-2"><a href="2.2-replication-based-variance-estimation.html#cb53-2" tabindex="-1"></a><span class="fu">identical</span>( gini.se , <span class="fu">SE</span>( gini.repstat )[[<span class="dv">1</span>]] )</span></code></pre></div>
<pre><code>## [1] TRUE</code></pre>
</div>
</div>
Expand Down
2 changes: 1 addition & 1 deletion docs/2.3-variance-estimation-for-decompositions.html
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@

<meta name="author" content="By Guilherme Jacob, Anthony Damico, and Djalma Pessoa. The authors received no external funding for the convey software and this accompanying textbook." />

<meta name="date" content="2023-11-04" />
<meta name="date" content="2023-11-07" />

<script type="text/x-mathjax-config">
MathJax.Hub.Config({
Expand Down
2 changes: 1 addition & 1 deletion docs/3-poverty.html
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@

<meta name="author" content="By Guilherme Jacob, Anthony Damico, and Djalma Pessoa. The authors received no external funding for the convey software and this accompanying textbook." />

<meta name="date" content="2023-11-04" />
<meta name="date" content="2023-11-07" />

<script type="text/x-mathjax-config">
MathJax.Hub.Config({
Expand Down
Loading

0 comments on commit fe1c5c2

Please sign in to comment.