What is the appropriate population scaling of the Affordable Care Act Funding?

[This article was first published on Jonathan Sidi's R Blog, and kindly contributed to R-bloggers]. (You can report issue about the content on this page here)
Want to share your content on R-bloggers? click here if you have a blog, or here if you don't.

Analysis of the effects of the Graham-Cassidy Bill on the ACA population –

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.

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.

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.

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?

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.

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.

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.

Saying that, let’s continue:

<span class="n">library</span><span class="p">(</span><span class="n">xml2</span><span class="p">)</span><span class="w">
</span><span class="n">library</span><span class="p">(</span><span class="n">rvest</span><span class="p">)</span><span class="w">
</span><span class="n">library</span><span class="p">(</span><span class="n">dplyr</span><span class="p">)</span><span class="w">
</span><span class="n">library</span><span class="p">(</span><span class="n">ggplot2</span><span class="p">)</span><span class="w">
</span><span class="n">library</span><span class="p">(</span><span class="n">geofacet</span><span class="p">)</span><span class="w">
</span><span class="n">knitr</span><span class="o">::</span><span class="n">opts_chunk</span><span class="o">$</span><span class="n">set</span><span class="p">(</span><span class="n">fig.height</span><span class="o">=</span><span class="m">7</span><span class="p">,</span><span class="n">fig.width</span><span class="o">=</span><span class="m">12</span><span class="p">,</span><span class="n">warning</span><span class="o">=</span><span class="kc">FALSE</span><span class="p">,</span><span class="n">message</span><span class="o">=</span><span class="kc">FALSE</span><span class="p">)</span><span class="w">
</span>

Scraping the relevant information

Kaiser Family Foundation

ACA and Graham-Cassidy federal spending by state.

<span class="n">kf_spending</span><span class="w"> </span><span class="o"><-</span><span class="w"> </span><span class="p">(</span><span class="n">xml2</span><span class="o">::</span><span class="n">read_html</span><span class="p">(</span><span class="s1">'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 class="p">)</span><span class="o">%>%</span><span class="w">
  </span><span class="n">rvest</span><span class="o">::</span><span class="n">html_table</span><span class="p">())[[</span><span class="m">2</span><span class="p">]][</span><span class="o">-</span><span class="nf">c</span><span class="p">(</span><span class="m">1</span><span class="p">,</span><span class="m">2</span><span class="p">,</span><span class="m">3</span><span class="p">,</span><span class="m">55</span><span class="p">),]</span><span class="w">

</span><span class="nf">names</span><span class="p">(</span><span class="n">kf_spending</span><span class="p">)</span><span class="w"> </span><span class="o"><-</span><span class="w"> </span><span class="nf">c</span><span class="p">(</span><span class="s1">'Location'</span><span class="p">,</span><span class="s1">'ACA'</span><span class="p">,</span><span class="s1">'GC'</span><span class="p">,</span><span class="s1">'DIFF'</span><span class="p">,</span><span class="s1">'PCT'</span><span class="p">)</span><span class="w">

</span><span class="n">kf_spending</span><span class="o">$</span><span class="n">Location</span><span class="p">[</span><span class="n">which</span><span class="p">(</span><span class="n">kf_spending</span><span class="o">$</span><span class="n">Location</span><span class="o">==</span><span class="s1">'DC'</span><span class="p">)]</span><span class="o">=</span><span class="s1">'District of Columbia'</span><span class="w">

</span><span class="n">kf_spending</span><span class="w"> </span><span class="o"><-</span><span class="w"> </span><span class="n">kf_spending</span><span class="o">%>%</span><span class="n">mutate_at</span><span class="p">(</span><span class="n">.vars</span><span class="o">=</span><span class="n">vars</span><span class="p">(</span><span class="n">ACA</span><span class="p">,</span><span class="n">GC</span><span class="p">,</span><span class="n">DIFF</span><span class="p">,</span><span class="n">PCT</span><span class="p">),</span><span class="n">.funs</span><span class="o">=</span><span class="n">funs</span><span class="p">(</span><span class="nf">as.numeric</span><span class="p">(</span><span class="n">gsub</span><span class="p">(</span><span class="s1">'[,%]'</span><span class="p">,</span><span class="s1">''</span><span class="p">,</span><span class="n">.</span><span class="p">))))</span><span class="w">
</span>

ACA medicare expansion by state

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.

<span class="c1">#http://www.kff.org/health-reform/state-indicator/state-activity-around-expanding-medicaid-under-the-affordable-care-act/?currentTimeframe=0&sortModel=%7B%22colId%22:%22Location%22,%22sort%22:%22asc%22%7D
</span><span class="n">kf_expansion</span><span class="w"> </span><span class="o"><-</span><span class="w"> </span><span class="n">read.csv</span><span class="p">(</span><span class="s1">'data/kf_expansion.csv'</span><span class="p">,</span><span class="n">stringsAsFactors</span><span class="w"> </span><span class="o">=</span><span class="w"> </span><span class="kc">FALSE</span><span class="p">,</span><span class="n">skip</span><span class="w"> </span><span class="o">=</span><span class="w"> </span><span class="m">2</span><span class="p">)</span><span class="w">
</span><span class="n">kf_expansion</span><span class="w"> </span><span class="o"><-</span><span class="w"> </span><span class="n">kf_expansion</span><span class="p">[</span><span class="o">-</span><span class="nf">c</span><span class="p">(</span><span class="m">1</span><span class="p">,</span><span class="m">53</span><span class="o">:</span><span class="m">61</span><span class="p">),</span><span class="m">-3</span><span class="p">]</span><span class="w">
</span><span class="nf">names</span><span class="p">(</span><span class="n">kf_expansion</span><span class="p">)[</span><span class="m">2</span><span class="p">]</span><span class="w"> </span><span class="o"><-</span><span class="w"> </span><span class="s1">'Expansion'</span><span class="w">
</span>

Population of ACA enrollment by state.

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.

  • Federally-Facilitated Market
  • State-based Marketplace
  • State-based Marketplace (using HealthCare.gov)
<span class="c1">#http://www.kff.org/health-reform/state-indicator/total-marketplace-enrollment/?currentTimeframe=0&sortModel=%7B%22colId%22:%22Total%20Individuals%20Who%20Have%20Selected%20a%20Marketplace%20Plan%22,%22sort%22:%22asc%22%7D
</span><span class="n">kf_marketplace_pop</span><span class="w"> </span><span class="o"><-</span><span class="w"> </span><span class="n">read.csv</span><span class="p">(</span><span class="s1">'data/kf_marketplace_pop.csv'</span><span class="p">,</span><span class="n">stringsAsFactors</span><span class="w"> </span><span class="o">=</span><span class="w"> </span><span class="kc">FALSE</span><span class="p">,</span><span class="n">skip</span><span class="w"> </span><span class="o">=</span><span class="w"> </span><span class="m">2</span><span class="p">)</span><span class="w">
</span><span class="n">kf_marketplace_pop</span><span class="w"> </span><span class="o"><-</span><span class="w"> </span><span class="n">kf_marketplace_pop</span><span class="p">[</span><span class="o">-</span><span class="nf">c</span><span class="p">(</span><span class="m">1</span><span class="p">,</span><span class="m">53</span><span class="o">:</span><span class="m">59</span><span class="p">),]</span><span class="w">
</span><span class="nf">names</span><span class="p">(</span><span class="n">kf_marketplace_pop</span><span class="p">)[</span><span class="nf">c</span><span class="p">(</span><span class="m">2</span><span class="p">,</span><span class="m">3</span><span class="p">)]</span><span class="w"> </span><span class="o"><-</span><span class="w"> </span><span class="nf">c</span><span class="p">(</span><span class="s1">'Marketplace_Type'</span><span class="p">,</span><span class="s1">'N'</span><span class="p">)</span><span class="w">
</span>

Wikipedia

State characteristics (2016 elections and general population)

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.

<span class="n">wiki_elections</span><span class="w"> </span><span class="o"><-</span><span class="w"> </span><span class="p">(</span><span class="n">xml2</span><span class="o">::</span><span class="n">read_html</span><span class="p">(</span><span class="s1">'https://en.wikipedia.org/wiki/United_States_presidential_election,_2016'</span><span class="p">)</span><span class="o">%>%</span><span class="w">
        </span><span class="n">rvest</span><span class="o">::</span><span class="n">xml_nodes</span><span class="p">(</span><span class="n">xpath</span><span class="o">=</span><span class="s1">'//*[@id="mw-content-text"]/div/div[40]/table'</span><span class="p">)</span><span class="o">%>%</span><span class="w">
        </span><span class="n">rvest</span><span class="o">::</span><span class="n">html_table</span><span class="p">())[[</span><span class="m">1</span><span class="p">]][</span><span class="o">-</span><span class="nf">c</span><span class="p">(</span><span class="m">1</span><span class="p">,</span><span class="m">58</span><span class="p">),</span><span class="nf">c</span><span class="p">(</span><span class="m">1</span><span class="p">,</span><span class="m">3</span><span class="p">,</span><span class="m">6</span><span class="p">,</span><span class="m">23</span><span class="p">)]</span><span class="w">

</span><span class="nf">names</span><span class="p">(</span><span class="n">wiki_elections</span><span class="p">)</span><span class="w"> </span><span class="o"><-</span><span class="w"> </span><span class="nf">c</span><span class="p">(</span><span class="s1">'Location'</span><span class="p">,</span><span class="s1">'Clinton'</span><span class="p">,</span><span class="s1">'Trump'</span><span class="p">,</span><span class="s1">'Total'</span><span class="p">)</span><span class="w">

</span><span class="n">wiki_elections</span><span class="o">$</span><span class="n">Location</span><span class="p">[</span><span class="n">grep</span><span class="p">(</span><span class="s1">'^Nebraska'</span><span class="p">,</span><span class="n">wiki_elections</span><span class="o">$</span><span class="n">Location</span><span class="p">)]</span><span class="w"> </span><span class="o"><-</span><span class="w"> </span><span class="s1">'Nebraska'</span><span class="w">
</span><span class="n">wiki_elections</span><span class="o">$</span><span class="n">Location</span><span class="p">[</span><span class="n">grep</span><span class="p">(</span><span class="s1">'^Maine'</span><span class="p">,</span><span class="n">wiki_elections</span><span class="o">$</span><span class="n">Location</span><span class="p">)]</span><span class="w"> </span><span class="o"><-</span><span class="w"> </span><span class="s1">'Maine'</span><span class="w">

</span><span class="n">wiki_elections</span><span class="w"> </span><span class="o"><-</span><span class="w"> </span><span class="n">wiki_elections</span><span class="o">%>%</span><span class="w">
  </span><span class="n">mutate_at</span><span class="p">(</span><span class="n">.vars</span><span class="w"> </span><span class="o">=</span><span class="w"> </span><span class="n">vars</span><span class="p">(</span><span class="n">Clinton</span><span class="p">,</span><span class="n">Trump</span><span class="p">,</span><span class="n">Total</span><span class="p">),</span><span class="n">.funs</span><span class="o">=</span><span class="n">funs</span><span class="p">(</span><span class="nf">as.numeric</span><span class="p">(</span><span class="n">gsub</span><span class="p">(</span><span class="s1">'[,]'</span><span class="p">,</span><span class="s1">''</span><span class="p">,</span><span class="n">.</span><span class="p">))))</span><span class="o">%>%</span><span class="w">
  </span><span class="n">group_by</span><span class="p">(</span><span class="n">Location</span><span class="p">)</span><span class="o">%>%</span><span class="n">summarise_at</span><span class="p">(</span><span class="n">.vars</span><span class="w"> </span><span class="o">=</span><span class="w"> </span><span class="n">vars</span><span class="p">(</span><span class="n">Clinton</span><span class="p">,</span><span class="n">Trump</span><span class="p">,</span><span class="n">Total</span><span class="p">),</span><span class="n">.funs</span><span class="w"> </span><span class="o">=</span><span class="w"> </span><span class="n">funs</span><span class="p">(</span><span class="n">sum</span><span class="p">))</span><span class="o">%>%</span><span class="w">
  </span><span class="n">mutate</span><span class="p">(</span><span class="n">ClintonPct</span><span class="o">=</span><span class="n">Clinton</span><span class="o">/</span><span class="n">Total</span><span class="p">,</span><span class="n">TrumpPct</span><span class="o">=</span><span class="n">Trump</span><span class="o">/</span><span class="n">Total</span><span class="p">,</span><span class="n">TrumpWin</span><span class="o">=</span><span class="n">ifelse</span><span class="p">(</span><span class="n">TrumpPct</span><span class="o">></span><span class="n">ClintonPct</span><span class="p">,</span><span class="s1">'Trump Win'</span><span class="p">,</span><span class="s1">'Clinton Win'</span><span class="p">))</span><span class="w">

</span><span class="n">wiki_pop</span><span class="w"> </span><span class="o"><-</span><span class="w"> </span><span class="p">(</span><span class="n">xml2</span><span class="o">::</span><span class="n">read_html</span><span class="p">(</span><span class="s1">'https://en.wikipedia.org/wiki/List_of_U.S._states_and_territories_by_population'</span><span class="p">)</span><span class="o">%>%</span><span class="w">
        </span><span class="n">rvest</span><span class="o">::</span><span class="n">xml_nodes</span><span class="p">(</span><span class="n">xpath</span><span class="o">=</span><span class="s1">'//*[@id="mw-content-text"]/div/table[1]'</span><span class="p">)</span><span class="o">%>%</span><span class="w">
        </span><span class="n">rvest</span><span class="o">::</span><span class="n">html_table</span><span class="p">())[[</span><span class="m">1</span><span class="p">]][</span><span class="o">-</span><span class="nf">c</span><span class="p">(</span><span class="m">30</span><span class="p">,</span><span class="m">53</span><span class="o">:</span><span class="m">64</span><span class="p">),</span><span class="nf">c</span><span class="p">(</span><span class="m">3</span><span class="p">,</span><span class="m">4</span><span class="p">)]</span><span class="w">

</span><span class="nf">names</span><span class="p">(</span><span class="n">wiki_pop</span><span class="p">)</span><span class="w"> </span><span class="o"><-</span><span class="w"> </span><span class="nf">c</span><span class="p">(</span><span class="s1">'Location'</span><span class="p">,</span><span class="s1">'Total_N'</span><span class="p">)</span><span class="w">

</span><span class="n">wiki_pop</span><span class="o">$</span><span class="n">Total_N</span><span class="w"> </span><span class="o"><-</span><span class="w"> </span><span class="nf">as.numeric</span><span class="p">(</span><span class="n">gsub</span><span class="p">(</span><span class="s1">'[,]'</span><span class="p">,</span><span class="s1">''</span><span class="p">,</span><span class="n">wiki_pop</span><span class="o">$</span><span class="n">Total_N</span><span class="p">))</span><span class="w">
</span>

Join all the data sets

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.

<span class="n">kf</span><span class="w"> </span><span class="o"><-</span><span class="w"> </span><span class="n">kf_marketplace_pop</span><span class="o">%>%</span><span class="w">
  </span><span class="n">left_join</span><span class="p">(</span><span class="n">kf_expansion</span><span class="p">,</span><span class="n">by</span><span class="o">=</span><span class="s1">'Location'</span><span class="p">)</span><span class="o">%>%</span><span class="w">
  </span><span class="n">left_join</span><span class="p">(</span><span class="n">wiki_pop</span><span class="p">,</span><span class="n">by</span><span class="o">=</span><span class="s1">'Location'</span><span class="p">)</span><span class="w">

</span><span class="n">kf</span><span class="w"> </span><span class="o"><-</span><span class="w"> </span><span class="n">kf_spending</span><span class="o">%>%</span><span class="n">left_join</span><span class="p">(</span><span class="n">kf</span><span class="p">,</span><span class="w"> </span><span class="n">by</span><span class="w"> </span><span class="o">=</span><span class="w"> </span><span class="nf">c</span><span class="p">(</span><span class="s1">'Location'</span><span class="p">))</span><span class="o">%>%</span><span class="w">
  </span><span class="n">mutate</span><span class="p">(</span><span class="n">ratio_ACA</span><span class="o">=</span><span class="m">1000</span><span class="o">*</span><span class="n">ACA</span><span class="o">/</span><span class="n">N</span><span class="p">,</span><span class="n">ratio_GC</span><span class="o">=</span><span class="m">1000</span><span class="o">*</span><span class="n">GC</span><span class="o">/</span><span class="n">N</span><span class="p">,</span><span class="n">ratio_DIFF</span><span class="w"> </span><span class="o">=</span><span class="w"> </span><span class="n">ratio_GC</span><span class="o">-</span><span class="n">ratio_ACA</span><span class="p">,</span><span class="w">
         </span><span class="n">tot_ratio_ACA</span><span class="o">=</span><span class="m">1000</span><span class="o">*</span><span class="n">ACA</span><span class="o">/</span><span class="n">Total_N</span><span class="p">,</span><span class="n">tot_ratio_GC</span><span class="o">=</span><span class="m">1000</span><span class="o">*</span><span class="n">GC</span><span class="o">/</span><span class="n">Total_N</span><span class="p">,</span><span class="n">tot_ratio_DIFF</span><span class="w"> </span><span class="o">=</span><span class="w"> </span><span class="n">tot_ratio_GC</span><span class="o">-</span><span class="n">tot_ratio_ACA</span><span class="p">)</span><span class="o">%>%</span><span class="w">
  </span><span class="n">arrange</span><span class="p">(</span><span class="n">desc</span><span class="p">(</span><span class="n">ratio_DIFF</span><span class="p">))</span><span class="w">

</span><span class="n">kf</span><span class="w"> </span><span class="o"><-</span><span class="w"> </span><span class="n">kf</span><span class="o">%>%</span><span class="n">left_join</span><span class="p">(</span><span class="n">wiki_elections</span><span class="p">,</span><span class="n">by</span><span class="o">=</span><span class="s1">'Location'</span><span class="p">)</span><span class="w">

</span><span class="n">kf</span><span class="o">$</span><span class="n">Expansion</span><span class="w"> </span><span class="o"><-</span><span class="w"> </span><span class="n">sprintf</span><span class="p">(</span><span class="s1">'Medicaid Expansion %s'</span><span class="p">,</span><span class="n">kf</span><span class="o">$</span><span class="n">Expansion</span><span class="p">)</span><span class="w">

</span><span class="n">kf</span><span class="o">$</span><span class="n">Location</span><span class="w"> </span><span class="o"><-</span><span class="w"> </span><span class="n">factor</span><span class="p">(</span><span class="n">kf</span><span class="o">$</span><span class="n">Location</span><span class="p">,</span><span class="n">levels</span><span class="w"> </span><span class="o">=</span><span class="w"> </span><span class="n">kf</span><span class="o">$</span><span class="n">Location</span><span class="p">)</span><span class="w">

</span><span class="n">kf</span><span class="o">$</span><span class="n">Marketplace_Type</span><span class="w"> </span><span class="o"><-</span><span class="w"> </span><span class="n">factor</span><span class="p">(</span><span class="n">kf</span><span class="o">$</span><span class="n">Marketplace_Type</span><span class="p">,</span><span class="n">labels</span><span class="o">=</span><span class="nf">c</span><span class="p">(</span><span class="s1">'Federally-Facilitated Market'</span><span class="p">,</span><span class="s1">'State-based Marketplace'</span><span class="p">,</span><span class="s1">'State-based Marketplace (using HealthCare.gov)'</span><span class="p">))</span><span class="w">
</span>

Plots

Percent of state population enrolled in ACA

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)

<span class="n">kf</span><span class="o">%>%</span><span class="w">
  </span><span class="n">mutate</span><span class="p">(</span><span class="n">pop_pct</span><span class="o">=</span><span class="m">100</span><span class="o">*</span><span class="n">N</span><span class="o">/</span><span class="n">Total_N</span><span class="p">)</span><span class="o">%>%</span><span class="w">
  </span><span class="n">arrange</span><span class="p">(</span><span class="n">desc</span><span class="p">(</span><span class="n">pop_pct</span><span class="p">))</span><span class="o">%>%</span><span class="w">
  </span><span class="n">mutate</span><span class="p">(</span><span class="n">Location</span><span class="o">=</span><span class="n">factor</span><span class="p">(</span><span class="n">Location</span><span class="p">,</span><span class="n">levels</span><span class="o">=</span><span class="n">Location</span><span class="p">))</span><span class="o">%>%</span><span class="w">
  </span><span class="n">ggplot</span><span class="p">(</span><span class="n">aes</span><span class="p">(</span><span class="n">x</span><span class="o">=</span><span class="n">Location</span><span class="p">,</span><span class="n">y</span><span class="o">=</span><span class="n">pop_pct</span><span class="p">))</span><span class="o">+</span><span class="w">
  </span><span class="n">geom_point</span><span class="p">()</span><span class="o">+</span><span class="w">
  </span><span class="n">coord_flip</span><span class="p">()</span><span class="o">+</span><span class="w">
  </span><span class="n">labs</span><span class="p">(</span><span class="n">y</span><span class="o">=</span><span class="s1">'Percent of Population that have selected an ACA market based plan'</span><span class="p">)</span><span class="w">
</span>

Overall distribution by Medicare Expansion

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.

<span class="n">boxplot_dat</span><span class="w"> </span><span class="o"><-</span><span class="w"> </span><span class="n">kf</span><span class="o">%>%</span><span class="w">
  </span><span class="n">dplyr</span><span class="o">::</span><span class="n">select</span><span class="p">(</span><span class="n">Expansion</span><span class="p">,</span><span class="n">Marketplace_Type</span><span class="p">,</span><span class="n">TrumpWin</span><span class="p">,</span><span class="w"> </span><span class="n">ratio_DIFF</span><span class="p">,</span><span class="n">tot_ratio_DIFF</span><span class="p">)</span><span class="o">%>%</span><span class="w">
  </span><span class="n">reshape2</span><span class="o">::</span><span class="n">melt</span><span class="p">(</span><span class="n">.</span><span class="p">,</span><span class="n">id</span><span class="o">=</span><span class="nf">c</span><span class="p">(</span><span class="s1">'Marketplace_Type'</span><span class="p">,</span><span class="s1">'Expansion'</span><span class="p">,</span><span class="s1">'TrumpWin'</span><span class="p">))</span><span class="w">

</span><span class="n">levels</span><span class="p">(</span><span class="n">boxplot_dat</span><span class="o">$</span><span class="n">variable</span><span class="p">)</span><span class="w"> </span><span class="o"><-</span><span class="w"> </span><span class="nf">c</span><span class="p">(</span><span class="s1">'per 1,000 Individuals who have\nselected a market based plan'</span><span class="p">,</span><span class="s1">'per 1,000 Individuals'</span><span class="p">)</span><span class="w">

  </span><span class="n">boxplot_dat</span><span class="o">%>%</span><span class="w">
    </span><span class="n">ggplot</span><span class="p">(</span><span class="n">aes</span><span class="p">(</span><span class="n">x</span><span class="o">=</span><span class="n">Expansion</span><span class="p">,</span><span class="w">
             </span><span class="n">y</span><span class="o">=</span><span class="n">value</span><span class="p">,</span><span class="w">
             </span><span class="n">fill</span><span class="o">=</span><span class="n">TrumpWin</span><span class="p">))</span><span class="o">+</span><span class="w">
  </span><span class="n">geom_boxplot</span><span class="p">()</span><span class="o">+</span><span class="w">
  </span><span class="n">geom_hline</span><span class="p">(</span><span class="n">aes</span><span class="p">(</span><span class="n">yintercept</span><span class="o">=</span><span class="m">0</span><span class="p">),</span><span class="n">linetype</span><span class="o">=</span><span class="m">2</span><span class="p">)</span><span class="o">+</span><span class="w">
  </span><span class="n">facet_wrap</span><span class="p">(</span><span class="o">~</span><span class="n">variable</span><span class="p">,</span><span class="n">ncol</span><span class="o">=</span><span class="m">1</span><span class="p">,</span><span class="n">scales</span><span class="o">=</span><span class="s1">'free_y'</span><span class="p">)</span><span class="o">+</span><span class="w">
  </span><span class="n">labs</span><span class="p">(</span><span class="n">title</span><span class="o">=</span><span class="s1">'Change in Federal Funds ACA vs Graham-Cassidy, 2020-2026'</span><span class="p">,</span><span class="w">
         </span><span class="n">y</span><span class="o">=</span><span class="s1">'Change in Federal Funds ($ Millions) per 1,000 individuals'</span><span class="p">)</span><span class="o">+</span><span class="w">
  </span><span class="n">theme_bw</span><span class="p">()</span><span class="o">+</span><span class="w">
  </span><span class="n">theme</span><span class="p">(</span><span class="n">legend.position</span><span class="w"> </span><span class="o">=</span><span class="w"> </span><span class="s1">'bottom'</span><span class="p">)</span><span class="w">
</span>

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.

Some things to look for:

  • New York has the largest negative net funding per 1,000 persons.
  • Kentucky has the largest negative net funding per 1,000 persons among Republican leaning states.
  • The net increase in funding per 1,000 persons for states that did not expand medicaid is mostly minimal.
<span class="n">p</span><span class="w"> </span><span class="o"><-</span><span class="w"> </span><span class="n">kf</span><span class="o">%>%</span><span class="n">ggplot</span><span class="p">(</span><span class="n">aes</span><span class="p">(</span><span class="n">x</span><span class="o">=</span><span class="n">Location</span><span class="p">,</span><span class="n">xend</span><span class="o">=</span><span class="n">Location</span><span class="p">,</span><span class="n">yend</span><span class="o">=</span><span class="n">ratio_GC</span><span class="p">,</span><span class="n">y</span><span class="o">=</span><span class="n">ratio_ACA</span><span class="p">,</span><span class="n">colour</span><span class="o">=</span><span class="n">ratio_DIFF</span><span class="p">))</span><span class="o">+</span><span class="w">
  </span><span class="n">geom_segment</span><span class="p">(</span><span class="n">arrow</span><span class="w"> </span><span class="o">=</span><span class="w"> </span><span class="n">arrow</span><span class="p">(</span><span class="n">length</span><span class="w"> </span><span class="o">=</span><span class="w"> </span><span class="n">unit</span><span class="p">(</span><span class="m">0.02</span><span class="p">,</span><span class="w"> </span><span class="s2">"npc"</span><span class="p">)))</span><span class="o">+</span><span class="w">
  </span><span class="n">coord_flip</span><span class="p">()</span><span class="o">+</span><span class="w">
  </span><span class="n">scale_colour_gradient</span><span class="p">(</span><span class="n">low</span><span class="w"> </span><span class="o">=</span><span class="w"> </span><span class="s1">'red'</span><span class="p">,</span><span class="n">high</span><span class="w"> </span><span class="o">=</span><span class="w"> </span><span class="s1">'blue'</span><span class="p">,</span><span class="n">name</span><span class="o">=</span><span class="s1">'Difference'</span><span class="p">)</span><span class="o">+</span><span class="w">
  </span><span class="n">labs</span><span class="p">(</span><span class="n">title</span><span class="o">=</span><span class="s1">'Change in Federal Funds per 1,000 Individuals who have\nselected a market based plan ACA vs Graham-Cassidy, 2020-2026'</span><span class="p">,</span><span class="w">
       </span><span class="n">subtitle</span><span class="o">=</span><span class="s1">'Arrow pointing to movement from ACA to Graham-Cassidy'</span><span class="p">,</span><span class="w">
       </span><span class="n">caption</span><span class="o">=</span><span class="s1">'Source: Kaiser Family Foundation'</span><span class="p">,</span><span class="w">
       </span><span class="n">y</span><span class="o">=</span><span class="s1">'Federal Funds ($ Millions) per 1,000 individuals who have selected a market based plan'</span><span class="p">)</span><span class="o">+</span><span class="w">
  </span><span class="n">theme_bw</span><span class="p">()</span><span class="o">+</span><span class="w">
  </span><span class="n">theme</span><span class="p">(</span><span class="n">legend.position</span><span class="w"> </span><span class="o">=</span><span class="w"> </span><span class="s1">'bottom'</span><span class="p">)</span><span class="w">
</span>

Policial Leaning

<span class="n">p</span><span class="w"> </span><span class="o">+</span><span class="w"> </span><span class="n">facet_wrap</span><span class="p">(</span><span class="o">~</span><span class="w"> </span><span class="n">TrumpWin</span><span class="w"> </span><span class="p">,</span><span class="w"> </span><span class="n">scales</span><span class="o">=</span><span class="s1">'free_y'</span><span class="p">)</span><span class="w">
</span>

ACA Medicare expansion

<span class="n">p</span><span class="w"> </span><span class="o">+</span><span class="w"> </span><span class="n">facet_wrap</span><span class="p">(</span><span class="o">~</span><span class="w"> </span><span class="n">Expansion</span><span class="w"> </span><span class="p">,</span><span class="w"> </span><span class="n">scales</span><span class="o">=</span><span class="s1">'free_y'</span><span class="p">)</span><span class="w">
</span>

ACA Medicare expansion and Political Leaning

<span class="n">p</span><span class="w"> </span><span class="o">+</span><span class="w"> </span><span class="n">facet_wrap</span><span class="p">(</span><span class="o">~</span><span class="w"> </span><span class="n">Expansion</span><span class="w"> </span><span class="o">+</span><span class="w"> </span><span class="n">TrumpWin</span><span class="w"> </span><span class="p">,</span><span class="w"> </span><span class="n">scales</span><span class="o">=</span><span class="s1">'free_y'</span><span class="p">)</span><span class="w">
</span>

State Marketplace Type

<span class="n">p</span><span class="w"> </span><span class="o">+</span><span class="w"> </span><span class="n">facet_wrap</span><span class="p">(</span><span class="o">~</span><span class="w"> </span><span class="n">Marketplace_Type</span><span class="p">,</span><span class="w"> </span><span class="n">scales</span><span class="o">=</span><span class="s1">'free_y'</span><span class="p">)</span><span class="w">
</span>

ACA Medicare expansion and State Marketplace Type

<span class="n">p</span><span class="w"> </span><span class="o">+</span><span class="w"> </span><span class="n">facet_wrap</span><span class="p">(</span><span class="o">~</span><span class="w"> </span><span class="n">Expansion</span><span class="w"> </span><span class="o">+</span><span class="w"> </span><span class="n">Marketplace_Type</span><span class="w"> </span><span class="p">,</span><span class="w"> </span><span class="n">scales</span><span class="o">=</span><span class="s1">'free_y'</span><span class="p">)</span><span class="w">
</span>

Geofaceting

Lastly, we construct geographic representation of the difference between the ACA and the GC bill using Ryan Hafen’s geofacet package.

<span class="n">states_facet</span><span class="w"> </span><span class="o"><-</span><span class="w"> </span><span class="n">state_ranks</span><span class="o">%>%</span><span class="n">left_join</span><span class="p">(</span><span class="n">kf</span><span class="o">%>%</span><span class="n">rename</span><span class="p">(</span><span class="n">name</span><span class="o">=</span><span class="n">Location</span><span class="p">),</span><span class="n">by</span><span class="o">=</span><span class="s1">'name'</span><span class="p">)</span><span class="w">

</span><span class="n">states_facet</span><span class="o">$</span><span class="n">Expansion</span><span class="w"> </span><span class="o"><-</span><span class="w"> </span><span class="n">factor</span><span class="p">(</span><span class="n">states_facet</span><span class="o">$</span><span class="n">Expansion</span><span class="p">,</span><span class="n">labels</span><span class="o">=</span><span class="nf">c</span><span class="p">(</span><span class="s1">'Expansion'</span><span class="p">,</span><span class="s1">'No Expansion'</span><span class="p">))</span><span class="w">

</span><span class="n">states_facet</span><span class="o">$</span><span class="n">tile_lbl</span><span class="w"> </span><span class="o"><-</span><span class="w"> </span><span class="n">sprintf</span><span class="p">(</span><span class="s1">'%s\n%s'</span><span class="p">,</span><span class="n">states_facet</span><span class="o">$</span><span class="n">Expansion</span><span class="p">,</span><span class="n">states_facet</span><span class="o">$</span><span class="n">TrumpWin</span><span class="p">)</span><span class="w">
</span>

Total State Population

<span class="n">states_facet</span><span class="o">%>%</span><span class="w">
  </span><span class="n">ggplot</span><span class="p">(</span><span class="n">aes</span><span class="p">(</span><span class="n">x</span><span class="o">=</span><span class="s1">'1'</span><span class="p">,</span><span class="w"> </span><span class="n">y</span><span class="o">=</span><span class="s1">'1'</span><span class="p">,</span><span class="n">fill</span><span class="o">=</span><span class="n">tot_ratio_DIFF</span><span class="p">))</span><span class="w"> </span><span class="o">+</span><span class="w">
  </span><span class="n">geom_tile</span><span class="p">()</span><span class="w"> </span><span class="o">+</span><span class="w">
  </span><span class="n">geom_text</span><span class="p">(</span><span class="n">aes</span><span class="p">(</span><span class="n">label</span><span class="o">=</span><span class="n">tile_lbl</span><span class="p">),</span><span class="n">size</span><span class="o">=</span><span class="m">2</span><span class="p">)</span><span class="o">+</span><span class="w">
  </span><span class="n">theme_bw</span><span class="p">()</span><span class="w"> </span><span class="o">+</span><span class="w">
  </span><span class="n">facet_geo</span><span class="p">(</span><span class="w"> </span><span class="o">~</span><span class="w"> </span><span class="n">state</span><span class="p">)</span><span class="o">+</span><span class="w">
  </span><span class="n">scale_fill_gradient2</span><span class="p">(</span><span class="n">low</span><span class="o">=</span><span class="s1">'red'</span><span class="p">,</span><span class="n">mid</span><span class="o">=</span><span class="s1">'white'</span><span class="p">,</span><span class="n">high</span><span class="o">=</span><span class="s1">'green'</span><span class="p">,</span><span class="n">name</span><span class="o">=</span><span class="s1">'Difference'</span><span class="p">)</span><span class="w"> </span><span class="o">+</span><span class="w">
  </span><span class="n">theme</span><span class="p">(</span><span class="n">legend.position</span><span class="w"> </span><span class="o">=</span><span class="w"> </span><span class="s1">'bottom'</span><span class="p">,</span><span class="w">
        </span><span class="n">axis.text</span><span class="w"> </span><span class="o">=</span><span class="w"> </span><span class="n">element_blank</span><span class="p">(),</span><span class="w">
        </span><span class="n">axis.title</span><span class="w"> </span><span class="o">=</span><span class="w"> </span><span class="n">element_blank</span><span class="p">(),</span><span class="w">
        </span><span class="n">axis.ticks</span><span class="w"> </span><span class="o">=</span><span class="w"> </span><span class="n">element_blank</span><span class="p">())</span><span class="o">+</span><span class="w">
  </span><span class="n">labs</span><span class="p">(</span><span class="n">title</span><span class="o">=</span><span class="s1">'Change in Federal Funds per 1,000 Individuals, 2020-2026'</span><span class="p">,</span><span class="w">
       </span><span class="n">caption</span><span class="o">=</span><span class="s1">'Source: Kaiser Family Foundation'</span><span class="p">)</span><span class="w">
</span>

ACA enrollment population

<span class="n">states_facet</span><span class="o">%>%</span><span class="w">
  </span><span class="n">ggplot</span><span class="p">(</span><span class="n">aes</span><span class="p">(</span><span class="n">x</span><span class="o">=</span><span class="s1">'1'</span><span class="p">,</span><span class="w"> </span><span class="n">y</span><span class="o">=</span><span class="s1">'1'</span><span class="p">,</span><span class="n">fill</span><span class="o">=</span><span class="n">ratio_DIFF</span><span class="p">))</span><span class="w"> </span><span class="o">+</span><span class="w">
  </span><span class="n">geom_tile</span><span class="p">()</span><span class="w"> </span><span class="o">+</span><span class="w">
  </span><span class="n">geom_text</span><span class="p">(</span><span class="n">aes</span><span class="p">(</span><span class="n">label</span><span class="o">=</span><span class="n">tile_lbl</span><span class="p">),</span><span class="n">size</span><span class="o">=</span><span class="m">2</span><span class="p">)</span><span class="o">+</span><span class="w">
  </span><span class="n">theme_bw</span><span class="p">()</span><span class="w"> </span><span class="o">+</span><span class="w">
  </span><span class="n">facet_geo</span><span class="p">(</span><span class="w"> </span><span class="o">~</span><span class="w"> </span><span class="n">state</span><span class="p">)</span><span class="o">+</span><span class="w">
  </span><span class="n">scale_fill_gradient2</span><span class="p">(</span><span class="n">low</span><span class="o">=</span><span class="s1">'red'</span><span class="p">,</span><span class="n">mid</span><span class="o">=</span><span class="s1">'white'</span><span class="p">,</span><span class="n">high</span><span class="o">=</span><span class="s1">'green'</span><span class="p">,</span><span class="n">name</span><span class="o">=</span><span class="s1">'Difference'</span><span class="p">)</span><span class="w"> </span><span class="o">+</span><span class="w">
  </span><span class="n">theme</span><span class="p">(</span><span class="n">legend.position</span><span class="w"> </span><span class="o">=</span><span class="w"> </span><span class="s1">'bottom'</span><span class="p">,</span><span class="w">
        </span><span class="n">axis.text</span><span class="w"> </span><span class="o">=</span><span class="w"> </span><span class="n">element_blank</span><span class="p">(),</span><span class="w">
        </span><span class="n">axis.title</span><span class="w"> </span><span class="o">=</span><span class="w"> </span><span class="n">element_blank</span><span class="p">(),</span><span class="w">
        </span><span class="n">axis.ticks</span><span class="w"> </span><span class="o">=</span><span class="w"> </span><span class="n">element_blank</span><span class="p">())</span><span class="o">+</span><span class="w">
  </span><span class="n">labs</span><span class="p">(</span><span class="n">title</span><span class="o">=</span><span class="s1">'Change in Federal Funds per 1,000 Individuals who have\nselected a market based plan ACA vs Graham-Cassidy, 2020-2026'</span><span class="p">,</span><span class="w">
       </span><span class="n">caption</span><span class="o">=</span><span class="s1">'Source: Kaiser Family Foundation'</span><span class="p">)</span><span class="w">
</span>

To leave a comment for the author, please follow the link and comment on their blog: Jonathan Sidi's R Blog.

R-bloggers.com offers daily e-mail updates about R news and tutorials about learning R and many other topics. Click here if you're looking to post or find an R/data-science job.
Want to share your content on R-bloggers? click here if you have a blog, or here if you don't.

Never miss an update!
Subscribe to R-bloggers to receive
e-mails with the latest R posts.
(You will not see this message again.)

Click here to close (This popup will not appear again)