<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/a-recession-before-2020-is-likely-on-the-distribution-of-time-between-recessions/"></div></div><div></div></div><div></div></div>
<div>
(This article was first published on <strong><a href="https://ntguardian.wordpress.com/2018/04/19/a-recession-before-2020-is-likely-on-the-distribution-of-time-between-recessions/"> R – Curtis Miller's Personal Website</a></strong>, and kindly contributed to <a rel="nofollow" href="https://www.r-bloggers.com/">R-bloggers)</a> </div>
<p>I recently saw a <a rel="nofollow" href="https://www.reddit.com/" target="_blank">Reddit</a> thread in <a rel="nofollow" href="https://www.reddit.com/r/PoliticalDiscussion/" target="_blank">r/PoliticalDiscussion</a> asking the question <a rel="nofollow" href="https://redd.it/8d5sx6" target="_blank">“If the economy is still booming 2020, how should the Democratic address this?”</a> This gets to an issue that’s been on my mind since at least 2016, maybe even 2014: when will the current period of economic growth end?</p>
<p><span></span></p>
<p>For some context, the Great Recession, as economists colloquially call the recession beginning in 2007 and punctuated with the 2008 financial crisis, ended officially in June 2009; it was then the economy resumed growth. As of this writing, that was about eight years, ten months ago. The longest previous period between recessions was the time between the early 1990s recession and the recession in the early 2000s that coincided with the collapse of the dot-com bubble; that period was ten years, and the only period longer than the present period between recessions.</p>
<p>There is growing optimism in the economy, most noticeably amongst consumers, and we are finally seeing wages increase in the United States after years of stagnation. Donald Trump and Republicans point to the economy as a reason to vote for Republicans in November (and yet Donald Trump is still historically unpopular and Democrats have a strong chance of capturing the House, and a fair chance at the Senate). Followers of the American economy are starting to ask, “How long can this last?”</p>
<p>In 2016, I was thinking about this issue in relation to the election. I wanted Hillary Clinton to win, but at the same time I feared that a Clinton win would be a short-term gain, long-term loss for Democrats. One reason why is I believe there’s a strong chance of a recession within the next few years.</p>
<p>The 2008 financial crisis was a dramatic event, yet the Dodd-Frank reforms and other policy responses, in my opinion, did not go far enough to address the problems unearthed by the financial crisis. Too-big-to-fail institutions are now a part of law (though the policy jargon is systemically important financial institution, or SIFI). In fact, the scandal surrounding HSBC’s support of money laundering and the Justice Departments weak response suggested bankers may be too-big-to-jail! Many of the financial products and practices that caused the financial crisis are still legal; the fundamentals that produced the crisis have not changed. Barack Obama and the Democrats (and the Republicans, certainly) failed to break the political back of the bankers.</p>
<p>While I did not think Bernie Sanders’ reforms would necessarily make the American economy better, I thought he would put the fear of God back into the financial sector, and that alone could help keep risky behavior in check. Donald Trump, for all his populist rhetoric, has not demonstrated he’s going to put that fear in them. In fact, the Republicans passed a bill that’s a gift to corporations and top earners. The legacy of the 2008 financial crisis is that the financial sector can make grossly risky bets in the good “get government off our back!” times, but will have their losses covered by taxpayers in the “we need government help!” times. Recessions and financial crises are a part of the process of expropriating taxpayers. (I wrote other articles about this topic: see <a rel="nofollow" href="https://ntguardian.wordpress.com/2016/08/29/game-of-bank-bargains/" target="_blank">this article</a> and <a rel="nofollow" href="https://ntguardian.wordpress.com/2016/09/05/money-is-power-the-consequences-of-economic-inequality/" target="_blank">this article</a>, as well as <a rel="nofollow" href="https://ntguardian.files.wordpress.com/2016/08/econ5500finalpaper.pdf" target="_blank">this paper I wrote</a> for an undergraduate class.)</p>
<p>Given all this, there’s good reason to believe that nothing has changed about the American economy that would change the likelihood of a financial crisis. Since it has been so long since the last one, it’s time to start expecting one, and whoever holds the Presidency will be blamed.</p>
<p>Right now that’s Donald Trump and the Republicans. And I don’t need to tell you that given <a rel="nofollow" href="https://projects.fivethirtyeight.com/trump-approval-ratings/?ex_cid=rrpromo" target="_blank">Trump’s popularity in <em>good</em> economic times is historically low</a>, a recession before the 2020 election would lead to a Republican rout, with few survivors.</p>
<p>And in a Census year, too!</p>
<p>So what is the probability of a recession? The rest of this article will focus on finding a statistical model for duration between elections and using that model to estimate the probability of a recession.</p>
<p>A recent article in the magazine <a rel="nofollow" href="https://www.significancemagazine.com/" target="_blank"><em>Significance</em></a> entitled <a rel="nofollow" href="https://rss.onlinelibrary.wiley.com/doi/10.1111/j.1740-9713.2018.01123.x" target="_blank">“The Weibull distribution”</a> describes the <a rel="nofollow" href="https://en.wikipedia.org/wiki/Weibull_distribution" target="_blank">Weibull distribution</a>, a common and expressive probability distribution (and one I recently taught in my statistics class). This distribution is used to model a lot of phenomena, including survival times, the time until a system fails or how long a patient diagnosed with a disease survives. Time until recession sounds like a “survival time”, so perhaps the Weibull distribution can be used to model it.</p>
<p>First, I’m going to be doing some bootstrapping, so here’s the seed for replicability:</p>
<pre>
set.seed(4182018)
</pre>
<p>The dataset below, obtained from <a rel="nofollow" href="https://en.wikipedia.org/wiki/List_of_recessions_in_the_United_States" target="_blank">this Wikipedia article</a>, contains the time between recessions in the United States. I look only at recessions since the Great Depression, considering this to be the “modern” economic era for the United States. The sample size is necessarily small, at 13 observations.</p>
<pre>
recessions &lt;- c( 4+ 2/12,  6+ 8/12,  3+ 1/12,  3+ 9/12,  3+ 3/12,  2+ 0/12,
                 8+10/12,  3+ 0/12,  4+10/12,  1+ 0/12,  7+ 8/12, 10+ 0/12,
                 6+ 1/12)

hist(recessions)
</pre>
<p><img src="https://ntguardian.files.wordpress.com/2018/04/rplot01.png?w=456" data-recalc-dims="1"></p>
<pre>
plot(density(recessions))
</pre>
<p><img src="https://ntguardian.files.wordpress.com/2018/04/rplot.png?w=456" data-recalc-dims="1"></p>
<p>The <a rel="nofollow" href="https://cran.r-project.org/web/packages/fitdistrplus/index.html" target="_blank">fitdistrplus</a> allows for estimating the parameters of statistical distributions using the usual statistical techniques. (I found <a rel="nofollow" href="https://www.jstatsoft.org/article/view/2241" target="_blank">J.Stat.Soft article</a> useful for learning about the package.) I load it below and look at an initial plot to get a sense of appropriate distributions.</p>
<pre>
suppressPackageStartupMessages(library(fitdistrplus))

descdist(recessions, boot = 1000)
</pre>
<p><img src="https://ntguardian.files.wordpress.com/2018/04/rplot02.png?w=456" data-recalc-dims="1"></p>
<pre>
## summary statistics
## ------
## min:  1   max:  10 
## median:  4.166667 
## mean:  4.948718 
## estimated sd:  2.71943 
## estimated skewness:  0.51865 
## estimated kurtosis:  2.349399
</pre>
<p>The recessions dataset is <a rel="nofollow" href="https://www.investopedia.com/terms/p/platykurtic.asp" target="_blank">platykurtic</a> though right-skewed, a surprising result. However, that’s not enough to deter me from attempting to use the Weibull distribution to model time between recessions. (I should mention here that I am assuming essentially that I’m assuming that time between recessions since the Great Depression are independent and identically distributed. This is not obvious or uncontroversial, but I doubt this could be credibly disproven or that assuming dependence would improve the model.) Let’s fit parameters.</p>
<pre>
fw &lt;- fitdist(recessions, &quot;weibull&quot;)
summary(fw)
</pre>
<pre>
## Fitting of the distribution ' weibull ' by maximum likelihood 
## Parameters : 
##       estimate Std. Error
## shape 2.001576  0.4393137
## scale 5.597367  0.8179352
## Loglikelihood:  -30.12135   AIC:  64.2427   BIC:  65.3726 
## Correlation matrix:
##           shape     scale
## shape 1.0000000 0.3172753
## scale 0.3172753 1.0000000
</pre>
<p></p>
<pre>
plot(seq(0, 15, length.out = 1000), dweibull(seq(0, 15, length.out = 1000),
                                              shape = fw$estimate[&quot;shape&quot;],
                                              scale = fw$estimate[&quot;scale&quot;]),
     col = &quot;blue&quot;, type = &quot;l&quot;, xlab = &quot;Duration&quot;, ylab = &quot;Density&quot;,
     main = &quot;Weibull distribution applied to recession duration&quot;)
lines(density(recessions))
</pre>
<p><img src="https://ntguardian.files.wordpress.com/2018/04/rplot03.png?w=456" data-recalc-dims="1"></p>
<pre>
plot(fw)
</pre>
<p><img src="https://ntguardian.files.wordpress.com/2018/04/rplot04.png?w=456" data-recalc-dims="1"></p>
<p>The plots above suggest the fitted Weibull distribution describe the observed distribution; the Q-Q plot, P-P plot, and the estimated density function all fit well with a Weibull distribution. I also compared the AIC values of the fitted Weibull distribution to two other close candidates, the gamma and log-normal distributions; the Weibull distribution provides the best fit according to the AIC criterion, being twice as reasonable as the log-normal distribution, although only slightly better than the gamma distribution (which is not surprising, given that the two distributions are similar). Due to the interpretations that come with the Weibull distribution and the statistical evidence, I believe it provides the better fit and should be used.</p>
<p>Based on the form of the distribution and the estimated parameters we can find a point estimate for the probability of a recession both before the 2018 midterm election and before the 2020 presidential election. That is, if <img alt="T" title="T" src="https://s0.wp.com/latex.php?latex=T&bg=ffffff&%23038;fg=444444&%23038;s=0" class="latex"> is the time between recessions, we can estimate</p>
<p><img alt="P(T leq t + t_0 | T &gt; t_0)" title="P(T leq t + t_0 | T &gt; t_0)" src="https://s0.wp.com/latex.php?latex=P%28T+%5Cleq+t+%2B+t_0+%7C+T+%3E+t_0%29&bg=ffffff&%23038;fg=444444&%23038;s=0" class="latex"></p>
<pre>
alpha &lt;- fw$estimate[&quot;shape&quot;]
beta &lt;- fw$estimate[&quot;scale&quot;]

recession_prob_wei &lt;- function(delta, passed, shape, scale) {
  # Computes the probability of a recession within the next delta years given
  # passed years
  #
  # args:
  #   delta: a number representing time to next recession
  #   passed: a number representing time since last recession
  #   shape: the shape parameter of the Weibull distribution
  #   scale: the scale parameter of the Weibull distribution
  
  if (delta &lt; 0 | passed &lt; 0) {
    stop(&quot;Both delta and passed must be non-negative&quot;)
  }
  
  return(1 - pweibull(passed + delta, shape = shape, scale = scale,
                      lower.tail = FALSE) /
             pweibull(passed, shape = shape, scale = scale, lower.tail = FALSE))
}
</pre>
<p></p>
<pre>
# Recession prob. before 2018 election point estimate
recession_prob_wei(6/12, 8+10/12, shape = alpha, scale = beta)
</pre>
<pre>
## [1] 0.252013
</pre>
<p></p>
<pre>
# Before 2020 election
recession_prob_wei(2+6/12, 8+10/12, shape = alpha, scale = beta)
</pre>
<pre>
## [1] 0.8005031
</pre>
<p>Judging by the point estimates, there’s a 25% chance of a recession before the 2018 midterm election and an 80% chance of a recession before the 2020 election.</p>
<p>The code below finds bootstrapped 95% confidence intervals for these numbers.</p>
<pre>
suppressPackageStartupMessages(library(boot))
recession_prob_wei_bootci &lt;- function(data, delta, passed, conf = .95,
                                      R = 1000) {
  # Computes bootstrapped CI for the probability a recession will occur before
  # a certain time given some time has passed
  #
  # args:
  #   data: A numeric vector containing recession data
  #   delta: A nonnegative real number representing maximum time till recession
  #   passed: A nonnegative real number representing time since last recession
  #   conf: A real number between 0 and 1; the confidence level
  #   R: A positive integer for the number of bootstrap replicates
  bootobj &lt;- boot(recessions, R = R, statistic = function(data, indices) {
    d &lt;- data[indices]
    params &lt;- fitdist(d, &quot;weibull&quot;)$estimate
    return(recession_prob_wei(delta, passed, shape = params[&quot;shape&quot;],
                              scale = params[&quot;scale&quot;]))
  })
  boot.ci(bootobj, type = &quot;perc&quot;, conf = conf)
}

# Bootstrapped 95% CI for probability of recession before 2018 election
recession_prob_wei_bootci(recessions, 6/12, 8+10/12, R = 10000)
</pre>
<pre>
## BOOTSTRAP CONFIDENCE INTERVAL CALCULATIONS
## Based on 10000 bootstrap replicates
## 
## CALL : 
## boot.ci(boot.out = bootobj, conf = conf, type = &quot;perc&quot;)
## 
## Intervals : 
## Level     Percentile     
## 95%   ( 0.1691,  0.6174 )  
## Calculations and Intervals on Original Scale
</pre>
<p></p>
<pre>
# Bootstrapped 95% CI for probability of recession before 2020 election
recession_prob_wei_bootci(recessions, 2+6/12, 8+10/12, R = 10000)
</pre>
<pre>
## BOOTSTRAP CONFIDENCE INTERVAL CALCULATIONS
## Based on 10000 bootstrap replicates
## 
## CALL : 
## boot.ci(boot.out = bootobj, conf = conf, type = &quot;perc&quot;)
## 
## Intervals : 
## Level     Percentile     
## 95%   ( 0.6299,  0.9974 )  
## Calculations and Intervals on Original Scale
</pre>
<p>These CIs suggest that while the probability of a recession before the 2018 midterm is very uncertain (it could plausibly be between 17% and 62%), my hunch about 2020 has validity; even the lower bound of that CI suggests a recession before 2020 is likely, and the upper bound is almost-certainty.</p>
<p>How bad could it be? That’s hard to say. However, these odds make the Republican tax bill and its trillion-dollar deficits look even more irresponsible; that money will be needed to deal with a potential recession’s fallout.</p>
<p>As bad as 2018 looks for Republicans, it could look like a cakewalk compared to 2020.</p>
<p>(And despite the seemingly jubilant tone, this suggests I may have trouble finding a job in the upcoming years.)</p>
<hr>
<p>I have created a video course published by <a rel="nofollow" href="http://packtpub.com/" target="_blank">Packt Publishing</a> entitled <a rel="nofollow" href="https://ntguardian.wordpress.com/video-courses/data-acquisition-and-manipulation-with-python/" target="_blank"><em>Data Acqusition and Manipulation with Python</em></a>, the second volume in a four-volume set of video courses entitled, <em>Taming Data with Python; Excelling as a Data Analyst</em>. This course covers more advanced <a rel="nofollow" href="http://pandas.pydata.org/" target="_blank">Pandas</a> topics such as reading in datasets in different formats and from databases, aggregation, and data wrangling. The course then transitions to cover getting data in “messy” formats from Web documents via web scraping. The course covers web scraping using <a rel="nofollow" href="https://www.crummy.com/software/BeautifulSoup/" target="_blank">BeautifulSoup</a>, <a rel="nofollow" href="http://www.seleniumhq.org/" target="_blank">Selenium</a>, and <a rel="nofollow" href="https://scrapy.org/" target="_blank">Scrapy</a>. If you are starting out using Python for data analysis or know someone who is, please consider <a rel="nofollow" href="https://www.packtpub.com/big-data-and-business-intelligence/data-acquisition-and-manipulation-python-video" target="_blank">buying my course</a> or at least spreading the word about it. You can buy the course directly or purchase a <a rel="nofollow" href="https://www.packtpub.com/mapt/" target="_blank">subscription to Mapt</a> and watch it there.</p>
<p>If you like my blog and would like to support it, spread the word (if not get a copy yourself)! Also, stay tuned for future courses I publish with Packt at the Video Courses section of my site.</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="https://ntguardian.wordpress.com/2018/04/19/a-recession-before-2020-is-likely-on-the-distribution-of-time-between-recessions/"> R – Curtis Miller's Personal Website</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/iFzCKWEA_dE" height="1"></a></div>