<?xml version="1.0" encoding="UTF-8"?>
<rss  xmlns:atom="http://www.w3.org/2005/Atom" 
      xmlns:media="http://search.yahoo.com/mrss/" 
      xmlns:content="http://purl.org/rss/1.0/modules/content/" 
      xmlns:dc="http://purl.org/dc/elements/1.1/" 
      version="2.0">
<channel>
<title>svy Learn</title>
<link>https://svylab.com/learn/workshops/</link>
<atom:link href="https://svylab.com/learn/workshops/index.xml" rel="self" type="application/rss+xml"/>
<description>Learn complex survey analysis in Python with svy. Tutorials, technical notes, and case studies covering stratified sampling, cluster designs, Taylor linearization, replication methods, and design-based inference.
</description>
<generator>quarto-1.8.24</generator>
<lastBuildDate>Mon, 27 Oct 2025 04:00:00 GMT</lastBuildDate>
<item>
  <title>2025 Medical Expenditure Panel Survey, Household Component (MEPS-HC)</title>
  <dc:creator>Mamadou S. Diallo</dc:creator>
  <link>https://svylab.com/learn/workshops/meps-2025/</link>
  <description><![CDATA[ 




<p>In this document, we use Python and the <a href="https://svylab.com/docs/svy/"><code>svy</code> library</a> to reproduce the <strong>2025 <a href="https://meps.ahrq.gov/mepsweb/index.jsp">MEPS</a> Workshop</strong> (originally conducted in R, see <a href="https://github.com/HHS-AHRQ/MEPS-Workshop-2025/tree/main">GitHub Repository</a>).</p>
<p>To follow along and run the code locally, download the following <strong>2023</strong> MEPS public-use files:</p>
<ul>
<li><a href="https://meps.ahrq.gov/mepsweb/data_stats/download_data_files_detail.jsp?cboPufNumber=HC-251">2023 Full-Year Consolidated (HC-251)</a></li>
<li><a href="https://meps.ahrq.gov/mepsweb/data_stats/download_data_files_detail.jsp?cboPufNumber=HC-248G">2023 Office-Based Medical Provider Visits (HC-248G)</a></li>
<li><a href="https://meps.ahrq.gov/mepsweb/data_stats/download_data_files_detail.jsp?cboPufNumber=HC-249">2023 Medical Conditions (HC-249)</a></li>
<li><a href="https://meps.ahrq.gov/mepsweb/data_stats/download_data_files_detail.jsp?cboPufNumber=HC-248I">2023 CLNK: Condition–Event Link (HC-248I)</a></li>
</ul>
<div class="callout callout-style-default callout-tip callout-titled">
<div class="callout-header d-flex align-content-center">
<div class="callout-icon-container">
<i class="callout-icon"></i>
</div>
<div class="callout-title-container flex-fill">
<span class="screen-reader-only">Tip</span>Create a Python environment using <code>uv</code>
</div>
</div>
<div class="callout-body-container callout-body">
<p>The steps below give you a <strong>fast, reproducible</strong> setup for running the MEPS workshop with <code>svy</code>.</p>
<ul>
<li>If you do not have <code>uv</code>, install it. See instructions at https://docs.astral.sh/uv/getting-started/installation/</li>
<li>restart your shell so <code>uv</code> is on PATH, and from your root project run: <code>uv venv -p 3.13</code></li>
<li>Initialize the environment with <code>uv init</code></li>
<li>Add the requirements: <code>uv add svy[report]</code></li>
</ul>
<p>Since it’s a simple analysis, you can store the datasets and code in the root project folder.</p>
</div>
</div>
<p>Imports used throughout the workshop and some general settings.</p>
<div id="13d19d1a" class="cell" data-execution_count="1">
<div class="code-copy-outer-scaffold"><div class="sourceCode cell-code" id="cb1" style="background: #f1f3f5;"><pre class="sourceCode numberSource python number-lines code-with-copy"><code class="sourceCode python"><span id="cb1-1"><span class="im" style="color: #00769E;
background-color: null;
font-style: inherit;">import</span> polars <span class="im" style="color: #00769E;
background-color: null;
font-style: inherit;">as</span> pl</span>
<span id="cb1-2"><span class="im" style="color: #00769E;
background-color: null;
font-style: inherit;">import</span> svy</span>
<span id="cb1-3"></span>
<span id="cb1-4">svy.Estimate.PRINT_WIDTH <span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">=</span> <span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">89</span></span>
<span id="cb1-5">svy.Estimate.DECIMALS <span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">=</span> <span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">4</span></span></code></pre></div></div>
</div>
<section id="part-i-estimates-for-national-health-care-for-the-u.s.-civilian-non-institutionalized-population-2023" class="level2">
<h2 class="anchored" data-anchor-id="part-i-estimates-for-national-health-care-for-the-u.s.-civilian-non-institutionalized-population-2023">Part I — Estimates for National Health Care for the U.S. Civilian Non-Institutionalized Population, 2023</h2>
<section id="exploration-of-the-relevant-data-from-the-2023-meps-hc" class="level3">
<h3 class="anchored" data-anchor-id="exploration-of-the-relevant-data-from-the-2023-meps-hc">Exploration of the Relevant Data from the 2023 MEPS-HC</h3>
<p>First, we read the <strong>2023 Full-Year Consolidated</strong> file from local storage using <code>svy.read_stata</code>. Then we subset the variables needed for this tutorial, derive two helper variables, and run quick QC checks.</p>
<p>Read the Stata file via <code>svy</code></p>
<div id="fb06193f" class="cell" data-execution_count="2">
<div class="code-copy-outer-scaffold"><div class="sourceCode cell-code" id="cb2" style="background: #f1f3f5;"><pre class="sourceCode numberSource python number-lines code-with-copy"><code class="sourceCode python"><span id="cb2-1">fyc23 <span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">=</span> svy.read_stata(path<span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">=</span><span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"./h251.dta"</span>)</span>
<span id="cb2-2"></span>
<span id="cb2-3"><span class="bu" style="color: null;
background-color: null;
font-style: inherit;">print</span>(fyc23)</span></code></pre></div></div>
<div class="cell-output cell-output-stdout">
<pre><code>shape: (18_919, 1_374)
┌────────────┬───────┬────────────┬───────┬───┬──────────────┬──────────────┬────────┬────────┐
│ DUID       ┆ PID   ┆ DUPERSID   ┆ PANEL ┆ … ┆ FAMWT23C     ┆ SAQWT23F     ┆ VARSTR ┆ VARPSU │
│ ---        ┆ ---   ┆ ---        ┆ ---   ┆   ┆ ---          ┆ ---          ┆ ---    ┆ ---    │
│ f64        ┆ f64   ┆ str        ┆ f64   ┆   ┆ f64          ┆ f64          ┆ f64    ┆ f64    │
╞════════════╪═══════╪════════════╪═══════╪═══╪══════════════╪══════════════╪════════╪════════╡
│ 2.790002e6 ┆ 101.0 ┆ 2790002101 ┆ 27.0  ┆ … ┆ 11158.817826 ┆ 13221.315673 ┆ 2019.0 ┆ 1.0    │
│ 2.790002e6 ┆ 102.0 ┆ 2790002102 ┆ 27.0  ┆ … ┆ 11158.817826 ┆ 0.0          ┆ 2019.0 ┆ 1.0    │
│ 2.790004e6 ┆ 101.0 ┆ 2790004101 ┆ 27.0  ┆ … ┆ 28540.745942 ┆ 29999.277476 ┆ 2084.0 ┆ 1.0    │
│ 2.790006e6 ┆ 101.0 ┆ 2790006101 ┆ 27.0  ┆ … ┆ 10821.040689 ┆ 11144.513916 ┆ 2113.0 ┆ 1.0    │
│ 2.790006e6 ┆ 102.0 ┆ 2790006102 ┆ 27.0  ┆ … ┆ 10821.040689 ┆ 0.0          ┆ 2113.0 ┆ 1.0    │
│ …          ┆ …     ┆ …          ┆ …     ┆ … ┆ …            ┆ …            ┆ …      ┆ …      │
│ 2.819784e6 ┆ 105.0 ┆ 2819784105 ┆ 28.0  ┆ … ┆ 5126.030033  ┆ 0.0          ┆ 2015.0 ┆ 1.0    │
│ 2.819788e6 ┆ 101.0 ┆ 2819788101 ┆ 28.0  ┆ … ┆ 3608.933864  ┆ 4902.751776  ┆ 2005.0 ┆ 1.0    │
│ 2.819792e6 ┆ 101.0 ┆ 2819792101 ┆ 28.0  ┆ … ┆ 26238.599825 ┆ 0.0          ┆ 2012.0 ┆ 3.0    │
│ 2.819793e6 ┆ 101.0 ┆ 2819793101 ┆ 28.0  ┆ … ┆ 15780.213332 ┆ 0.0          ┆ 2004.0 ┆ 1.0    │
│ 2.819793e6 ┆ 102.0 ┆ 2819793102 ┆ 28.0  ┆ … ┆ 15780.213332 ┆ 0.0          ┆ 2004.0 ┆ 1.0    │
└────────────┴───────┴────────────┴───────┴───┴──────────────┴──────────────┴────────┴────────┘</code></pre>
</div>
</div>
<p>Subset to columns used in the tutorial using <code>polars</code>.</p>
<div id="b2cefb58" class="cell" data-execution_count="3">
<div class="code-copy-outer-scaffold"><div class="sourceCode cell-code" id="cb4" style="background: #f1f3f5;"><pre class="sourceCode numberSource python number-lines code-with-copy"><code class="sourceCode python"><span id="cb4-1">fyc23_sub <span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">=</span> fyc23.select(</span>
<span id="cb4-2">    [<span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"AGELAST"</span>, <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"TOTEXP23"</span>, <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"DUPERSID"</span>, <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"VARSTR"</span>, <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"VARPSU"</span>, <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"PERWT23F"</span>]</span>
<span id="cb4-3">)</span>
<span id="cb4-4"></span>
<span id="cb4-5"><span class="bu" style="color: null;
background-color: null;
font-style: inherit;">print</span>(fyc23_sub.head())</span></code></pre></div></div>
<div class="cell-output cell-output-stdout">
<pre><code>shape: (5, 6)
┌─────────┬──────────┬────────────┬────────┬────────┬──────────────┐
│ AGELAST ┆ TOTEXP23 ┆ DUPERSID   ┆ VARSTR ┆ VARPSU ┆ PERWT23F     │
│ ---     ┆ ---      ┆ ---        ┆ ---    ┆ ---    ┆ ---          │
│ f64     ┆ f64      ┆ str        ┆ f64    ┆ f64    ┆ f64          │
╞═════════╪══════════╪════════════╪════════╪════════╪══════════════╡
│ 58.0    ┆ 646.0    ┆ 2790002101 ┆ 2019.0 ┆ 1.0    ┆ 11664.426815 │
│ 27.0    ┆ 1894.0   ┆ 2790002102 ┆ 2019.0 ┆ 1.0    ┆ 32212.113596 │
│ 49.0    ┆ 986.0    ┆ 2790004101 ┆ 2084.0 ┆ 1.0    ┆ 21944.142826 │
│ 75.0    ┆ 1312.0   ┆ 2790006101 ┆ 2113.0 ┆ 1.0    ┆ 10328.00953  │
│ 23.0    ┆ 0.0      ┆ 2790006102 ┆ 2113.0 ┆ 1.0    ┆ 17430.521357 │
└─────────┴──────────┴────────────┴────────┴────────┴──────────────┘</code></pre>
</div>
</div>
<p>Derive helper variables:</p>
<ul>
<li><code>has_exp</code>: indicator for any total expenditure</li>
<li><code>age_cat</code>: &lt;65 vs 65+</li>
</ul>
<div id="5ee78add" class="cell" data-execution_count="4">
<div class="code-copy-outer-scaffold"><div class="sourceCode cell-code" id="cb6" style="background: #f1f3f5;"><pre class="sourceCode numberSource python number-lines code-with-copy"><code class="sourceCode python"><span id="cb6-1">fyc23x <span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">=</span> fyc23_sub.with_columns(</span>
<span id="cb6-2">    has_exp<span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">=</span>pl.col(<span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"TOTEXP23"</span>).gt(pl.lit(<span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">0</span>)),</span>
<span id="cb6-3">    age_cat<span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">=</span>pl.when(pl.col(<span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"AGELAST"</span>) <span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">&lt;</span> <span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">65</span>)</span>
<span id="cb6-4">    .then(pl.lit(<span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"&lt;65"</span>))</span>
<span id="cb6-5">    .otherwise(pl.lit(<span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"65+"</span>)),</span>
<span id="cb6-6">)</span>
<span id="cb6-7"></span>
<span id="cb6-8"><span class="bu" style="color: null;
background-color: null;
font-style: inherit;">print</span>(fyc23x.head())</span></code></pre></div></div>
<div class="cell-output cell-output-stdout">
<pre><code>shape: (5, 8)
┌─────────┬──────────┬────────────┬────────┬────────┬──────────────┬─────────┬─────────┐
│ AGELAST ┆ TOTEXP23 ┆ DUPERSID   ┆ VARSTR ┆ VARPSU ┆ PERWT23F     ┆ has_exp ┆ age_cat │
│ ---     ┆ ---      ┆ ---        ┆ ---    ┆ ---    ┆ ---          ┆ ---     ┆ ---     │
│ f64     ┆ f64      ┆ str        ┆ f64    ┆ f64    ┆ f64          ┆ bool    ┆ str     │
╞═════════╪══════════╪════════════╪════════╪════════╪══════════════╪═════════╪═════════╡
│ 58.0    ┆ 646.0    ┆ 2790002101 ┆ 2019.0 ┆ 1.0    ┆ 11664.426815 ┆ true    ┆ &lt;65     │
│ 27.0    ┆ 1894.0   ┆ 2790002102 ┆ 2019.0 ┆ 1.0    ┆ 32212.113596 ┆ true    ┆ &lt;65     │
│ 49.0    ┆ 986.0    ┆ 2790004101 ┆ 2084.0 ┆ 1.0    ┆ 21944.142826 ┆ true    ┆ &lt;65     │
│ 75.0    ┆ 1312.0   ┆ 2790006101 ┆ 2113.0 ┆ 1.0    ┆ 10328.00953  ┆ true    ┆ 65+     │
│ 23.0    ┆ 0.0      ┆ 2790006102 ┆ 2113.0 ┆ 1.0    ┆ 17430.521357 ┆ false   ┆ &lt;65     │
└─────────┴──────────┴────────────┴────────┴────────┴──────────────┴─────────┴─────────┘</code></pre>
</div>
</div>
<p><strong>QC 1</strong>: Two-way counts of derived variables</p>
<div id="f6b54f66" class="cell" data-execution_count="5">
<div class="code-copy-outer-scaffold"><div class="sourceCode cell-code" id="cb8" style="background: #f1f3f5;"><pre class="sourceCode numberSource python number-lines code-with-copy"><code class="sourceCode python"><span id="cb8-1">qc_exp_by_age <span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">=</span> fyc23x.group_by([<span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"has_exp"</span>, <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"age_cat"</span>]).agg(pl.<span class="bu" style="color: null;
background-color: null;
font-style: inherit;">len</span>())</span>
<span id="cb8-2"></span>
<span id="cb8-3"><span class="bu" style="color: null;
background-color: null;
font-style: inherit;">print</span>(qc_exp_by_age)</span></code></pre></div></div>
<div class="cell-output cell-output-stdout">
<pre><code>shape: (4, 3)
┌─────────┬─────────┬───────┐
│ has_exp ┆ age_cat ┆ len   │
│ ---     ┆ ---     ┆ ---   │
│ bool    ┆ str     ┆ u32   │
╞═════════╪═════════╪═══════╡
│ true    ┆ &lt;65     ┆ 11778 │
│ true    ┆ 65+     ┆ 4486  │
│ false   ┆ &lt;65     ┆ 2497  │
│ false   ┆ 65+     ┆ 158   │
└─────────┴─────────┴───────┘</code></pre>
</div>
</div>
<p><strong>QC 2</strong>: Expenditure ranges by has_exp</p>
<div id="f68f9b2f" class="cell" data-execution_count="6">
<div class="code-copy-outer-scaffold"><div class="sourceCode cell-code" id="cb10" style="background: #f1f3f5;"><pre class="sourceCode numberSource python number-lines code-with-copy"><code class="sourceCode python"><span id="cb10-1">qc_exp <span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">=</span> fyc23x.group_by([<span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"has_exp"</span>]).agg(</span>
<span id="cb10-2">    pl.col(<span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"TOTEXP23"</span>).<span class="bu" style="color: null;
background-color: null;
font-style: inherit;">min</span>().alias(<span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"min"</span>),</span>
<span id="cb10-3">    pl.col(<span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"TOTEXP23"</span>).<span class="bu" style="color: null;
background-color: null;
font-style: inherit;">max</span>().alias(<span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"max"</span>),</span>
<span id="cb10-4">)</span>
<span id="cb10-5"></span>
<span id="cb10-6"><span class="bu" style="color: null;
background-color: null;
font-style: inherit;">print</span>(qc_exp)</span></code></pre></div></div>
<div class="cell-output cell-output-stdout">
<pre><code>shape: (2, 3)
┌─────────┬─────┬──────────┐
│ has_exp ┆ min ┆ max      │
│ ---     ┆ --- ┆ ---      │
│ bool    ┆ f64 ┆ f64      │
╞═════════╪═════╪══════════╡
│ false   ┆ 0.0 ┆ 0.0      │
│ true    ┆ 1.0 ┆ 574675.0 │
└─────────┴─────┴──────────┘</code></pre>
</div>
</div>
<p><strong>QC 3</strong>: Age ranges by age_cat</p>
<div id="8258adc7" class="cell" data-execution_count="7">
<div class="code-copy-outer-scaffold"><div class="sourceCode cell-code" id="cb12" style="background: #f1f3f5;"><pre class="sourceCode numberSource python number-lines code-with-copy"><code class="sourceCode python"><span id="cb12-1">qc_age <span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">=</span> fyc23x.group_by([<span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"age_cat"</span>]).agg(</span>
<span id="cb12-2">    pl.col(<span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"AGELAST"</span>).<span class="bu" style="color: null;
background-color: null;
font-style: inherit;">min</span>().alias(<span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"min"</span>),</span>
<span id="cb12-3">    pl.col(<span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"AGELAST"</span>).<span class="bu" style="color: null;
background-color: null;
font-style: inherit;">max</span>().alias(<span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"max"</span>),</span>
<span id="cb12-4">)</span>
<span id="cb12-5"></span>
<span id="cb12-6"><span class="bu" style="color: null;
background-color: null;
font-style: inherit;">print</span>(qc_age)</span></code></pre></div></div>
<div class="cell-output cell-output-stdout">
<pre><code>shape: (2, 3)
┌─────────┬──────┬──────┐
│ age_cat ┆ min  ┆ max  │
│ ---     ┆ ---  ┆ ---  │
│ str     ┆ f64  ┆ f64  │
╞═════════╪══════╪══════╡
│ 65+     ┆ 65.0 ┆ 85.0 │
│ &lt;65     ┆ 0.0  ┆ 64.0 │
└─────────┴──────┴──────┘</code></pre>
</div>
</div>
</section>
<section id="estimation-of-expenses" class="level3">
<h3 class="anchored" data-anchor-id="estimation-of-expenses">Estimation of Expenses</h3>
<section id="sample-design" class="level4">
<h4 class="anchored" data-anchor-id="sample-design">Sample design</h4>
<p>First, we are going to define the sample</p>
<div id="da68fd5a" class="cell" data-execution_count="8">
<div class="code-copy-outer-scaffold"><div class="sourceCode cell-code" id="cb14" style="background: #f1f3f5;"><pre class="sourceCode numberSource python number-lines code-with-copy"><code class="sourceCode python"><span id="cb14-1"><span class="im" style="color: #00769E;
background-color: null;
font-style: inherit;">from</span> svy <span class="im" style="color: #00769E;
background-color: null;
font-style: inherit;">import</span> Sample, Design</span>
<span id="cb14-2"></span>
<span id="cb14-3">fyc23_design <span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">=</span> Design(stratum<span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">=</span><span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"VARSTR"</span>, psu<span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">=</span><span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"VARPSU"</span>, wgt<span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">=</span><span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"PERWT23F"</span>)</span>
<span id="cb14-4"></span>
<span id="cb14-5">fyc23_sample <span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">=</span> Sample(data<span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">=</span>fyc23x, design<span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">=</span>fyc23_design)</span>
<span id="cb14-6"></span>
<span id="cb14-7"><span class="bu" style="color: null;
background-color: null;
font-style: inherit;">print</span>(fyc23_sample)</span></code></pre></div></div>
<div class="cell-output cell-output-display">
<pre style="white-space:pre;overflow-x:auto;line-height:normal;font-family:Menlo,'DejaVu Sans Mono',consolas,'Courier New',monospace"><span style="color: #008080; text-decoration-color: #008080">╭────────────── Sample ──────────────╮</span>
<span style="color: #008080; text-decoration-color: #008080">│</span> <span style="font-weight: bold">Survey Data</span>                        <span style="color: #008080; text-decoration-color: #008080">│</span>
<span style="color: #008080; text-decoration-color: #008080">│</span>   Rows     : 18919                 <span style="color: #008080; text-decoration-color: #008080">│</span>
<span style="color: #008080; text-decoration-color: #008080">│</span>   Columns  : 11                    <span style="color: #008080; text-decoration-color: #008080">│</span>
<span style="color: #008080; text-decoration-color: #008080">│</span>   Strata   : 105                   <span style="color: #008080; text-decoration-color: #008080">│</span>
<span style="color: #008080; text-decoration-color: #008080">│</span>   PSUs     : 262                   <span style="color: #008080; text-decoration-color: #008080">│</span>
<span style="color: #008080; text-decoration-color: #008080">│</span>                                    <span style="color: #008080; text-decoration-color: #008080">│</span>
<span style="color: #008080; text-decoration-color: #008080">│</span> <span style="font-weight: bold">Survey Design</span>                      <span style="color: #008080; text-decoration-color: #008080">│</span>
<span style="color: #008080; text-decoration-color: #008080">│</span>   Row index          svy_row_index <span style="color: #008080; text-decoration-color: #008080">│</span>
<span style="color: #008080; text-decoration-color: #008080">│</span>   Stratum            VARSTR        <span style="color: #008080; text-decoration-color: #008080">│</span>
<span style="color: #008080; text-decoration-color: #008080">│</span>   PSU                VARPSU        <span style="color: #008080; text-decoration-color: #008080">│</span>
<span style="color: #008080; text-decoration-color: #008080">│</span>   SSU                None          <span style="color: #008080; text-decoration-color: #008080">│</span>
<span style="color: #008080; text-decoration-color: #008080">│</span>   Weight             PERWT23F      <span style="color: #008080; text-decoration-color: #008080">│</span>
<span style="color: #008080; text-decoration-color: #008080">│</span>   With replacement   False         <span style="color: #008080; text-decoration-color: #008080">│</span>
<span style="color: #008080; text-decoration-color: #008080">│</span>   Prob               None          <span style="color: #008080; text-decoration-color: #008080">│</span>
<span style="color: #008080; text-decoration-color: #008080">│</span>   Hit                None          <span style="color: #008080; text-decoration-color: #008080">│</span>
<span style="color: #008080; text-decoration-color: #008080">│</span>   MOS                None          <span style="color: #008080; text-decoration-color: #008080">│</span>
<span style="color: #008080; text-decoration-color: #008080">│</span>   Population size    None          <span style="color: #008080; text-decoration-color: #008080">│</span>
<span style="color: #008080; text-decoration-color: #008080">│</span>   Replicate weights  None          <span style="color: #008080; text-decoration-color: #008080">│</span>
<span style="color: #008080; text-decoration-color: #008080">╰────────────────────────────────────╯</span>
</pre>
</div>
<div class="cell-output cell-output-stdout">
<pre><code></code></pre>
</div>
</div>
</section>
<section id="checking-for-singletons" class="level4">
<h4 class="anchored" data-anchor-id="checking-for-singletons">Checking for singletons</h4>
<p>If some strata only have one PSU, the estimation will fail. We can check for singletons (strata with one PSU) as follows</p>
<div id="281ee938" class="cell" data-execution_count="9">
<div class="code-copy-outer-scaffold"><div class="sourceCode cell-code" id="cb16" style="background: #f1f3f5;"><pre class="sourceCode numberSource python number-lines code-with-copy"><code class="sourceCode python"><span id="cb16-1"><span class="co" style="color: #5E5E5E;
background-color: null;
font-style: inherit;"># List of strata with only one PSU</span></span>
<span id="cb16-2">fyc23_sample.singleton.detected()</span></code></pre></div></div>
<div class="cell-output cell-output-display" data-execution_count="9">
<pre><code>[]</code></pre>
</div>
</div>
<p>The sample does not have singletons.</p>
</section>
<section id="overall-expenses-national-totals" class="level4">
<h4 class="anchored" data-anchor-id="overall-expenses-national-totals">Overall expenses (national totals)</h4>
<div id="9890496f" class="cell" data-execution_count="10">
<div class="code-copy-outer-scaffold"><div class="sourceCode cell-code" id="cb18" style="background: #f1f3f5;"><pre class="sourceCode numberSource python number-lines code-with-copy"><code class="sourceCode python"><span id="cb18-1">tot_exp <span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">=</span> fyc23_sample.estimation.total(y<span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">=</span><span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"TOTEXP23"</span>)</span>
<span id="cb18-2"></span>
<span id="cb18-3"><span class="bu" style="color: null;
background-color: null;
font-style: inherit;">print</span>(tot_exp)</span></code></pre></div></div>
<div class="cell-output cell-output-display">
<pre style="white-space:pre;overflow-x:auto;line-height:normal;font-family:Menlo,'DejaVu Sans Mono',consolas,'Courier New',monospace"><span style="color: #008080; text-decoration-color: #008080">╭────────────────────────────── Estimate: </span><span style="color: #008080; text-decoration-color: #008080; font-weight: bold">TOTAL</span><span style="color: #008080; text-decoration-color: #008080"> (TAYLOR) ───────────────────────────────╮</span>
<span style="color: #008080; text-decoration-color: #008080">│</span>                                                                                       <span style="color: #008080; text-decoration-color: #008080">│</span>
<span style="color: #008080; text-decoration-color: #008080">│</span>  <span style="font-weight: bold">              est </span> <span style="font-weight: bold">               se </span> <span style="font-weight: bold">              lci </span> <span style="font-weight: bold">              uci </span> <span style="font-weight: bold"> cv (%)</span>  <span style="color: #008080; text-decoration-color: #008080">│</span>
<span style="color: #008080; text-decoration-color: #008080">│</span>  ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━  <span style="color: #008080; text-decoration-color: #008080">│</span>
<span style="color: #008080; text-decoration-color: #008080">│</span>  2,504,715,663,92…   72,782,531,974.…   2,360,956,395,5…   2,648,474,932,3…   2.9058  <span style="color: #008080; text-decoration-color: #008080">│</span>
<span style="color: #008080; text-decoration-color: #008080">│</span>                                                                                       <span style="color: #008080; text-decoration-color: #008080">│</span>
<span style="color: #008080; text-decoration-color: #008080">╰───────────────────────────────────────────────────────────────────────────────────────╯</span>
</pre>
</div>
<div class="cell-output cell-output-stdout">
<pre><code></code></pre>
</div>
</div>
</section>
<section id="percentage-of-persons-with-an-expense" class="level4">
<h4 class="anchored" data-anchor-id="percentage-of-persons-with-an-expense">Percentage of persons with an expense</h4>
<div id="e05fe79a" class="cell" data-execution_count="11">
<div class="code-copy-outer-scaffold"><div class="sourceCode cell-code" id="cb20" style="background: #f1f3f5;"><pre class="sourceCode numberSource python number-lines code-with-copy"><code class="sourceCode python"><span id="cb20-1">has_exp <span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">=</span> fyc23_sample.estimation.prop(y<span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">=</span><span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"has_exp"</span>)</span>
<span id="cb20-2"></span>
<span id="cb20-3"><span class="co" style="color: #5E5E5E;
background-color: null;
font-style: inherit;"># has_exp.set_decimals(6)</span></span>
<span id="cb20-4"><span class="bu" style="color: null;
background-color: null;
font-style: inherit;">print</span>(has_exp)</span></code></pre></div></div>
<div class="cell-output cell-output-display">
<pre style="white-space:pre;overflow-x:auto;line-height:normal;font-family:Menlo,'DejaVu Sans Mono',consolas,'Courier New',monospace"><span style="color: #008080; text-decoration-color: #008080">╭─────────────── Estimate: </span><span style="color: #008080; text-decoration-color: #008080; font-weight: bold">PROP</span><span style="color: #008080; text-decoration-color: #008080"> (TAYLOR) ────────────────╮</span>
<span style="color: #008080; text-decoration-color: #008080">│</span>                                                        <span style="color: #008080; text-decoration-color: #008080">│</span>
<span style="color: #008080; text-decoration-color: #008080">│</span>  <span style="font-weight: bold">has_exp </span> <span style="font-weight: bold">    est </span> <span style="font-weight: bold">     se </span> <span style="font-weight: bold">    lci </span> <span style="font-weight: bold">    uci </span> <span style="font-weight: bold"> cv (%)</span>  <span style="color: #008080; text-decoration-color: #008080">│</span>
<span style="color: #008080; text-decoration-color: #008080">│</span>  ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━  <span style="color: #008080; text-decoration-color: #008080">│</span>
<span style="color: #008080; text-decoration-color: #008080">│</span>  false     0.1445   0.0050   0.1348   0.1547   3.4807  <span style="color: #008080; text-decoration-color: #008080">│</span>
<span style="color: #008080; text-decoration-color: #008080">│</span>  true      0.8555   0.0050   0.8453   0.8652   0.5879  <span style="color: #008080; text-decoration-color: #008080">│</span>
<span style="color: #008080; text-decoration-color: #008080">│</span>                                                        <span style="color: #008080; text-decoration-color: #008080">│</span>
<span style="color: #008080; text-decoration-color: #008080">╰────────────────────────────────────────────────────────╯</span>
</pre>
</div>
<div class="cell-output cell-output-stdout">
<pre><code></code></pre>
</div>
</div>
</section>
<section id="mean-expense-per-person" class="level4">
<h4 class="anchored" data-anchor-id="mean-expense-per-person">Mean expense per person</h4>
<div id="bccc4835" class="cell" data-execution_count="12">
<div class="code-copy-outer-scaffold"><div class="sourceCode cell-code" id="cb22" style="background: #f1f3f5;"><pre class="sourceCode numberSource python number-lines code-with-copy"><code class="sourceCode python"><span id="cb22-1">avg_exp <span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">=</span> fyc23_sample.estimation.mean(y<span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">=</span><span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"TOTEXP23"</span>)</span>
<span id="cb22-2"></span>
<span id="cb22-3"><span class="bu" style="color: null;
background-color: null;
font-style: inherit;">print</span>(avg_exp)</span></code></pre></div></div>
<div class="cell-output cell-output-display">
<pre style="white-space:pre;overflow-x:auto;line-height:normal;font-family:Menlo,'DejaVu Sans Mono',consolas,'Courier New',monospace"><span style="color: #008080; text-decoration-color: #008080">╭───────────────── Estimate: </span><span style="color: #008080; text-decoration-color: #008080; font-weight: bold">MEAN</span><span style="color: #008080; text-decoration-color: #008080"> (TAYLOR) ──────────────────╮</span>
<span style="color: #008080; text-decoration-color: #008080">│</span>                                                            <span style="color: #008080; text-decoration-color: #008080">│</span>
<span style="color: #008080; text-decoration-color: #008080">│</span>  <span style="font-weight: bold">       est </span> <span style="font-weight: bold">       se </span> <span style="font-weight: bold">        lci </span> <span style="font-weight: bold">        uci </span> <span style="font-weight: bold"> cv (%)</span>  <span style="color: #008080; text-decoration-color: #008080">│</span>
<span style="color: #008080; text-decoration-color: #008080">│</span>  ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━  <span style="color: #008080; text-decoration-color: #008080">│</span>
<span style="color: #008080; text-decoration-color: #008080">│</span>  7,487.2616   173.3692   7,144.8246   7,829.6986   2.3155  <span style="color: #008080; text-decoration-color: #008080">│</span>
<span style="color: #008080; text-decoration-color: #008080">│</span>                                                            <span style="color: #008080; text-decoration-color: #008080">│</span>
<span style="color: #008080; text-decoration-color: #008080">╰────────────────────────────────────────────────────────────╯</span>
</pre>
</div>
<div class="cell-output cell-output-stdout">
<pre><code></code></pre>
</div>
</div>
</section>
<section id="mean-expense-per-person-for-people-with-expenditures" class="level4">
<h4 class="anchored" data-anchor-id="mean-expense-per-person-for-people-with-expenditures">Mean expense per person, for people with expenditures)</h4>
<div id="9a5ae58a" class="cell" data-execution_count="13">
<div class="code-copy-outer-scaffold"><div class="sourceCode cell-code" id="cb24" style="background: #f1f3f5;"><pre class="sourceCode numberSource python number-lines code-with-copy"><code class="sourceCode python"><span id="cb24-1">avg_exp1 <span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">=</span> fyc23_sample.estimation.mean(y<span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">=</span><span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"TOTEXP23"</span>)</span>
<span id="cb24-2"></span>
<span id="cb24-3"><span class="bu" style="color: null;
background-color: null;
font-style: inherit;">print</span>(avg_exp1)</span></code></pre></div></div>
<div class="cell-output cell-output-display">
<pre style="white-space:pre;overflow-x:auto;line-height:normal;font-family:Menlo,'DejaVu Sans Mono',consolas,'Courier New',monospace"><span style="color: #008080; text-decoration-color: #008080">╭───────────────── Estimate: </span><span style="color: #008080; text-decoration-color: #008080; font-weight: bold">MEAN</span><span style="color: #008080; text-decoration-color: #008080"> (TAYLOR) ──────────────────╮</span>
<span style="color: #008080; text-decoration-color: #008080">│</span>                                                            <span style="color: #008080; text-decoration-color: #008080">│</span>
<span style="color: #008080; text-decoration-color: #008080">│</span>  <span style="font-weight: bold">       est </span> <span style="font-weight: bold">       se </span> <span style="font-weight: bold">        lci </span> <span style="font-weight: bold">        uci </span> <span style="font-weight: bold"> cv (%)</span>  <span style="color: #008080; text-decoration-color: #008080">│</span>
<span style="color: #008080; text-decoration-color: #008080">│</span>  ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━  <span style="color: #008080; text-decoration-color: #008080">│</span>
<span style="color: #008080; text-decoration-color: #008080">│</span>  7,487.2616   173.3692   7,144.8246   7,829.6986   2.3155  <span style="color: #008080; text-decoration-color: #008080">│</span>
<span style="color: #008080; text-decoration-color: #008080">│</span>                                                            <span style="color: #008080; text-decoration-color: #008080">│</span>
<span style="color: #008080; text-decoration-color: #008080">╰────────────────────────────────────────────────────────────╯</span>
</pre>
</div>
<div class="cell-output cell-output-stdout">
<pre><code></code></pre>
</div>
</div>
</section>
<section id="subset-to-people-with-income" class="level4">
<h4 class="anchored" data-anchor-id="subset-to-people-with-income">Subset to people with income</h4>
<div id="351c3c36" class="cell" data-execution_count="14">
<div class="code-copy-outer-scaffold"><div class="sourceCode cell-code" id="cb26" style="background: #f1f3f5;"><pre class="sourceCode numberSource python number-lines code-with-copy"><code class="sourceCode python"><span id="cb26-1">has_exp_sample <span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">=</span> fyc23_sample.wrangling.filter_records(svy.col(<span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"has_exp"</span>))</span>
<span id="cb26-2"></span>
<span id="cb26-3"><span class="bu" style="color: null;
background-color: null;
font-style: inherit;">print</span>(has_exp_sample)</span></code></pre></div></div>
<div class="cell-output cell-output-display">
<pre style="white-space:pre;overflow-x:auto;line-height:normal;font-family:Menlo,'DejaVu Sans Mono',consolas,'Courier New',monospace"><span style="color: #008080; text-decoration-color: #008080">╭────────────── Sample ──────────────╮</span>
<span style="color: #008080; text-decoration-color: #008080">│</span> <span style="font-weight: bold">Survey Data</span>                        <span style="color: #008080; text-decoration-color: #008080">│</span>
<span style="color: #008080; text-decoration-color: #008080">│</span>   Rows     : 16264                 <span style="color: #008080; text-decoration-color: #008080">│</span>
<span style="color: #008080; text-decoration-color: #008080">│</span>   Columns  : 11                    <span style="color: #008080; text-decoration-color: #008080">│</span>
<span style="color: #008080; text-decoration-color: #008080">│</span>   Strata   : 105                   <span style="color: #008080; text-decoration-color: #008080">│</span>
<span style="color: #008080; text-decoration-color: #008080">│</span>   PSUs     : 262                   <span style="color: #008080; text-decoration-color: #008080">│</span>
<span style="color: #008080; text-decoration-color: #008080">│</span>                                    <span style="color: #008080; text-decoration-color: #008080">│</span>
<span style="color: #008080; text-decoration-color: #008080">│</span> <span style="font-weight: bold">Survey Design</span>                      <span style="color: #008080; text-decoration-color: #008080">│</span>
<span style="color: #008080; text-decoration-color: #008080">│</span>   Row index          svy_row_index <span style="color: #008080; text-decoration-color: #008080">│</span>
<span style="color: #008080; text-decoration-color: #008080">│</span>   Stratum            VARSTR        <span style="color: #008080; text-decoration-color: #008080">│</span>
<span style="color: #008080; text-decoration-color: #008080">│</span>   PSU                VARPSU        <span style="color: #008080; text-decoration-color: #008080">│</span>
<span style="color: #008080; text-decoration-color: #008080">│</span>   SSU                None          <span style="color: #008080; text-decoration-color: #008080">│</span>
<span style="color: #008080; text-decoration-color: #008080">│</span>   Weight             PERWT23F      <span style="color: #008080; text-decoration-color: #008080">│</span>
<span style="color: #008080; text-decoration-color: #008080">│</span>   With replacement   False         <span style="color: #008080; text-decoration-color: #008080">│</span>
<span style="color: #008080; text-decoration-color: #008080">│</span>   Prob               None          <span style="color: #008080; text-decoration-color: #008080">│</span>
<span style="color: #008080; text-decoration-color: #008080">│</span>   Hit                None          <span style="color: #008080; text-decoration-color: #008080">│</span>
<span style="color: #008080; text-decoration-color: #008080">│</span>   MOS                None          <span style="color: #008080; text-decoration-color: #008080">│</span>
<span style="color: #008080; text-decoration-color: #008080">│</span>   Population size    None          <span style="color: #008080; text-decoration-color: #008080">│</span>
<span style="color: #008080; text-decoration-color: #008080">│</span>   Replicate weights  None          <span style="color: #008080; text-decoration-color: #008080">│</span>
<span style="color: #008080; text-decoration-color: #008080">╰────────────────────────────────────╯</span>
</pre>
</div>
<div class="cell-output cell-output-stdout">
<pre><code></code></pre>
</div>
</div>
</section>
<section id="mean-expense-per-person-with-an-expense" class="level4">
<h4 class="anchored" data-anchor-id="mean-expense-per-person-with-an-expense">Mean expense per person with an expense</h4>
<div id="140c0e4d" class="cell" data-execution_count="15">
<div class="code-copy-outer-scaffold"><div class="sourceCode cell-code" id="cb28" style="background: #f1f3f5;"><pre class="sourceCode numberSource python number-lines code-with-copy"><code class="sourceCode python"><span id="cb28-1">avg_exp1 <span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">=</span> has_exp_sample.estimation.mean(y<span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">=</span><span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"TOTEXP23"</span>)</span>
<span id="cb28-2"></span>
<span id="cb28-3"><span class="bu" style="color: null;
background-color: null;
font-style: inherit;">print</span>(avg_exp1)</span></code></pre></div></div>
<div class="cell-output cell-output-display">
<pre style="white-space:pre;overflow-x:auto;line-height:normal;font-family:Menlo,'DejaVu Sans Mono',consolas,'Courier New',monospace"><span style="color: #008080; text-decoration-color: #008080">╭───────────────── Estimate: </span><span style="color: #008080; text-decoration-color: #008080; font-weight: bold">MEAN</span><span style="color: #008080; text-decoration-color: #008080"> (TAYLOR) ──────────────────╮</span>
<span style="color: #008080; text-decoration-color: #008080">│</span>                                                            <span style="color: #008080; text-decoration-color: #008080">│</span>
<span style="color: #008080; text-decoration-color: #008080">│</span>  <span style="font-weight: bold">       est </span> <span style="font-weight: bold">       se </span> <span style="font-weight: bold">        lci </span> <span style="font-weight: bold">        uci </span> <span style="font-weight: bold"> cv (%)</span>  <span style="color: #008080; text-decoration-color: #008080">│</span>
<span style="color: #008080; text-decoration-color: #008080">│</span>  ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━  <span style="color: #008080; text-decoration-color: #008080">│</span>
<span style="color: #008080; text-decoration-color: #008080">│</span>  8,751.8209   187.2480   8,381.9707   9,121.6712   2.1395  <span style="color: #008080; text-decoration-color: #008080">│</span>
<span style="color: #008080; text-decoration-color: #008080">│</span>                                                            <span style="color: #008080; text-decoration-color: #008080">│</span>
<span style="color: #008080; text-decoration-color: #008080">╰────────────────────────────────────────────────────────────╯</span>
</pre>
</div>
<div class="cell-output cell-output-stdout">
<pre><code></code></pre>
</div>
</div>
</section>
<section id="mean-expense-per-person-with-an-expense-by-age-category" class="level4">
<h4 class="anchored" data-anchor-id="mean-expense-per-person-with-an-expense-by-age-category">Mean expense per person with an expense, by age category</h4>
<div id="94d87d50" class="cell" data-execution_count="16">
<div class="code-copy-outer-scaffold"><div class="sourceCode cell-code" id="cb30" style="background: #f1f3f5;"><pre class="sourceCode numberSource python number-lines code-with-copy"><code class="sourceCode python"><span id="cb30-1">avg_exp1_by_age_cat <span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">=</span> has_exp_sample.estimation.mean(</span>
<span id="cb30-2">    y<span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">=</span><span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"TOTEXP23"</span>, by<span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">=</span><span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"age_cat"</span></span>
<span id="cb30-3">)</span>
<span id="cb30-4"></span>
<span id="cb30-5"><span class="bu" style="color: null;
background-color: null;
font-style: inherit;">print</span>(avg_exp1_by_age_cat)</span></code></pre></div></div>
<div class="cell-output cell-output-display">
<pre style="white-space:pre;overflow-x:auto;line-height:normal;font-family:Menlo,'DejaVu Sans Mono',consolas,'Courier New',monospace"><span style="color: #008080; text-decoration-color: #008080">╭──────────────────────── Estimate: </span><span style="color: #008080; text-decoration-color: #008080; font-weight: bold">MEAN</span><span style="color: #008080; text-decoration-color: #008080"> (TAYLOR) ────────────────────────╮</span>
<span style="color: #008080; text-decoration-color: #008080">│</span>                                                                         <span style="color: #008080; text-decoration-color: #008080">│</span>
<span style="color: #008080; text-decoration-color: #008080">│</span>  <span style="font-weight: bold">age_cat </span> <span style="font-weight: bold">         est </span> <span style="font-weight: bold">       se </span> <span style="font-weight: bold">         lci </span> <span style="font-weight: bold">         uci </span> <span style="font-weight: bold"> cv (%)</span>  <span style="color: #008080; text-decoration-color: #008080">│</span>
<span style="color: #008080; text-decoration-color: #008080">│</span>  ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━  <span style="color: #008080; text-decoration-color: #008080">│</span>
<span style="color: #008080; text-decoration-color: #008080">│</span>  65+       16,000.1324   517.8130   14,977.3538   17,022.9111   3.2363  <span style="color: #008080; text-decoration-color: #008080">│</span>
<span style="color: #008080; text-decoration-color: #008080">│</span>  &lt;65        6,853.3919   196.1686    6,465.9217    7,240.8620   2.8624  <span style="color: #008080; text-decoration-color: #008080">│</span>
<span style="color: #008080; text-decoration-color: #008080">│</span>                                                                         <span style="color: #008080; text-decoration-color: #008080">│</span>
<span style="color: #008080; text-decoration-color: #008080">╰─────────────────────────────────────────────────────────────────────────╯</span>
</pre>
</div>
<div class="cell-output cell-output-stdout">
<pre><code></code></pre>
</div>
</div>
</section>
<section id="median-expense-per-person-with-an-expense-by-age-category" class="level4">
<h4 class="anchored" data-anchor-id="median-expense-per-person-with-an-expense-by-age-category">Median expense per person with an expense, by age category</h4>
<div id="4dafe6bf" class="cell" data-execution_count="17">
<div class="code-copy-outer-scaffold"><div class="sourceCode cell-code" id="cb32" style="background: #f1f3f5;"><pre class="sourceCode numberSource python number-lines code-with-copy"><code class="sourceCode python"><span id="cb32-1"><span class="im" style="color: #00769E;
background-color: null;
font-style: inherit;">from</span> svy <span class="im" style="color: #00769E;
background-color: null;
font-style: inherit;">import</span> QuantileMethod</span>
<span id="cb32-2"></span>
<span id="cb32-3">median_exp1_by_age_cat <span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">=</span> has_exp_sample.estimation.median(</span>
<span id="cb32-4">    y<span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">=</span><span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"TOTEXP23"</span>, by<span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">=</span><span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"age_cat"</span>, q_method<span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">=</span>QuantileMethod.HIGHER</span>
<span id="cb32-5">)</span>
<span id="cb32-6"></span>
<span id="cb32-7"><span class="bu" style="color: null;
background-color: null;
font-style: inherit;">print</span>(median_exp1_by_age_cat)</span></code></pre></div></div>
</div>
</section>
</section>
</section>
<section id="part-ii---link-the-meps-hc-medical-conditions-file-to-the-office-based-medical-visits-file-for-estimation" class="level2">
<h2 class="anchored" data-anchor-id="part-ii---link-the-meps-hc-medical-conditions-file-to-the-office-based-medical-visits-file-for-estimation">Part II - Link the MEPS-HC Medical Conditions File to the Office-Based Medical Visits File for Estimation</h2>
<section id="merging-relevant-files" class="level3">
<h3 class="anchored" data-anchor-id="merging-relevant-files">Merging Relevant Files</h3>
<section id="load-stata-data-files-using-svy.read_dta" class="level4">
<h4 class="anchored" data-anchor-id="load-stata-data-files-using-svy.read_dta">Load Stata data files using <code>svy.read_dta</code></h4>
<div id="2d58f360" class="cell" data-execution_count="18">
<div class="code-copy-outer-scaffold"><div class="sourceCode cell-code" id="cb33" style="background: #f1f3f5;"><pre class="sourceCode numberSource python number-lines code-with-copy"><code class="sourceCode python"><span id="cb33-1">ob23 <span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">=</span> svy.read_stata(path<span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">=</span><span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"./h248g.dta"</span>)</span>
<span id="cb33-2">cond23 <span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">=</span> svy.read_stata(path<span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">=</span><span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"./h249.dta"</span>)</span>
<span id="cb33-3">clnk23 <span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">=</span> svy.read_stata(path<span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">=</span><span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"./h248if1.dta"</span>)</span>
<span id="cb33-4">fyc23 <span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">=</span> svy.read_stata(path<span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">=</span><span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"./h251.dta"</span>)</span></code></pre></div></div>
</div>
</section>
<section id="keep-only-needed-variables" class="level4">
<h4 class="anchored" data-anchor-id="keep-only-needed-variables">Keep only needed variables</h4>
<div id="06bd2f50" class="cell" data-execution_count="19">
<div class="code-copy-outer-scaffold"><div class="sourceCode cell-code" id="cb34" style="background: #f1f3f5;"><pre class="sourceCode numberSource python number-lines code-with-copy"><code class="sourceCode python"><span id="cb34-1">ob23x <span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">=</span> ob23.select([<span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"DUPERSID"</span>, <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"EVNTIDX"</span>, <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"OBXP23X"</span>])</span>
<span id="cb34-2">cond23x <span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">=</span> cond23.select(</span>
<span id="cb34-3">    [<span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"DUPERSID"</span>, <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"CONDIDX"</span>, <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"ICD10CDX"</span>, <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"CCSR1X"</span>, <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"CCSR2X"</span>, <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"CCSR3X"</span>, <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"CCSR4X"</span>]</span>
<span id="cb34-4">)</span>
<span id="cb34-5">fyc23_sub <span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">=</span> fyc23.select(</span>
<span id="cb34-6">    [<span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"DUPERSID"</span>, <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"AGELAST"</span>, <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"VARSTR"</span>, <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"VARPSU"</span>, <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"PERWT23F"</span>]</span>
<span id="cb34-7">)</span></code></pre></div></div>
</div>
</section>
<section id="prepare-data-for-estimation" class="level4">
<h4 class="anchored" data-anchor-id="prepare-data-for-estimation">Prepare data for estimation</h4>
<div id="0bdaa4db" class="cell" data-execution_count="20">
<div class="code-copy-outer-scaffold"><div class="sourceCode cell-code" id="cb35" style="background: #f1f3f5;"><pre class="sourceCode numberSource python number-lines code-with-copy"><code class="sourceCode python"><span id="cb35-1">cond_combos <span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">=</span> cond23.group_by([<span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"CCSR1X"</span>, <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"CCSR2X"</span>, <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"CCSR3X"</span>, <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"CCSR4X"</span>]).agg(</span>
<span id="cb35-2">    pl.<span class="bu" style="color: null;
background-color: null;
font-style: inherit;">len</span>()</span>
<span id="cb35-3">)</span>
<span id="cb35-4"></span>
<span id="cb35-5"><span class="bu" style="color: null;
background-color: null;
font-style: inherit;">print</span>(cond_combos.sort(by<span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">=</span>[<span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"CCSR1X"</span>, <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"CCSR2X"</span>, <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"CCSR3X"</span>, <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"CCSR4X"</span>]))</span></code></pre></div></div>
<div class="cell-output cell-output-stdout">
<pre><code>shape: (229, 5)
┌────────┬────────┬────────┬────────┬─────┐
│ CCSR1X ┆ CCSR2X ┆ CCSR3X ┆ CCSR4X ┆ len │
│ ---    ┆ ---    ┆ ---    ┆ ---    ┆ --- │
│ str    ┆ str    ┆ str    ┆ str    ┆ u32 │
╞════════╪════════╪════════╪════════╪═════╡
│ -15    ┆ -1     ┆ -1     ┆ -1     ┆ 396 │
│ BLD000 ┆ -1     ┆ -1     ┆ -1     ┆ 127 │
│ BLD000 ┆ CIR000 ┆ -1     ┆ -1     ┆ 1   │
│ BLD000 ┆ NEO000 ┆ -1     ┆ -1     ┆ 5   │
│ BLD001 ┆ -1     ┆ -1     ┆ -1     ┆ 71  │
│ …      ┆ …      ┆ …      ┆ …      ┆ …   │
│ SYM013 ┆ -1     ┆ -1     ┆ -1     ┆ 561 │
│ SYM014 ┆ -1     ┆ -1     ┆ -1     ┆ 313 │
│ SYM015 ┆ -1     ┆ -1     ┆ -1     ┆ 223 │
│ SYM016 ┆ -1     ┆ -1     ┆ -1     ┆ 681 │
│ SYM017 ┆ -1     ┆ -1     ┆ -1     ┆ 460 │
└────────┴────────┴────────┴────────┴─────┘</code></pre>
</div>
</div>
<div id="41bf5826" class="cell" data-execution_count="21">
<div class="code-copy-outer-scaffold"><div class="sourceCode cell-code" id="cb37" style="background: #f1f3f5;"><pre class="sourceCode numberSource python number-lines code-with-copy"><code class="sourceCode python"><span id="cb37-1">cols <span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">=</span> [<span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"CCSR1X"</span>, <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"CCSR2X"</span>, <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"CCSR3X"</span>, <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"CCSR4X"</span>]</span>
<span id="cb37-2"></span>
<span id="cb37-3">cancer <span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">=</span> cond23x.<span class="bu" style="color: null;
background-color: null;
font-style: inherit;">filter</span>(</span>
<span id="cb37-4">    (</span>
<span id="cb37-5">        pl.any_horizontal(pl.col(cols).<span class="bu" style="color: null;
background-color: null;
font-style: inherit;">str</span>.contains(<span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"NEO"</span>))</span>
<span id="cb37-6">        <span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">|</span> pl.any_horizontal(pl.col(cols) <span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">==</span> <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"FAC006"</span>)</span>
<span id="cb37-7">    )</span>
<span id="cb37-8">    <span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">&amp;</span> pl.all_horizontal(pl.col(cols) <span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">!=</span> <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"NEO073"</span>)</span>
<span id="cb37-9">)</span></code></pre></div></div>
</div>
<div id="32e3ba0a" class="cell" data-execution_count="22">
<div class="code-copy-outer-scaffold"><div class="sourceCode cell-code" id="cb38" style="background: #f1f3f5;"><pre class="sourceCode numberSource python number-lines code-with-copy"><code class="sourceCode python"><span id="cb38-1">cancers <span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">=</span> cancer.group_by(</span>
<span id="cb38-2">    [<span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"ICD10CDX"</span>, <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"CCSR1X"</span>, <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"CCSR2X"</span>, <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"CCSR3X"</span>, <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"CCSR4X"</span>]</span>
<span id="cb38-3">).agg(pl.<span class="bu" style="color: null;
background-color: null;
font-style: inherit;">len</span>())</span>
<span id="cb38-4"></span>
<span id="cb38-5"><span class="bu" style="color: null;
background-color: null;
font-style: inherit;">print</span>(cancers.sort(by<span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">=</span>[<span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"ICD10CDX"</span>, <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"CCSR1X"</span>, <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"CCSR2X"</span>, <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"CCSR3X"</span>, <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"CCSR4X"</span>]))</span></code></pre></div></div>
<div class="cell-output cell-output-stdout">
<pre><code>shape: (16, 6)
┌──────────┬────────┬────────┬────────┬────────┬─────┐
│ ICD10CDX ┆ CCSR1X ┆ CCSR2X ┆ CCSR3X ┆ CCSR4X ┆ len │
│ ---      ┆ ---    ┆ ---    ┆ ---    ┆ ---    ┆ --- │
│ str      ┆ str    ┆ str    ┆ str    ┆ str    ┆ u32 │
╞══════════╪════════╪════════╪════════╪════════╪═════╡
│ -15      ┆ BLD000 ┆ NEO000 ┆ -1     ┆ -1     ┆ 5   │
│ -15      ┆ NEO000 ┆ -1     ┆ -1     ┆ -1     ┆ 273 │
│ C18      ┆ NEO015 ┆ -1     ┆ -1     ┆ -1     ┆ 44  │
│ C34      ┆ NEO022 ┆ -1     ┆ -1     ┆ -1     ┆ 42  │
│ C43      ┆ NEO025 ┆ -1     ┆ -1     ┆ -1     ┆ 119 │
│ …        ┆ …      ┆ …      ┆ …      ┆ …      ┆ …   │
│ C73      ┆ NEO050 ┆ -1     ┆ -1     ┆ -1     ┆ 49  │
│ C95      ┆ NEO064 ┆ -1     ┆ -1     ┆ -1     ┆ 46  │
│ D04      ┆ NEO028 ┆ -1     ┆ -1     ┆ -1     ┆ 97  │
│ D48      ┆ NEO072 ┆ -1     ┆ -1     ┆ -1     ┆ 58  │
│ D49      ┆ NEO072 ┆ -1     ┆ -1     ┆ -1     ┆ 78  │
└──────────┴────────┴────────┴────────┴────────┴─────┘</code></pre>
</div>
</div>
</section>
<section id="many-to-many-joins-via-clnk-crosswalk-then-ob-events" class="level4">
<h4 class="anchored" data-anchor-id="many-to-many-joins-via-clnk-crosswalk-then-ob-events">Many-to-many joins via CLNK crosswalk, then OB events</h4>
<div id="677851a1" class="cell" data-execution_count="23">
<div class="code-copy-outer-scaffold"><div class="sourceCode cell-code" id="cb40" style="background: #f1f3f5;"><pre class="sourceCode numberSource python number-lines code-with-copy"><code class="sourceCode python"><span id="cb40-1">cancer_merged <span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">=</span> (</span>
<span id="cb40-2">    cancer</span>
<span id="cb40-3">    .join(clnk23, on<span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">=</span>[<span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"DUPERSID"</span>, <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"CONDIDX"</span>], how<span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">=</span><span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"inner"</span>)   <span class="co" style="color: #5E5E5E;
background-color: null;
font-style: inherit;"># m:m join ok</span></span>
<span id="cb40-4">    .join(ob23x,   on<span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">=</span>[<span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"DUPERSID"</span>, <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"EVNTIDX"</span>], how<span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">=</span><span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"inner"</span>)  <span class="co" style="color: #5E5E5E;
background-color: null;
font-style: inherit;"># m:m join ok</span></span>
<span id="cb40-5">    .with_columns(pl.lit(<span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">1</span>).alias(<span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"ob_visit"</span>))               <span class="co" style="color: #5E5E5E;
background-color: null;
font-style: inherit;"># indicator</span></span>
<span id="cb40-6">)</span></code></pre></div></div>
</div>
</section>
<section id="qc-check-eventype-distribution" class="level4">
<h4 class="anchored" data-anchor-id="qc-check-eventype-distribution">QC: Check EVENTYPE distribution</h4>
<div id="a7bbe81d" class="cell" data-execution_count="24">
<div class="code-copy-outer-scaffold"><div class="sourceCode cell-code" id="cb41" style="background: #f1f3f5;"><pre class="sourceCode numberSource python number-lines code-with-copy"><code class="sourceCode python"><span id="cb41-1">clnk_counts <span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">=</span> (</span>
<span id="cb41-2">    clnk23.group_by(<span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"EVENTYPE"</span>).agg(pl.<span class="bu" style="color: null;
background-color: null;
font-style: inherit;">len</span>().alias(<span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"n"</span>)).sort(<span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"EVENTYPE"</span>)</span>
<span id="cb41-3">)</span>
<span id="cb41-4"><span class="bu" style="color: null;
background-color: null;
font-style: inherit;">print</span>(clnk_counts)</span>
<span id="cb41-5"></span>
<span id="cb41-6">cm_counts <span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">=</span> (</span>
<span id="cb41-7">    cancer_merged.group_by(<span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"EVENTYPE"</span>)</span>
<span id="cb41-8">    .agg(pl.<span class="bu" style="color: null;
background-color: null;
font-style: inherit;">len</span>().alias(<span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"n"</span>))</span>
<span id="cb41-9">    .sort(<span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"EVENTYPE"</span>)</span>
<span id="cb41-10">)</span>
<span id="cb41-11"><span class="bu" style="color: null;
background-color: null;
font-style: inherit;">print</span>(cm_counts)</span></code></pre></div></div>
<div class="cell-output cell-output-stdout">
<pre><code>shape: (6, 2)
┌──────────┬────────┐
│ EVENTYPE ┆ n      │
│ ---      ┆ ---    │
│ f64      ┆ u32    │
╞══════════╪════════╡
│ 1.0      ┆ 145548 │
│ 2.0      ┆ 22177  │
│ 3.0      ┆ 4294   │
│ 4.0      ┆ 2153   │
│ 7.0      ┆ 9045   │
│ 8.0      ┆ 97941  │
└──────────┴────────┘
shape: (1, 2)
┌──────────┬──────┐
│ EVENTYPE ┆ n    │
│ ---      ┆ ---  │
│ f64      ┆ u32  │
╞══════════╪══════╡
│ 1.0      ┆ 4362 │
└──────────┴──────┘</code></pre>
</div>
</div>
</section>
<section id="example-same-event-treating-multiple-cancers-for-same-person" class="level4">
<h4 class="anchored" data-anchor-id="example-same-event-treating-multiple-cancers-for-same-person">Example: Same event treating multiple cancers for same person</h4>
<div id="edf37197" class="cell" data-execution_count="25">
<div class="code-copy-outer-scaffold"><div class="sourceCode cell-code" id="cb43" style="background: #f1f3f5;"><pre class="sourceCode numberSource python number-lines code-with-copy"><code class="sourceCode python"><span id="cb43-1">example_evts <span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">=</span> cancer_merged.<span class="bu" style="color: null;
background-color: null;
font-style: inherit;">filter</span>(pl.col(<span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"DUPERSID"</span>) <span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">==</span> <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"2790405102"</span>)</span>
<span id="cb43-2"></span>
<span id="cb43-3"><span class="bu" style="color: null;
background-color: null;
font-style: inherit;">print</span>(example_evts)</span></code></pre></div></div>
<div class="cell-output cell-output-stdout">
<pre><code>shape: (3, 13)
┌────────────┬───────────────┬──────────┬────────┬───┬──────────┬───────┬─────────┬──────────┐
│ DUPERSID   ┆ CONDIDX       ┆ ICD10CDX ┆ CCSR1X ┆ … ┆ EVENTYPE ┆ PANEL ┆ OBXP23X ┆ ob_visit │
│ ---        ┆ ---           ┆ ---      ┆ ---    ┆   ┆ ---      ┆ ---   ┆ ---     ┆ ---      │
│ str        ┆ str           ┆ str      ┆ str    ┆   ┆ f64      ┆ f64   ┆ f64     ┆ i32      │
╞════════════╪═══════════════╪══════════╪════════╪═══╪══════════╪═══════╪═════════╪══════════╡
│ 2790405102 ┆ 2790405102007 ┆ C61      ┆ NEO039 ┆ … ┆ 1.0      ┆ 27.0  ┆ 184.59  ┆ 1        │
│ 2790405102 ┆ 2790405102005 ┆ D04      ┆ NEO028 ┆ … ┆ 1.0      ┆ 27.0  ┆ 715.29  ┆ 1        │
│ 2790405102 ┆ 2790405102006 ┆ D48      ┆ NEO072 ┆ … ┆ 1.0      ┆ 27.0  ┆ 715.29  ┆ 1        │
└────────────┴───────────────┴──────────┴────────┴───┴──────────┴───────┴─────────┴──────────┘</code></pre>
</div>
</div>
</section>
<section id="de-duplicate-by-evntidx-per-person" class="level4">
<h4 class="anchored" data-anchor-id="de-duplicate-by-evntidx-per-person">De-Duplicate by EVNTIDX Per Person</h4>
<div id="51835041" class="cell" data-execution_count="26">
<div class="code-copy-outer-scaffold"><div class="sourceCode cell-code" id="cb45" style="background: #f1f3f5;"><pre class="sourceCode numberSource python number-lines code-with-copy"><code class="sourceCode python"><span id="cb45-1">cancer_unique <span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">=</span> cancer_merged.unique(</span>
<span id="cb45-2">    subset<span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">=</span>[<span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"DUPERSID"</span>, <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"EVNTIDX"</span>], keep<span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">=</span><span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"first"</span>, maintain_order<span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">=</span><span class="va" style="color: #111111;
background-color: null;
font-style: inherit;">True</span></span>
<span id="cb45-3">)</span></code></pre></div></div>
</div>
</section>
<section id="check-the-example-person-after-de-duplication" class="level4">
<h4 class="anchored" data-anchor-id="check-the-example-person-after-de-duplication">Check the example person after de-duplication</h4>
<div id="04116549" class="cell" data-execution_count="27">
<div class="code-copy-outer-scaffold"><div class="sourceCode cell-code" id="cb46" style="background: #f1f3f5;"><pre class="sourceCode numberSource python number-lines code-with-copy"><code class="sourceCode python"><span id="cb46-1"><span class="bu" style="color: null;
background-color: null;
font-style: inherit;">print</span>(cancer_unique.<span class="bu" style="color: null;
background-color: null;
font-style: inherit;">filter</span>(pl.col(<span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"DUPERSID"</span>) <span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">==</span> <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"2790405102"</span>))</span></code></pre></div></div>
<div class="cell-output cell-output-stdout">
<pre><code>shape: (2, 13)
┌────────────┬───────────────┬──────────┬────────┬───┬──────────┬───────┬─────────┬──────────┐
│ DUPERSID   ┆ CONDIDX       ┆ ICD10CDX ┆ CCSR1X ┆ … ┆ EVENTYPE ┆ PANEL ┆ OBXP23X ┆ ob_visit │
│ ---        ┆ ---           ┆ ---      ┆ ---    ┆   ┆ ---      ┆ ---   ┆ ---     ┆ ---      │
│ str        ┆ str           ┆ str      ┆ str    ┆   ┆ f64      ┆ f64   ┆ f64     ┆ i32      │
╞════════════╪═══════════════╪══════════╪════════╪═══╪══════════╪═══════╪═════════╪══════════╡
│ 2790405102 ┆ 2790405102007 ┆ C61      ┆ NEO039 ┆ … ┆ 1.0      ┆ 27.0  ┆ 184.59  ┆ 1        │
│ 2790405102 ┆ 2790405102005 ┆ D04      ┆ NEO028 ┆ … ┆ 1.0      ┆ 27.0  ┆ 715.29  ┆ 1        │
└────────────┴───────────────┴──────────┴────────┴───┴──────────┴───────┴─────────┴──────────┘</code></pre>
</div>
</div>
</section>
<section id="aggregate-to-person-level" class="level4">
<h4 class="anchored" data-anchor-id="aggregate-to-person-level">Aggregate to person-Level</h4>
<div id="5eaaae47" class="cell" data-execution_count="28">
<div class="code-copy-outer-scaffold"><div class="sourceCode cell-code" id="cb48" style="background: #f1f3f5;"><pre class="sourceCode numberSource python number-lines code-with-copy"><code class="sourceCode python"><span id="cb48-1">pers <span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">=</span> (</span>
<span id="cb48-2">    cancer_unique.group_by(<span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"DUPERSID"</span>)</span>
<span id="cb48-3">    .agg(</span>
<span id="cb48-4">        pl.col(<span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"OBXP23X"</span>)</span>
<span id="cb48-5">        .<span class="bu" style="color: null;
background-color: null;
font-style: inherit;">sum</span>()</span>
<span id="cb48-6">        .alias(<span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"pers_ob_exp"</span>),  <span class="co" style="color: #5E5E5E;
background-color: null;
font-style: inherit;"># total cancer office-visit exp</span></span>
<span id="cb48-7">        pl.col(<span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"ob_visit"</span>)</span>
<span id="cb48-8">        .<span class="bu" style="color: null;
background-color: null;
font-style: inherit;">sum</span>()</span>
<span id="cb48-9">        .alias(<span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"ob_visits"</span>),  <span class="co" style="color: #5E5E5E;
background-color: null;
font-style: inherit;"># total number of cancer office visits</span></span>
<span id="cb48-10">    )</span>
<span id="cb48-11">    .with_columns(any_OB<span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">=</span>pl.lit(<span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">1</span>))  <span class="co" style="color: #5E5E5E;
background-color: null;
font-style: inherit;"># indicator (all 1's in this subset)</span></span>
<span id="cb48-12">)</span></code></pre></div></div>
</div>
</section>
<section id="revisit-the-example-person" class="level4">
<h4 class="anchored" data-anchor-id="revisit-the-example-person">Revisit the example person</h4>
<div id="d29960ef" class="cell" data-execution_count="29">
<div class="code-copy-outer-scaffold"><div class="sourceCode cell-code" id="cb49" style="background: #f1f3f5;"><pre class="sourceCode numberSource python number-lines code-with-copy"><code class="sourceCode python"><span id="cb49-1"><span class="bu" style="color: null;
background-color: null;
font-style: inherit;">print</span>(pers.<span class="bu" style="color: null;
background-color: null;
font-style: inherit;">filter</span>(pl.col(<span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"DUPERSID"</span>) <span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">==</span> <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"2790405102"</span>))</span></code></pre></div></div>
<div class="cell-output cell-output-stdout">
<pre><code>shape: (1, 4)
┌────────────┬─────────────┬───────────┬────────┐
│ DUPERSID   ┆ pers_ob_exp ┆ ob_visits ┆ any_OB │
│ ---        ┆ ---         ┆ ---       ┆ ---    │
│ str        ┆ f64         ┆ i32       ┆ i32    │
╞════════════╪═════════════╪═══════════╪════════╡
│ 2790405102 ┆ 899.88      ┆ 2         ┆ 1      │
└────────────┴─────────────┴───────────┴────────┘</code></pre>
</div>
</div>
</section>
<section id="left-join-person-level-cancer-statistics-onto-fyc" class="level4">
<h4 class="anchored" data-anchor-id="left-join-person-level-cancer-statistics-onto-fyc">Left-join person-level cancer statistics onto FYC</h4>
<div id="6b2a9138" class="cell" data-execution_count="30">
<div class="code-copy-outer-scaffold"><div class="sourceCode cell-code" id="cb51" style="background: #f1f3f5;"><pre class="sourceCode numberSource python number-lines code-with-copy"><code class="sourceCode python"><span id="cb51-1">fyc23_cancer <span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">=</span> (</span>
<span id="cb51-2">    fyc23x.join(pers, on<span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">=</span><span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"DUPERSID"</span>, how<span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">=</span><span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"left"</span>)</span>
<span id="cb51-3">    <span class="co" style="color: #5E5E5E;
background-color: null;
font-style: inherit;"># replace NA with 0 for the joined measures</span></span>
<span id="cb51-4">    .with_columns(pl.col([<span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"ob_visits"</span>, <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"any_OB"</span>, <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"pers_ob_exp"</span>]).fill_null(<span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">0</span>))</span>
<span id="cb51-5">)</span>
<span id="cb51-6"></span>
<span id="cb51-7"><span class="bu" style="color: null;
background-color: null;
font-style: inherit;">print</span>(fyc23_cancer)</span></code></pre></div></div>
<div class="cell-output cell-output-stdout">
<pre><code>shape: (18_919, 11)
┌─────────┬──────────┬────────────┬────────┬───┬─────────┬─────────────┬───────────┬────────┐
│ AGELAST ┆ TOTEXP23 ┆ DUPERSID   ┆ VARSTR ┆ … ┆ age_cat ┆ pers_ob_exp ┆ ob_visits ┆ any_OB │
│ ---     ┆ ---      ┆ ---        ┆ ---    ┆   ┆ ---     ┆ ---         ┆ ---       ┆ ---    │
│ f64     ┆ f64      ┆ str        ┆ f64    ┆   ┆ str     ┆ f64         ┆ i32       ┆ i32    │
╞═════════╪══════════╪════════════╪════════╪═══╪═════════╪═════════════╪═══════════╪════════╡
│ 58.0    ┆ 646.0    ┆ 2790002101 ┆ 2019.0 ┆ … ┆ &lt;65     ┆ 0.0         ┆ 0         ┆ 0      │
│ 27.0    ┆ 1894.0   ┆ 2790002102 ┆ 2019.0 ┆ … ┆ &lt;65     ┆ 0.0         ┆ 0         ┆ 0      │
│ 49.0    ┆ 986.0    ┆ 2790004101 ┆ 2084.0 ┆ … ┆ &lt;65     ┆ 0.0         ┆ 0         ┆ 0      │
│ 75.0    ┆ 1312.0   ┆ 2790006101 ┆ 2113.0 ┆ … ┆ 65+     ┆ 283.28      ┆ 3         ┆ 1      │
│ 23.0    ┆ 0.0      ┆ 2790006102 ┆ 2113.0 ┆ … ┆ &lt;65     ┆ 0.0         ┆ 0         ┆ 0      │
│ …       ┆ …        ┆ …          ┆ …      ┆ … ┆ …       ┆ …           ┆ …         ┆ …      │
│ 11.0    ┆ 4585.0   ┆ 2819784105 ┆ 2015.0 ┆ … ┆ &lt;65     ┆ 0.0         ┆ 0         ┆ 0      │
│ 37.0    ┆ 6820.0   ┆ 2819788101 ┆ 2005.0 ┆ … ┆ &lt;65     ┆ 0.0         ┆ 0         ┆ 0      │
│ 24.0    ┆ 2549.0   ┆ 2819792101 ┆ 2012.0 ┆ … ┆ &lt;65     ┆ 0.0         ┆ 0         ┆ 0      │
│ 22.0    ┆ 1680.0   ┆ 2819793101 ┆ 2004.0 ┆ … ┆ &lt;65     ┆ 0.0         ┆ 0         ┆ 0      │
│ 50.0    ┆ 7802.0   ┆ 2819793102 ┆ 2004.0 ┆ … ┆ &lt;65     ┆ 0.0         ┆ 0         ┆ 0      │
└─────────┴──────────┴────────────┴────────┴───┴─────────┴─────────────┴───────────┴────────┘</code></pre>
</div>
</div>
</section>
<section id="qc-should-match-original-fyc-row-count" class="level4">
<h4 class="anchored" data-anchor-id="qc-should-match-original-fyc-row-count">QC: Should match original FYC row count</h4>
<div id="3f3da08b" class="cell" data-execution_count="31">
<div class="code-copy-outer-scaffold"><div class="sourceCode cell-code" id="cb53" style="background: #f1f3f5;"><pre class="sourceCode numberSource python number-lines code-with-copy"><code class="sourceCode python"><span id="cb53-1">fyc23x.height <span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">==</span> fyc23_cancer.height</span></code></pre></div></div>
<div class="cell-output cell-output-display" data-execution_count="30">
<pre><code>True</code></pre>
</div>
</div>
</section>
</section>
<section id="estimation-of-cancer-related-statistics" class="level3">
<h3 class="anchored" data-anchor-id="estimation-of-cancer-related-statistics">Estimation of Cancer Related Statistics</h3>
<section id="define-the-survey-design" class="level4">
<h4 class="anchored" data-anchor-id="define-the-survey-design">Define the survey design</h4>
<div id="3cdac253" class="cell" data-execution_count="32">
<div class="code-copy-outer-scaffold"><div class="sourceCode cell-code" id="cb55" style="background: #f1f3f5;"><pre class="sourceCode numberSource python number-lines code-with-copy"><code class="sourceCode python"><span id="cb55-1">fyc23_cancer_sample <span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">=</span> Sample(data<span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">=</span>fyc23_cancer, design<span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">=</span>fyc23_design)</span>
<span id="cb55-2"></span>
<span id="cb55-3"><span class="bu" style="color: null;
background-color: null;
font-style: inherit;">print</span>(fyc23_cancer_sample)</span></code></pre></div></div>
<div class="cell-output cell-output-display">
<pre style="white-space:pre;overflow-x:auto;line-height:normal;font-family:Menlo,'DejaVu Sans Mono',consolas,'Courier New',monospace"><span style="color: #008080; text-decoration-color: #008080">╭────────────── Sample ──────────────╮</span>
<span style="color: #008080; text-decoration-color: #008080">│</span> <span style="font-weight: bold">Survey Data</span>                        <span style="color: #008080; text-decoration-color: #008080">│</span>
<span style="color: #008080; text-decoration-color: #008080">│</span>   Rows     : 18919                 <span style="color: #008080; text-decoration-color: #008080">│</span>
<span style="color: #008080; text-decoration-color: #008080">│</span>   Columns  : 14                    <span style="color: #008080; text-decoration-color: #008080">│</span>
<span style="color: #008080; text-decoration-color: #008080">│</span>   Strata   : 105                   <span style="color: #008080; text-decoration-color: #008080">│</span>
<span style="color: #008080; text-decoration-color: #008080">│</span>   PSUs     : 262                   <span style="color: #008080; text-decoration-color: #008080">│</span>
<span style="color: #008080; text-decoration-color: #008080">│</span>                                    <span style="color: #008080; text-decoration-color: #008080">│</span>
<span style="color: #008080; text-decoration-color: #008080">│</span> <span style="font-weight: bold">Survey Design</span>                      <span style="color: #008080; text-decoration-color: #008080">│</span>
<span style="color: #008080; text-decoration-color: #008080">│</span>   Row index          svy_row_index <span style="color: #008080; text-decoration-color: #008080">│</span>
<span style="color: #008080; text-decoration-color: #008080">│</span>   Stratum            VARSTR        <span style="color: #008080; text-decoration-color: #008080">│</span>
<span style="color: #008080; text-decoration-color: #008080">│</span>   PSU                VARPSU        <span style="color: #008080; text-decoration-color: #008080">│</span>
<span style="color: #008080; text-decoration-color: #008080">│</span>   SSU                None          <span style="color: #008080; text-decoration-color: #008080">│</span>
<span style="color: #008080; text-decoration-color: #008080">│</span>   Weight             PERWT23F      <span style="color: #008080; text-decoration-color: #008080">│</span>
<span style="color: #008080; text-decoration-color: #008080">│</span>   With replacement   False         <span style="color: #008080; text-decoration-color: #008080">│</span>
<span style="color: #008080; text-decoration-color: #008080">│</span>   Prob               None          <span style="color: #008080; text-decoration-color: #008080">│</span>
<span style="color: #008080; text-decoration-color: #008080">│</span>   Hit                None          <span style="color: #008080; text-decoration-color: #008080">│</span>
<span style="color: #008080; text-decoration-color: #008080">│</span>   MOS                None          <span style="color: #008080; text-decoration-color: #008080">│</span>
<span style="color: #008080; text-decoration-color: #008080">│</span>   Population size    None          <span style="color: #008080; text-decoration-color: #008080">│</span>
<span style="color: #008080; text-decoration-color: #008080">│</span>   Replicate weights  None          <span style="color: #008080; text-decoration-color: #008080">│</span>
<span style="color: #008080; text-decoration-color: #008080">╰────────────────────────────────────╯</span>
</pre>
</div>
<div class="cell-output cell-output-stdout">
<pre><code></code></pre>
</div>
</div>
</section>
<section id="total-number-of-people-with-office-visit-for-cancer" class="level4">
<h4 class="anchored" data-anchor-id="total-number-of-people-with-office-visit-for-cancer">Total number of people with office visit for cancer</h4>
<div id="8bc22988" class="cell" data-execution_count="33">
<div class="code-copy-outer-scaffold"><div class="sourceCode cell-code" id="cb57" style="background: #f1f3f5;"><pre class="sourceCode numberSource python number-lines code-with-copy"><code class="sourceCode python"><span id="cb57-1">tot_people_office_visits <span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">=</span> fyc23_cancer_sample.estimation.total(<span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"any_OB"</span>)</span>
<span id="cb57-2"></span>
<span id="cb57-3"><span class="bu" style="color: null;
background-color: null;
font-style: inherit;">print</span>(tot_people_office_visits)</span></code></pre></div></div>
<div class="cell-output cell-output-display">
<pre style="white-space:pre;overflow-x:auto;line-height:normal;font-family:Menlo,'DejaVu Sans Mono',consolas,'Courier New',monospace"><span style="color: #008080; text-decoration-color: #008080">╭────────────────────────── Estimate: </span><span style="color: #008080; text-decoration-color: #008080; font-weight: bold">TOTAL</span><span style="color: #008080; text-decoration-color: #008080"> (TAYLOR) ───────────────────────────╮</span>
<span style="color: #008080; text-decoration-color: #008080">│</span>                                                                               <span style="color: #008080; text-decoration-color: #008080">│</span>
<span style="color: #008080; text-decoration-color: #008080">│</span>  <span style="font-weight: bold">            est </span> <span style="font-weight: bold">           se </span> <span style="font-weight: bold">             lci </span> <span style="font-weight: bold">             uci </span> <span style="font-weight: bold"> cv (%)</span>  <span style="color: #008080; text-decoration-color: #008080">│</span>
<span style="color: #008080; text-decoration-color: #008080">│</span>  ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━  <span style="color: #008080; text-decoration-color: #008080">│</span>
<span style="color: #008080; text-decoration-color: #008080">│</span>  15,172,494.4056   600,143.4714   13,987,097.5247   16,357,891.2865   3.9555  <span style="color: #008080; text-decoration-color: #008080">│</span>
<span style="color: #008080; text-decoration-color: #008080">│</span>                                                                               <span style="color: #008080; text-decoration-color: #008080">│</span>
<span style="color: #008080; text-decoration-color: #008080">╰───────────────────────────────────────────────────────────────────────────────╯</span>
</pre>
</div>
<div class="cell-output cell-output-stdout">
<pre><code></code></pre>
</div>
</div>
</section>
<section id="total-number-of-office-visits-for-cancer" class="level4">
<h4 class="anchored" data-anchor-id="total-number-of-office-visits-for-cancer">Total number of office visits for cancer</h4>
<div id="bc96f623" class="cell" data-execution_count="34">
<div class="code-copy-outer-scaffold"><div class="sourceCode cell-code" id="cb59" style="background: #f1f3f5;"><pre class="sourceCode numberSource python number-lines code-with-copy"><code class="sourceCode python"><span id="cb59-1">tot_office_visits <span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">=</span> fyc23_cancer_sample.estimation.total(<span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"ob_visits"</span>)</span>
<span id="cb59-2"></span>
<span id="cb59-3"><span class="bu" style="color: null;
background-color: null;
font-style: inherit;">print</span>(tot_office_visits)</span></code></pre></div></div>
<div class="cell-output cell-output-display">
<pre style="white-space:pre;overflow-x:auto;line-height:normal;font-family:Menlo,'DejaVu Sans Mono',consolas,'Courier New',monospace"><span style="color: #008080; text-decoration-color: #008080">╭─────────────────────────── Estimate: </span><span style="color: #008080; text-decoration-color: #008080; font-weight: bold">TOTAL</span><span style="color: #008080; text-decoration-color: #008080"> (TAYLOR) ────────────────────────────╮</span>
<span style="color: #008080; text-decoration-color: #008080">│</span>                                                                                 <span style="color: #008080; text-decoration-color: #008080">│</span>
<span style="color: #008080; text-decoration-color: #008080">│</span>  <span style="font-weight: bold">            est </span> <span style="font-weight: bold">             se </span> <span style="font-weight: bold">             lci </span> <span style="font-weight: bold">             uci </span> <span style="font-weight: bold"> cv (%)</span>  <span style="color: #008080; text-decoration-color: #008080">│</span>
<span style="color: #008080; text-decoration-color: #008080">│</span>  ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━  <span style="color: #008080; text-decoration-color: #008080">│</span>
<span style="color: #008080; text-decoration-color: #008080">│</span>  61,883,754.7788   4,190,843.7025   53,606,045.7136   70,161,463.8440   6.7721  <span style="color: #008080; text-decoration-color: #008080">│</span>
<span style="color: #008080; text-decoration-color: #008080">│</span>                                                                                 <span style="color: #008080; text-decoration-color: #008080">│</span>
<span style="color: #008080; text-decoration-color: #008080">╰─────────────────────────────────────────────────────────────────────────────────╯</span>
</pre>
</div>
<div class="cell-output cell-output-stdout">
<pre><code></code></pre>
</div>
</div>
</section>
<section id="total-expenditures-of-office-visits-for-cancer" class="level4">
<h4 class="anchored" data-anchor-id="total-expenditures-of-office-visits-for-cancer">Total expenditures of office visits for cancer</h4>
<div id="8ab73331" class="cell" data-execution_count="35">
<div class="code-copy-outer-scaffold"><div class="sourceCode cell-code" id="cb61" style="background: #f1f3f5;"><pre class="sourceCode numberSource python number-lines code-with-copy"><code class="sourceCode python"><span id="cb61-1">tot_exp_cancer <span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">=</span> fyc23_cancer_sample.estimation.total(<span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"pers_ob_exp"</span>)</span>
<span id="cb61-2"></span>
<span id="cb61-3"><span class="bu" style="color: null;
background-color: null;
font-style: inherit;">print</span>(tot_exp_cancer)</span></code></pre></div></div>
<div class="cell-output cell-output-display">
<pre style="white-space:pre;overflow-x:auto;line-height:normal;font-family:Menlo,'DejaVu Sans Mono',consolas,'Courier New',monospace"><span style="color: #008080; text-decoration-color: #008080">╭────────────────────────────── Estimate: </span><span style="color: #008080; text-decoration-color: #008080; font-weight: bold">TOTAL</span><span style="color: #008080; text-decoration-color: #008080"> (TAYLOR) ───────────────────────────────╮</span>
<span style="color: #008080; text-decoration-color: #008080">│</span>                                                                                       <span style="color: #008080; text-decoration-color: #008080">│</span>
<span style="color: #008080; text-decoration-color: #008080">│</span>  <span style="font-weight: bold">              est </span> <span style="font-weight: bold">               se </span> <span style="font-weight: bold">              lci </span> <span style="font-weight: bold">             uci </span> <span style="font-weight: bold">  cv (%)</span>  <span style="color: #008080; text-decoration-color: #008080">│</span>
<span style="color: #008080; text-decoration-color: #008080">│</span>  ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━  <span style="color: #008080; text-decoration-color: #008080">│</span>
<span style="color: #008080; text-decoration-color: #008080">│</span>  45,177,084,342.0…   10,188,777,333.…   25,052,321,767.…   65,301,846,916…   22.5530  <span style="color: #008080; text-decoration-color: #008080">│</span>
<span style="color: #008080; text-decoration-color: #008080">│</span>                                                                                       <span style="color: #008080; text-decoration-color: #008080">│</span>
<span style="color: #008080; text-decoration-color: #008080">╰───────────────────────────────────────────────────────────────────────────────────────╯</span>
</pre>
</div>
<div class="cell-output cell-output-stdout">
<pre><code></code></pre>
</div>
</div>
</section>
<section id="proportion-of-people-with-office-visit-for-cancer" class="level4">
<h4 class="anchored" data-anchor-id="proportion-of-people-with-office-visit-for-cancer">Proportion of people with office visit for cancer</h4>
<div id="688c065e" class="cell" data-execution_count="36">
<div class="code-copy-outer-scaffold"><div class="sourceCode cell-code" id="cb63" style="background: #f1f3f5;"><pre class="sourceCode numberSource python number-lines code-with-copy"><code class="sourceCode python"><span id="cb63-1">prop_people_office_visits <span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">=</span> fyc23_cancer_sample.estimation.prop(<span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"any_OB"</span>)</span>
<span id="cb63-2"></span>
<span id="cb63-3"><span class="co" style="color: #5E5E5E;
background-color: null;
font-style: inherit;"># prop_people_office_visits.set_decimals(6)</span></span>
<span id="cb63-4"><span class="bu" style="color: null;
background-color: null;
font-style: inherit;">print</span>(prop_people_office_visits)</span></code></pre></div></div>
<div class="cell-output cell-output-display">
<pre style="white-space:pre;overflow-x:auto;line-height:normal;font-family:Menlo,'DejaVu Sans Mono',consolas,'Courier New',monospace"><span style="color: #008080; text-decoration-color: #008080">╭─────────────── Estimate: </span><span style="color: #008080; text-decoration-color: #008080; font-weight: bold">PROP</span><span style="color: #008080; text-decoration-color: #008080"> (TAYLOR) ───────────────╮</span>
<span style="color: #008080; text-decoration-color: #008080">│</span>                                                       <span style="color: #008080; text-decoration-color: #008080">│</span>
<span style="color: #008080; text-decoration-color: #008080">│</span>  <span style="font-weight: bold">any_OB </span> <span style="font-weight: bold">    est </span> <span style="font-weight: bold">     se </span> <span style="font-weight: bold">    lci </span> <span style="font-weight: bold">    uci </span> <span style="font-weight: bold"> cv (%)</span>  <span style="color: #008080; text-decoration-color: #008080">│</span>
<span style="color: #008080; text-decoration-color: #008080">│</span>  ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━  <span style="color: #008080; text-decoration-color: #008080">│</span>
<span style="color: #008080; text-decoration-color: #008080">│</span>  0        0.9546   0.0017   0.9512   0.9579   0.1779  <span style="color: #008080; text-decoration-color: #008080">│</span>
<span style="color: #008080; text-decoration-color: #008080">│</span>  1        0.0454   0.0017   0.0421   0.0488   3.7439  <span style="color: #008080; text-decoration-color: #008080">│</span>
<span style="color: #008080; text-decoration-color: #008080">│</span>                                                       <span style="color: #008080; text-decoration-color: #008080">│</span>
<span style="color: #008080; text-decoration-color: #008080">╰───────────────────────────────────────────────────────╯</span>
</pre>
</div>
<div class="cell-output cell-output-stdout">
<pre><code></code></pre>
</div>
</div>
</section>
<section id="average-expense-per-person-for-office-visits-for-cancer-among-people-with-an-office-visit-for-cancer" class="level4">
<h4 class="anchored" data-anchor-id="average-expense-per-person-for-office-visits-for-cancer-among-people-with-an-office-visit-for-cancer">Average expense per person for office visits for cancer among people with an office visit for cancer</h4>
<div id="03e66b5e" class="cell" data-execution_count="37">
<div class="code-copy-outer-scaffold"><div class="sourceCode cell-code" id="cb65" style="background: #f1f3f5;"><pre class="sourceCode numberSource python number-lines code-with-copy"><code class="sourceCode python"><span id="cb65-1">avg_exp_cancer <span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">=</span> fyc23_cancer_sample.estimation.mean(<span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"pers_ob_exp"</span>, by<span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">=</span><span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"any_OB"</span>)</span>
<span id="cb65-2"></span>
<span id="cb65-3"><span class="bu" style="color: null;
background-color: null;
font-style: inherit;">print</span>(avg_exp_cancer)</span></code></pre></div></div>
<div class="cell-output cell-output-display">
<pre style="white-space:pre;overflow-x:auto;line-height:normal;font-family:Menlo,'DejaVu Sans Mono',consolas,'Courier New',monospace"><span style="color: #008080; text-decoration-color: #008080">╭────────────────────── Estimate: </span><span style="color: #008080; text-decoration-color: #008080; font-weight: bold">MEAN</span><span style="color: #008080; text-decoration-color: #008080"> (TAYLOR) ───────────────────────╮</span>
<span style="color: #008080; text-decoration-color: #008080">│</span>                                                                      <span style="color: #008080; text-decoration-color: #008080">│</span>
<span style="color: #008080; text-decoration-color: #008080">│</span>  <span style="font-weight: bold">any_OB </span> <span style="font-weight: bold">        est </span> <span style="font-weight: bold">       se </span> <span style="font-weight: bold">        lci </span> <span style="font-weight: bold">        uci </span> <span style="font-weight: bold">  cv (%)</span>  <span style="color: #008080; text-decoration-color: #008080">│</span>
<span style="color: #008080; text-decoration-color: #008080">│</span>  ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━  <span style="color: #008080; text-decoration-color: #008080">│</span>
<span style="color: #008080; text-decoration-color: #008080">│</span>  0            0.0000     0.0000       0.0000       0.0000       inf  <span style="color: #008080; text-decoration-color: #008080">│</span>
<span style="color: #008080; text-decoration-color: #008080">│</span>  1        2,977.5647   668.6195   1,655.9099   4,299.2196   22.4552  <span style="color: #008080; text-decoration-color: #008080">│</span>
<span style="color: #008080; text-decoration-color: #008080">│</span>                                                                      <span style="color: #008080; text-decoration-color: #008080">│</span>
<span style="color: #008080; text-decoration-color: #008080">╰──────────────────────────────────────────────────────────────────────╯</span>
</pre>
</div>
<div class="cell-output cell-output-stdout">
<pre><code></code></pre>
</div>
</div>



</section>
</section>
</section>

<a onclick="window.scrollTo(0, 0); return false;" id="quarto-back-to-top"><i class="bi bi-arrow-up"></i> Back to top</a> ]]></description>
  <category>true</category>
  <guid>https://svylab.com/learn/workshops/meps-2025/</guid>
  <pubDate>Mon, 27 Oct 2025 04:00:00 GMT</pubDate>
</item>
</channel>
</rss>
