<p><div><div><div><div data-show-faces="false" data-height="21" data-width="100" data-layout="button_count" data-send="true" data-href="https://www.r-bloggers.com/what-is-the-appropriate-population-scaling-of-the-affordable-care-act-funding/"></div></div><div></div></div><div></div></div>
<div>
(This article was first published on <strong><a href="http://yonicd.github.io/2017-09-26-aca/"> Jonathan Sidi's R Blog</a></strong>, and kindly contributed to <a rel="nofollow" href="https://www.r-bloggers.com/">R-bloggers)</a> </div>
<p>	Analysis of the effects of the Graham-Cassidy Bill on the ACA population – </p>
<p>I have been trying to decipher for myself, what is in the current (well, yesterday’s) Graham-Cassidy health care bill. I saw this image on many news outlets a few days ago and my inner hate for pie charts bubbled up.</p>
<p><img alt="" src="https://i1.wp.com/raw.githubusercontent.com/yonicd/yonicd.github.io/master/img/aca/ACA_pie_full.jpg?w=456&ssl=1" data-recalc-dims="1"></p>
<p>This is a zoom in on the pie chart … From what I can gather, these figures are attempting to say that there are specific states that are getting relatively more of the federal health care funds under the Afordable Care Act (ACA) than their relative state population. Among the many things that are really hard to do with pie charts , comparing distributions ranks pretty high up there.</p>
<p><img alt="" src="https://i1.wp.com/raw.githubusercontent.com/yonicd/yonicd.github.io/master/img/aca/ACA_pie.png?w=456&ssl=1" data-recalc-dims="1"></p>
<p>It is common practice when comparing different geographical areas that have different populations levels to scale it using the rate per person (per capita) or per number of people, e.g. rate per 1,000 people. In this case it would be population adjusted state federal funding. The question that needs answering, what is the relevant population.</p>
<p>Many charts in the last week have scaled the funding adjusted to state population (as is alluded to in the figure above), but the funds are not actually being used by everyone in each state, most people have health care from their employer. So, what is the actual population that is being serviced by the federal funding for the ACA? How much of a different picture does that paint from the original figure?</p>
<p>Hopefully this post will help motivate readers to start looking around for more data on what is the effect of the proposed bill on the approprations of federal funds on the state level.</p>
<p>My sources of information is the Kaiser Family Foundation site that have a great database for data on the ACA and the proposed bill, and Wikipedia for auxilary population data. We will end up with the following figure, but along the way I learned a number of things that I didn’t know from reading online and seeing the news on TV.</p>
<p><img alt="" src="https://i1.wp.com/raw.githubusercontent.com/yonicd/yonicd.github.io/master/img/aca/unnamed-chunk-17-1.png?w=456&ssl=1" data-recalc-dims="1"></p>
<p>A quick note before you proceed – This is not meant to be an all encompassing analysis of the predicted effects of the Graham-Cassidy bill, as it has been said before: “Healthcare is hard…”, and if I made any bad assumptions I apologize in advanced and welcome any comments and suggestions to better understand the subject matter.</p>
<p>Saying that, let’s continue:</p>
<div>
<pre><code><span>library</span><span>(</span><span>xml2</span><span>)</span><span>
</span><span>library</span><span>(</span><span>rvest</span><span>)</span><span>
</span><span>library</span><span>(</span><span>dplyr</span><span>)</span><span>
</span><span>library</span><span>(</span><span>ggplot2</span><span>)</span><span>
</span><span>library</span><span>(</span><span>geofacet</span><span>)</span><span>
</span><span>knitr</span><span>::</span><span>opts_chunk</span><span>$</span><span>set</span><span>(</span><span>fig.height</span><span>=</span><span>7</span><span>,</span><span>fig.width</span><span>=</span><span>12</span><span>,</span><span>warning</span><span>=</span><span>FALSE</span><span>,</span><span>message</span><span>=</span><span>FALSE</span><span>)</span><span>
</span></code></pre>
</div>
<h2>Scraping the relevant information</h2>
<h3>Kaiser Family Foundation</h3>
<h4>ACA and Graham-Cassidy federal spending by state.</h4>
<div>
<pre><code><span>kf_spending</span><span> </span><span>&lt;-</span><span> </span><span>(</span><span>xml2</span><span>::</span><span>read_html</span><span>(</span><span>'http://www.kff.org/health-reform/issue-brief/state-by-state-estimates-of-changes-in-federal-spending-on-health-care-under-the-graham-cassidy-bill/'</span><span>)</span><span>%>%</span><span>
</span><span>rvest</span><span>::</span><span>html_table</span><span>())[[</span><span>2</span><span>]][</span><span>-</span><span>c</span><span>(</span><span>1</span><span>,</span><span>2</span><span>,</span><span>3</span><span>,</span><span>55</span><span>),]</span><span>
</span><span>names</span><span>(</span><span>kf_spending</span><span>)</span><span> </span><span>&lt;-</span><span> </span><span>c</span><span>(</span><span>'Location'</span><span>,</span><span>'ACA'</span><span>,</span><span>'GC'</span><span>,</span><span>'DIFF'</span><span>,</span><span>'PCT'</span><span>)</span><span>
</span><span>kf_spending</span><span>$</span><span>Location</span><span>[</span><span>which</span><span>(</span><span>kf_spending</span><span>$</span><span>Location</span><span>==</span><span>'DC'</span><span>)]</span><span>=</span><span>'District of Columbia'</span><span>
</span><span>kf_spending</span><span> </span><span>&lt;-</span><span> </span><span>kf_spending</span><span>%>%</span><span>mutate_at</span><span>(</span><span>.vars</span><span>=</span><span>vars</span><span>(</span><span>ACA</span><span>,</span><span>GC</span><span>,</span><span>DIFF</span><span>,</span><span>PCT</span><span>),</span><span>.funs</span><span>=</span><span>funs</span><span>(</span><span>as.numeric</span><span>(</span><span>gsub</span><span>(</span><span>'[,%]'</span><span>,</span><span>''</span><span>,</span><span>.</span><span>))))</span><span>
</span></code></pre>
</div>
<h4>ACA medicare expansion by state</h4>
<p>The decision of each state to accept medicare expansion will have a large affect on the net affect of GC on the redistribution of federal funds. States that did not accept medicare expansion are expected to have a net positive increase of federal funds.</p>
<div>
<pre><code><span>#http://www.kff.org/health-reform/state-indicator/state-activity-around-expanding-medicaid-under-the-affordable-care-act/?currentTimeframe=0&amp;sortModel=%7B%22colId%22:%22Location%22,%22sort%22:%22asc%22%7D
</span><span>kf_expansion</span><span> </span><span>&lt;-</span><span> </span><span>read.csv</span><span>(</span><span>'data/kf_expansion.csv'</span><span>,</span><span>stringsAsFactors</span><span> </span><span>=</span><span> </span><span>FALSE</span><span>,</span><span>skip</span><span> </span><span>=</span><span> </span><span>2</span><span>)</span><span>
</span><span>kf_expansion</span><span> </span><span>&lt;-</span><span> </span><span>kf_expansion</span><span>[</span><span>-</span><span>c</span><span>(</span><span>1</span><span>,</span><span>53</span><span>:</span><span>61</span><span>),</span><span>-3</span><span>]</span><span>
</span><span>names</span><span>(</span><span>kf_expansion</span><span>)[</span><span>2</span><span>]</span><span> </span><span>&lt;-</span><span> </span><span>'Expansion'</span><span>
</span></code></pre>
</div>
<h4>Population of ACA enrollment by state.</h4>
<p>The target population that will be used to scale the federal funds is the total marketplace enrollment for each state. We also add the characteristic of type of marketplace applied in the state to check if that has any effect.</p>
<ul>
<li>Federally-Facilitated Market</li>
<li>State-based Marketplace</li>
<li>State-based Marketplace (using HealthCare.gov)</li>
</ul>
<div>
<pre><code><span>#http://www.kff.org/health-reform/state-indicator/total-marketplace-enrollment/?currentTimeframe=0&amp;sortModel=%7B%22colId%22:%22Total%20Individuals%20Who%20Have%20Selected%20a%20Marketplace%20Plan%22,%22sort%22:%22asc%22%7D
</span><span>kf_marketplace_pop</span><span> </span><span>&lt;-</span><span> </span><span>read.csv</span><span>(</span><span>'data/kf_marketplace_pop.csv'</span><span>,</span><span>stringsAsFactors</span><span> </span><span>=</span><span> </span><span>FALSE</span><span>,</span><span>skip</span><span> </span><span>=</span><span> </span><span>2</span><span>)</span><span>
</span><span>kf_marketplace_pop</span><span> </span><span>&lt;-</span><span> </span><span>kf_marketplace_pop</span><span>[</span><span>-</span><span>c</span><span>(</span><span>1</span><span>,</span><span>53</span><span>:</span><span>59</span><span>),]</span><span>
</span><span>names</span><span>(</span><span>kf_marketplace_pop</span><span>)[</span><span>c</span><span>(</span><span>2</span><span>,</span><span>3</span><span>)]</span><span> </span><span>&lt;-</span><span> </span><span>c</span><span>(</span><span>'Marketplace_Type'</span><span>,</span><span>'N'</span><span>)</span><span>
</span></code></pre>
</div>
<h3>Wikipedia</h3>
<h4>State characteristics (2016 elections and general population)</h4>
<p>To gather more characteristics of each state are the 2016 general election results and the total population in each state, so the prevalent scaling can be used as a comparison.</p>
<div>
<pre><code><span>wiki_elections</span><span> </span><span>&lt;-</span><span> </span><span>(</span><span>xml2</span><span>::</span><span>read_html</span><span>(</span><span>'https://en.wikipedia.org/wiki/United_States_presidential_election,_2016'</span><span>)</span><span>%>%</span><span>
</span><span>rvest</span><span>::</span><span>xml_nodes</span><span>(</span><span>xpath</span><span>=</span><span>'//*[@id=&quot;mw-content-text&quot;]/div/div[40]/table'</span><span>)</span><span>%>%</span><span>
</span><span>rvest</span><span>::</span><span>html_table</span><span>())[[</span><span>1</span><span>]][</span><span>-</span><span>c</span><span>(</span><span>1</span><span>,</span><span>58</span><span>),</span><span>c</span><span>(</span><span>1</span><span>,</span><span>3</span><span>,</span><span>6</span><span>,</span><span>23</span><span>)]</span><span>
</span><span>names</span><span>(</span><span>wiki_elections</span><span>)</span><span> </span><span>&lt;-</span><span> </span><span>c</span><span>(</span><span>'Location'</span><span>,</span><span>'Clinton'</span><span>,</span><span>'Trump'</span><span>,</span><span>'Total'</span><span>)</span><span>
</span><span>wiki_elections</span><span>$</span><span>Location</span><span>[</span><span>grep</span><span>(</span><span>'^Nebraska'</span><span>,</span><span>wiki_elections</span><span>$</span><span>Location</span><span>)]</span><span> </span><span>&lt;-</span><span> </span><span>'Nebraska'</span><span>
</span><span>wiki_elections</span><span>$</span><span>Location</span><span>[</span><span>grep</span><span>(</span><span>'^Maine'</span><span>,</span><span>wiki_elections</span><span>$</span><span>Location</span><span>)]</span><span> </span><span>&lt;-</span><span> </span><span>'Maine'</span><span>
</span><span>wiki_elections</span><span> </span><span>&lt;-</span><span> </span><span>wiki_elections</span><span>%>%</span><span>
</span><span>mutate_at</span><span>(</span><span>.vars</span><span> </span><span>=</span><span> </span><span>vars</span><span>(</span><span>Clinton</span><span>,</span><span>Trump</span><span>,</span><span>Total</span><span>),</span><span>.funs</span><span>=</span><span>funs</span><span>(</span><span>as.numeric</span><span>(</span><span>gsub</span><span>(</span><span>'[,]'</span><span>,</span><span>''</span><span>,</span><span>.</span><span>))))</span><span>%>%</span><span>
</span><span>group_by</span><span>(</span><span>Location</span><span>)</span><span>%>%</span><span>summarise_at</span><span>(</span><span>.vars</span><span> </span><span>=</span><span> </span><span>vars</span><span>(</span><span>Clinton</span><span>,</span><span>Trump</span><span>,</span><span>Total</span><span>),</span><span>.funs</span><span> </span><span>=</span><span> </span><span>funs</span><span>(</span><span>sum</span><span>))</span><span>%>%</span><span>
</span><span>mutate</span><span>(</span><span>ClintonPct</span><span>=</span><span>Clinton</span><span>/</span><span>Total</span><span>,</span><span>TrumpPct</span><span>=</span><span>Trump</span><span>/</span><span>Total</span><span>,</span><span>TrumpWin</span><span>=</span><span>ifelse</span><span>(</span><span>TrumpPct</span><span>></span><span>ClintonPct</span><span>,</span><span>'Trump Win'</span><span>,</span><span>'Clinton Win'</span><span>))</span><span>
</span><span>wiki_pop</span><span> </span><span>&lt;-</span><span> </span><span>(</span><span>xml2</span><span>::</span><span>read_html</span><span>(</span><span>'https://en.wikipedia.org/wiki/List_of_U.S._states_and_territories_by_population'</span><span>)</span><span>%>%</span><span>
</span><span>rvest</span><span>::</span><span>xml_nodes</span><span>(</span><span>xpath</span><span>=</span><span>'//*[@id=&quot;mw-content-text&quot;]/div/table[1]'</span><span>)</span><span>%>%</span><span>
</span><span>rvest</span><span>::</span><span>html_table</span><span>())[[</span><span>1</span><span>]][</span><span>-</span><span>c</span><span>(</span><span>30</span><span>,</span><span>53</span><span>:</span><span>64</span><span>),</span><span>c</span><span>(</span><span>3</span><span>,</span><span>4</span><span>)]</span><span>
</span><span>names</span><span>(</span><span>wiki_pop</span><span>)</span><span> </span><span>&lt;-</span><span> </span><span>c</span><span>(</span><span>'Location'</span><span>,</span><span>'Total_N'</span><span>)</span><span>
</span><span>wiki_pop</span><span>$</span><span>Total_N</span><span> </span><span>&lt;-</span><span> </span><span>as.numeric</span><span>(</span><span>gsub</span><span>(</span><span>'[,]'</span><span>,</span><span>''</span><span>,</span><span>wiki_pop</span><span>$</span><span>Total_N</span><span>))</span><span>
</span></code></pre>
</div>
<h3>Join all the data sets</h3>
<p>We join all the information and create a new variable – the change in federal funds from ACA to GC. This is done for the rate per 1,000 individuals who have selected a market based plan and the broader per 1,000 individuals state total. The former assumes that this the more consice defition of the population better reflects what is the population serviced by the federal funding, and that it is the potential population that would be serviced by the GC bill.</p>
<div>
<pre><code><span>kf</span><span> </span><span>&lt;-</span><span> </span><span>kf_marketplace_pop</span><span>%>%</span><span>
</span><span>left_join</span><span>(</span><span>kf_expansion</span><span>,</span><span>by</span><span>=</span><span>'Location'</span><span>)</span><span>%>%</span><span>
</span><span>left_join</span><span>(</span><span>wiki_pop</span><span>,</span><span>by</span><span>=</span><span>'Location'</span><span>)</span><span>
</span><span>kf</span><span> </span><span>&lt;-</span><span> </span><span>kf_spending</span><span>%>%</span><span>left_join</span><span>(</span><span>kf</span><span>,</span><span> </span><span>by</span><span> </span><span>=</span><span> </span><span>c</span><span>(</span><span>'Location'</span><span>))</span><span>%>%</span><span>
</span><span>mutate</span><span>(</span><span>ratio_ACA</span><span>=</span><span>1000</span><span>*</span><span>ACA</span><span>/</span><span>N</span><span>,</span><span>ratio_GC</span><span>=</span><span>1000</span><span>*</span><span>GC</span><span>/</span><span>N</span><span>,</span><span>ratio_DIFF</span><span> </span><span>=</span><span> </span><span>ratio_GC</span><span>-</span><span>ratio_ACA</span><span>,</span><span>
</span><span>tot_ratio_ACA</span><span>=</span><span>1000</span><span>*</span><span>ACA</span><span>/</span><span>Total_N</span><span>,</span><span>tot_ratio_GC</span><span>=</span><span>1000</span><span>*</span><span>GC</span><span>/</span><span>Total_N</span><span>,</span><span>tot_ratio_DIFF</span><span> </span><span>=</span><span> </span><span>tot_ratio_GC</span><span>-</span><span>tot_ratio_ACA</span><span>)</span><span>%>%</span><span>
</span><span>arrange</span><span>(</span><span>desc</span><span>(</span><span>ratio_DIFF</span><span>))</span><span>
</span><span>kf</span><span> </span><span>&lt;-</span><span> </span><span>kf</span><span>%>%</span><span>left_join</span><span>(</span><span>wiki_elections</span><span>,</span><span>by</span><span>=</span><span>'Location'</span><span>)</span><span>
</span><span>kf</span><span>$</span><span>Expansion</span><span> </span><span>&lt;-</span><span> </span><span>sprintf</span><span>(</span><span>'Medicaid Expansion %s'</span><span>,</span><span>kf</span><span>$</span><span>Expansion</span><span>)</span><span>
</span><span>kf</span><span>$</span><span>Location</span><span> </span><span>&lt;-</span><span> </span><span>factor</span><span>(</span><span>kf</span><span>$</span><span>Location</span><span>,</span><span>levels</span><span> </span><span>=</span><span> </span><span>kf</span><span>$</span><span>Location</span><span>)</span><span>
</span><span>kf</span><span>$</span><span>Marketplace_Type</span><span> </span><span>&lt;-</span><span> </span><span>factor</span><span>(</span><span>kf</span><span>$</span><span>Marketplace_Type</span><span>,</span><span>labels</span><span>=</span><span>c</span><span>(</span><span>'Federally-Facilitated Market'</span><span>,</span><span>'State-based Marketplace'</span><span>,</span><span>'State-based Marketplace (using HealthCare.gov)'</span><span>))</span><span>
</span></code></pre>
</div>
<h2>Plots</h2>
<h3>Percent of state population enrolled in ACA</h3>
<p>First we want to see what is the scope of the population in each state that have selected an ACA market based plan. (note California… not quite 12% of the US population)</p>
<div>
<pre><code><span>kf</span><span>%>%</span><span>
</span><span>mutate</span><span>(</span><span>pop_pct</span><span>=</span><span>100</span><span>*</span><span>N</span><span>/</span><span>Total_N</span><span>)</span><span>%>%</span><span>
</span><span>arrange</span><span>(</span><span>desc</span><span>(</span><span>pop_pct</span><span>))</span><span>%>%</span><span>
</span><span>mutate</span><span>(</span><span>Location</span><span>=</span><span>factor</span><span>(</span><span>Location</span><span>,</span><span>levels</span><span>=</span><span>Location</span><span>))</span><span>%>%</span><span>
</span><span>ggplot</span><span>(</span><span>aes</span><span>(</span><span>x</span><span>=</span><span>Location</span><span>,</span><span>y</span><span>=</span><span>pop_pct</span><span>))</span><span>+</span><span>
</span><span>geom_point</span><span>()</span><span>+</span><span>
</span><span>coord_flip</span><span>()</span><span>+</span><span>
</span><span>labs</span><span>(</span><span>y</span><span>=</span><span>'Percent of Population that have selected an ACA market based plan'</span><span>)</span><span>
</span></code></pre>
</div>
<p><img alt="" src="https://i0.wp.com/raw.githubusercontent.com/yonicd/yonicd.github.io/master/img/aca/unnamed-chunk-7-1.png?w=456&ssl=1" data-recalc-dims="1"></p>
<h3>Overall distribution by Medicare Expansion</h3>
<p>We then check that there really is a difference between states that expanded and did not expand medicaid under the ACA and if being a state that voted Republican compared to Democratic.</p>
<div>
<pre><code><span>boxplot_dat</span><span> </span><span>&lt;-</span><span> </span><span>kf</span><span>%>%</span><span>
</span><span>dplyr</span><span>::</span><span>select</span><span>(</span><span>Expansion</span><span>,</span><span>Marketplace_Type</span><span>,</span><span>TrumpWin</span><span>,</span><span> </span><span>ratio_DIFF</span><span>,</span><span>tot_ratio_DIFF</span><span>)</span><span>%>%</span><span>
</span><span>reshape2</span><span>::</span><span>melt</span><span>(</span><span>.</span><span>,</span><span>id</span><span>=</span><span>c</span><span>(</span><span>'Marketplace_Type'</span><span>,</span><span>'Expansion'</span><span>,</span><span>'TrumpWin'</span><span>))</span><span>
</span><span>levels</span><span>(</span><span>boxplot_dat</span><span>$</span><span>variable</span><span>)</span><span> </span><span>&lt;-</span><span> </span><span>c</span><span>(</span><span>'per 1,000 Individuals who have\nselected a market based plan'</span><span>,</span><span>'per 1,000 Individuals'</span><span>)</span><span>
</span><span>boxplot_dat</span><span>%>%</span><span>
</span><span>ggplot</span><span>(</span><span>aes</span><span>(</span><span>x</span><span>=</span><span>Expansion</span><span>,</span><span>
</span><span>y</span><span>=</span><span>value</span><span>,</span><span>
</span><span>fill</span><span>=</span><span>TrumpWin</span><span>))</span><span>+</span><span>
</span><span>geom_boxplot</span><span>()</span><span>+</span><span>
</span><span>geom_hline</span><span>(</span><span>aes</span><span>(</span><span>yintercept</span><span>=</span><span>0</span><span>),</span><span>linetype</span><span>=</span><span>2</span><span>)</span><span>+</span><span>
</span><span>facet_wrap</span><span>(</span><span>~</span><span>variable</span><span>,</span><span>ncol</span><span>=</span><span>1</span><span>,</span><span>scales</span><span>=</span><span>'free_y'</span><span>)</span><span>+</span><span>
</span><span>labs</span><span>(</span><span>title</span><span>=</span><span>'Change in Federal Funds ACA vs Graham-Cassidy, 2020-2026'</span><span>,</span><span>
</span><span>y</span><span>=</span><span>'Change in Federal Funds ($ Millions) per 1,000 individuals'</span><span>)</span><span>+</span><span>
</span><span>theme_bw</span><span>()</span><span>+</span><span>
</span><span>theme</span><span>(</span><span>legend.position</span><span> </span><span>=</span><span> </span><span>'bottom'</span><span>)</span><span>
</span></code></pre>
</div>
<p><img alt="" src="https://i0.wp.com/raw.githubusercontent.com/yonicd/yonicd.github.io/master/img/aca/unnamed-chunk-8-1.png?w=456&ssl=1" data-recalc-dims="1"></p>
<p>Drilling down to state level figures we show for each state the change from ACA funding to the proposed GC funding per 1,000 persons who selected a market based ACA plan. The arrows move from ACA to GC funding and the y-axis is ordered by the increasing net difference. This comparison is faceted among the different characteristics scrapped from above.</p>
<p>Some things to look for:</p>
<ul>
<li>New York has the largest negative net funding per 1,000 persons.</li>
<li>Kentucky has the largest negative net funding per 1,000 persons among Republican leaning states.</li>
<li>The net increase in funding per 1,000 persons for states that did not expand medicaid is mostly minimal.</li>
</ul>
<div>
<pre><code><span>p</span><span> </span><span>&lt;-</span><span> </span><span>kf</span><span>%>%</span><span>ggplot</span><span>(</span><span>aes</span><span>(</span><span>x</span><span>=</span><span>Location</span><span>,</span><span>xend</span><span>=</span><span>Location</span><span>,</span><span>yend</span><span>=</span><span>ratio_GC</span><span>,</span><span>y</span><span>=</span><span>ratio_ACA</span><span>,</span><span>colour</span><span>=</span><span>ratio_DIFF</span><span>))</span><span>+</span><span>
</span><span>geom_segment</span><span>(</span><span>arrow</span><span> </span><span>=</span><span> </span><span>arrow</span><span>(</span><span>length</span><span> </span><span>=</span><span> </span><span>unit</span><span>(</span><span>0.02</span><span>,</span><span> </span><span>&quot;npc&quot;</span><span>)))</span><span>+</span><span>
</span><span>coord_flip</span><span>()</span><span>+</span><span>
</span><span>scale_colour_gradient</span><span>(</span><span>low</span><span> </span><span>=</span><span> </span><span>'red'</span><span>,</span><span>high</span><span> </span><span>=</span><span> </span><span>'blue'</span><span>,</span><span>name</span><span>=</span><span>'Difference'</span><span>)</span><span>+</span><span>
</span><span>labs</span><span>(</span><span>title</span><span>=</span><span>'Change in Federal Funds per 1,000 Individuals who have\nselected a market based plan ACA vs Graham-Cassidy, 2020-2026'</span><span>,</span><span>
</span><span>subtitle</span><span>=</span><span>'Arrow pointing to movement from ACA to Graham-Cassidy'</span><span>,</span><span>
</span><span>caption</span><span>=</span><span>'Source: Kaiser Family Foundation'</span><span>,</span><span>
</span><span>y</span><span>=</span><span>'Federal Funds ($ Millions) per 1,000 individuals who have selected a market based plan'</span><span>)</span><span>+</span><span>
</span><span>theme_bw</span><span>()</span><span>+</span><span>
</span><span>theme</span><span>(</span><span>legend.position</span><span> </span><span>=</span><span> </span><span>'bottom'</span><span>)</span><span>
</span></code></pre>
</div>
<h3>Policial Leaning</h3>
<div>
<pre><code><span>p</span><span> </span><span>+</span><span> </span><span>facet_wrap</span><span>(</span><span>~</span><span> </span><span>TrumpWin</span><span> </span><span>,</span><span> </span><span>scales</span><span>=</span><span>'free_y'</span><span>)</span><span>
</span></code></pre>
</div>
<p><img alt="" src="https://i2.wp.com/raw.githubusercontent.com/yonicd/yonicd.github.io/master/img/aca/unnamed-chunk-10-1.png?w=456&ssl=1" data-recalc-dims="1"></p>
<h3>ACA Medicare expansion</h3>
<div>
<pre><code><span>p</span><span> </span><span>+</span><span> </span><span>facet_wrap</span><span>(</span><span>~</span><span> </span><span>Expansion</span><span> </span><span>,</span><span> </span><span>scales</span><span>=</span><span>'free_y'</span><span>)</span><span>
</span></code></pre>
</div>
<p><img alt="" src="https://i2.wp.com/raw.githubusercontent.com/yonicd/yonicd.github.io/master/img/aca/unnamed-chunk-11-1.png?w=456&ssl=1" data-recalc-dims="1"></p>
<h3>ACA Medicare expansion and Political Leaning</h3>
<div>
<pre><code><span>p</span><span> </span><span>+</span><span> </span><span>facet_wrap</span><span>(</span><span>~</span><span> </span><span>Expansion</span><span> </span><span>+</span><span> </span><span>TrumpWin</span><span> </span><span>,</span><span> </span><span>scales</span><span>=</span><span>'free_y'</span><span>)</span><span>
</span></code></pre>
</div>
<p><img alt="" src="https://i1.wp.com/raw.githubusercontent.com/yonicd/yonicd.github.io/master/img/aca/unnamed-chunk-12-1.png?w=456&ssl=1" data-recalc-dims="1"></p>
<h3>State Marketplace Type</h3>
<div>
<pre><code><span>p</span><span> </span><span>+</span><span> </span><span>facet_wrap</span><span>(</span><span>~</span><span> </span><span>Marketplace_Type</span><span>,</span><span> </span><span>scales</span><span>=</span><span>'free_y'</span><span>)</span><span>
</span></code></pre>
</div>
<p><img alt="" src="https://i1.wp.com/raw.githubusercontent.com/yonicd/yonicd.github.io/master/img/aca/unnamed-chunk-13-1.png?w=456&ssl=1" data-recalc-dims="1"></p>
<h3>ACA Medicare expansion and State Marketplace Type</h3>
<div>
<pre><code><span>p</span><span> </span><span>+</span><span> </span><span>facet_wrap</span><span>(</span><span>~</span><span> </span><span>Expansion</span><span> </span><span>+</span><span> </span><span>Marketplace_Type</span><span> </span><span>,</span><span> </span><span>scales</span><span>=</span><span>'free_y'</span><span>)</span><span>
</span></code></pre>
</div>
<p><img alt="" src="https://i2.wp.com/raw.githubusercontent.com/yonicd/yonicd.github.io/master/img/aca/unnamed-chunk-14-1.png?w=456&ssl=1" data-recalc-dims="1"></p>
<h3>Geofaceting</h3>
<p>Lastly, we construct geographic representation of the difference between the ACA and the GC bill using <a rel="nofollow" href="https://twitter.com/hafenstats" target="_blank">Ryan Hafen’s</a> <a rel="nofollow" href="https://cran.r-project.org/package=geofacet" target="_blank">geofacet</a> package.</p>
<div>
<pre><code><span>states_facet</span><span> </span><span>&lt;-</span><span> </span><span>state_ranks</span><span>%>%</span><span>left_join</span><span>(</span><span>kf</span><span>%>%</span><span>rename</span><span>(</span><span>name</span><span>=</span><span>Location</span><span>),</span><span>by</span><span>=</span><span>'name'</span><span>)</span><span>
</span><span>states_facet</span><span>$</span><span>Expansion</span><span> </span><span>&lt;-</span><span> </span><span>factor</span><span>(</span><span>states_facet</span><span>$</span><span>Expansion</span><span>,</span><span>labels</span><span>=</span><span>c</span><span>(</span><span>'Expansion'</span><span>,</span><span>'No Expansion'</span><span>))</span><span>
</span><span>states_facet</span><span>$</span><span>tile_lbl</span><span> </span><span>&lt;-</span><span> </span><span>sprintf</span><span>(</span><span>'%s\n%s'</span><span>,</span><span>states_facet</span><span>$</span><span>Expansion</span><span>,</span><span>states_facet</span><span>$</span><span>TrumpWin</span><span>)</span><span>
</span></code></pre>
</div>
<h4>Total State Population</h4>
<div>
<pre><code><span>states_facet</span><span>%>%</span><span>
</span><span>ggplot</span><span>(</span><span>aes</span><span>(</span><span>x</span><span>=</span><span>'1'</span><span>,</span><span> </span><span>y</span><span>=</span><span>'1'</span><span>,</span><span>fill</span><span>=</span><span>tot_ratio_DIFF</span><span>))</span><span> </span><span>+</span><span>
</span><span>geom_tile</span><span>()</span><span> </span><span>+</span><span>
</span><span>geom_text</span><span>(</span><span>aes</span><span>(</span><span>label</span><span>=</span><span>tile_lbl</span><span>),</span><span>size</span><span>=</span><span>2</span><span>)</span><span>+</span><span>
</span><span>theme_bw</span><span>()</span><span> </span><span>+</span><span>
</span><span>facet_geo</span><span>(</span><span> </span><span>~</span><span> </span><span>state</span><span>)</span><span>+</span><span>
</span><span>scale_fill_gradient2</span><span>(</span><span>low</span><span>=</span><span>'red'</span><span>,</span><span>mid</span><span>=</span><span>'white'</span><span>,</span><span>high</span><span>=</span><span>'green'</span><span>,</span><span>name</span><span>=</span><span>'Difference'</span><span>)</span><span> </span><span>+</span><span>
</span><span>theme</span><span>(</span><span>legend.position</span><span> </span><span>=</span><span> </span><span>'bottom'</span><span>,</span><span>
</span><span>axis.text</span><span> </span><span>=</span><span> </span><span>element_blank</span><span>(),</span><span>
</span><span>axis.title</span><span> </span><span>=</span><span> </span><span>element_blank</span><span>(),</span><span>
</span><span>axis.ticks</span><span> </span><span>=</span><span> </span><span>element_blank</span><span>())</span><span>+</span><span>
</span><span>labs</span><span>(</span><span>title</span><span>=</span><span>'Change in Federal Funds per 1,000 Individuals, 2020-2026'</span><span>,</span><span>
</span><span>caption</span><span>=</span><span>'Source: Kaiser Family Foundation'</span><span>)</span><span>
</span></code></pre>
</div>
<p><img alt="" src="https://i1.wp.com/raw.githubusercontent.com/yonicd/yonicd.github.io/master/img/aca/unnamed-chunk-16-1.png?w=456&ssl=1" data-recalc-dims="1"></p>
<h4>ACA enrollment population</h4>
<div>
<pre><code><span>states_facet</span><span>%>%</span><span>
</span><span>ggplot</span><span>(</span><span>aes</span><span>(</span><span>x</span><span>=</span><span>'1'</span><span>,</span><span> </span><span>y</span><span>=</span><span>'1'</span><span>,</span><span>fill</span><span>=</span><span>ratio_DIFF</span><span>))</span><span> </span><span>+</span><span>
</span><span>geom_tile</span><span>()</span><span> </span><span>+</span><span>
</span><span>geom_text</span><span>(</span><span>aes</span><span>(</span><span>label</span><span>=</span><span>tile_lbl</span><span>),</span><span>size</span><span>=</span><span>2</span><span>)</span><span>+</span><span>
</span><span>theme_bw</span><span>()</span><span> </span><span>+</span><span>
</span><span>facet_geo</span><span>(</span><span> </span><span>~</span><span> </span><span>state</span><span>)</span><span>+</span><span>
</span><span>scale_fill_gradient2</span><span>(</span><span>low</span><span>=</span><span>'red'</span><span>,</span><span>mid</span><span>=</span><span>'white'</span><span>,</span><span>high</span><span>=</span><span>'green'</span><span>,</span><span>name</span><span>=</span><span>'Difference'</span><span>)</span><span> </span><span>+</span><span>
</span><span>theme</span><span>(</span><span>legend.position</span><span> </span><span>=</span><span> </span><span>'bottom'</span><span>,</span><span>
</span><span>axis.text</span><span> </span><span>=</span><span> </span><span>element_blank</span><span>(),</span><span>
</span><span>axis.title</span><span> </span><span>=</span><span> </span><span>element_blank</span><span>(),</span><span>
</span><span>axis.ticks</span><span> </span><span>=</span><span> </span><span>element_blank</span><span>())</span><span>+</span><span>
</span><span>labs</span><span>(</span><span>title</span><span>=</span><span>'Change in Federal Funds per 1,000 Individuals who have\nselected a market based plan ACA vs Graham-Cassidy, 2020-2026'</span><span>,</span><span>
</span><span>caption</span><span>=</span><span>'Source: Kaiser Family Foundation'</span><span>)</span><span>
</span></code></pre>
</div>
<p><img alt="" src="https://i1.wp.com/raw.githubusercontent.com/yonicd/yonicd.github.io/master/img/aca/unnamed-chunk-17-1.png?w=456&ssl=1" data-recalc-dims="1"></p>
	<p>
<div>
<div>To <strong>leave a comment</strong> for the author, please follow the link and comment on their blog: <strong><a href="http://yonicd.github.io/2017-09-26-aca/"> Jonathan Sidi's R Blog</a></strong>.</div>
<hr>
<a rel="nofollow" href="https://www.r-bloggers.com/">R-bloggers.com</a> offers <strong><a rel="nofollow" href="https://feedburner.google.com/fb/a/mailverify?uri=RBloggers">daily e-mail updates</a></strong> about <a rel="nofollow" href="https://www.r-project.org/" title="The R Project for Statistical Computing">R</a> news and <a rel="nofollow" href="https://www.r-bloggers.com/search/tutorial" title="R tutorials">tutorials</a> on topics such as: <a rel="nofollow" href="https://www.r-bloggers.com/search/data%20science" title="Data science">Data science</a>, <a rel="nofollow" href="https://www.r-bloggers.com/search/Big%20Data" title="Big Data">Big Data, <a rel="nofollow" href="https://www.r-users.com/" title="R jobs">R jobs</a>, visualization (<a rel="nofollow" href="https://www.r-bloggers.com/search/ggplot2" title="ggplot and ggplot2 tutorials">ggplot2</a>, <a rel="nofollow" href="https://www.r-bloggers.com/search/boxplot" title="Boxplots using lattice and ggplot2 tutorials">Boxplots</a>, <a rel="nofollow" href="https://www.r-bloggers.com/search/map" title="Maps and gis">maps</a>, <a rel="nofollow" href="https://www.r-bloggers.com/search/animation" title="Animation in R">animation</a>), programming (<a rel="nofollow" href="https://www.r-bloggers.com/search/RStudio" title="RStudio IDE for R">RStudio</a>, <a rel="nofollow" href="https://www.r-bloggers.com/search/sweave" title="Sweave and literate programming">Sweave</a>, <a rel="nofollow" href="https://www.r-bloggers.com/search/LaTeX" title="LaTeX in R">LaTeX</a>, <a rel="nofollow" href="https://www.r-bloggers.com/search/SQL" title="SQL and databases">SQL</a>, <a rel="nofollow" href="https://www.r-bloggers.com/search/eclipse" title="Eclipse IDE for R">Eclipse</a>, <a rel="nofollow" href="https://www.r-bloggers.com/search/git" title="git and github, Version Control System">git</a>, <a rel="nofollow" href="https://www.r-bloggers.com/search/hadoop" title="Large data in R using Hadoop">hadoop</a>, <a rel="nofollow" href="https://www.r-bloggers.com/search/Web+Scraping" title="Web Scraping of google, facebook, yahoo, twitter and more using R">Web Scraping</a>) statistics (<a rel="nofollow" href="https://www.r-bloggers.com/search/regression" title="Regressions and ANOVA analysis tutorials">regression</a>, <a rel="nofollow" href="https://www.r-bloggers.com/search/PCA" title="principal component analysis tutorial">PCA</a>, <a rel="nofollow" href="https://www.r-bloggers.com/search/time+series" title="Time series">time series</a>, <a rel="nofollow" href="https://www.r-bloggers.com/search/trading" title="finance trading">trading</a>) and more...
<img width="1" alt="" src="http://feeds.feedburner.com/~r/RBloggers/~4/l9YGCaxS9zw" height="1"></a></div>