<?xml version="1.0" encoding="UTF-8"?><rss xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:atom="http://www.w3.org/2005/Atom" version="2.0" xmlns:cc="http://cyber.law.harvard.edu/rss/creativeCommonsRssModule.html">
    <channel>
        <title><![CDATA[Stories by Sean Holland on Medium]]></title>
        <description><![CDATA[Stories by Sean Holland on Medium]]></description>
        <link>https://medium.com/@sean.holland20?source=rss-c7c83ac0b074------2</link>
        <image>
            <url>https://cdn-images-1.medium.com/fit/c/150/150/2*wRxeQK93fxxTyMTmK8fowQ.jpeg</url>
            <title>Stories by Sean Holland on Medium</title>
            <link>https://medium.com/@sean.holland20?source=rss-c7c83ac0b074------2</link>
        </image>
        <generator>Medium</generator>
        <lastBuildDate>Thu, 03 Dec 2026 22:14:19 GMT</lastBuildDate>
        <atom:link href="https://medium.com/@sean.holland20/feed" rel="self" type="application/rss+xml"/>
        <webMaster><![CDATA[yourfriends@medium.com]]></webMaster>
        <atom:link href="http://medium.superfeedr.com/" rel="hub"/>
        <item>
            <title><![CDATA[Two First Serves: Analyzing ATP Service Data from 2000–2020]]></title>
            <link>https://medium.com/data-science/two-first-serves-analyzing-atp-service-data-from-2000-2020-b5cfcdb4901a?source=rss-c7c83ac0b074------2</link>
            <guid isPermaLink="false">https://medium.com/p/b5cfcdb4901a</guid>
            <category><![CDATA[sports-analytics]]></category>
            <category><![CDATA[tennis]]></category>
            <category><![CDATA[data-science]]></category>
            <category><![CDATA[plotly]]></category>
            <category><![CDATA[editors-pick]]></category>
            <dc:creator><![CDATA[Sean Holland]]></dc:creator>
            <pubDate>Fri, 03 Feb 2023 23:15:34 GMT</pubDate>
            <atom:updated>2023-02-08T04:17:31.093Z</atom:updated>
            <content:encoded><![CDATA[<h4>Which players on the tour should get rid of their second serve and why (and a Dash app to visualize it)</h4><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*rP7URXaDkQxaKm5fOmh9_Q.jpeg" /><figcaption>Stock Image Provided by <a href="https://pixabay.com/photos/tennis-play-tennis-court-ball-5782695/">Pixabay</a></figcaption></figure><p>Data, analytics, and machine learning have become ubiquitous around sports over the past decade or so. And, in tandem, non-traditional strategies have grown in popularity around the sports world. In football, fourth-down attempts and two-point conversion attempts have risen, as analytics has proven the increased value of employing these strategies. In 2021, <a href="https://www.sportingnews.com/us/nfl/news/nfl-fourth-down-conversion-chart-rate-by-distance/vofkeub6xwms6imajxqkfipp">fourth-down attempts reached a high of 793</a>, up more than 70% from 2011. In basketball, the long two-point attempt has <a href="https://fivethirtyeight.com/features/what-if-kevin-garnett-and-tracy-mcgrady-had-shot-threes-instead-of-long-twos/">basically vanished</a>, as analytics gurus have demonstrated the greater expected value of the corner three-pointer and lay-ups.</p><p>Just as basketball and football have proven fertile ground for data to effect change in tactics and strategy, so too does my pastime of tennis. For most tennis professionals, the value of sports analytics is in <a href="https://www.tennis.com/news/articles/the-role-of-analytics-in-tennis-is-on-a-long-slow-rise">opposition scouting.</a> Using opponent stats can tell a player what an optimal strategy might look like in terms of whether to attack an opponent&#39;s backhand, force them to play long rallies from the baseline, or try to bring them toward the net. However, there are still fruitful opportunities for pros to exploit the vast array of data that the sport produces, from legacy statistics like serving percentages to more advanced stats like player positioning from vision AI applications.</p><p>One of these opportunities to analyze tennis data became clear to me last year after I joined a local tennis league after a four-year hiatus. During my first few matches, I realized that, while my first serves were sailing out of bound too often, my opponents were able to attack my weak second serve. After one too many break points, I thought to myself <em>am I better off ditching my second serve and using my first serve twice?</em></p><p>The premise is fairly simple. In tennis, the player serving the ball has an advantage because they are able to start the point — giving them strategic choices like where to place the ball and what type of spin to hit with. The serve is also one of the fastest shots in tennis, with the ATP circuit players frequently reaching speeds of approximately <a href="https://tenniscreative.com/fastest-tennis-serve/">120 MPH (193 KM/H)</a>. Not only that, but the server gets <em>two</em> chances at their serve in case they miss the first.</p><p>Most players, amateur and professional, employ two different serves. See, serving strategy in tennis is predicated on a fairly simple principle. Players typically use their first serve to play a ball faster and into tighter, more advantageous windows, such as out wide or down the center of the “T,” where the service boxes meet. The point is to gain an advantage by forcing a weak return, pushing the opponent into an undesirable court position, or winning the point uncontested through an ace. The second serve, then, is typically played more safely. Players tend to use play a slower ball into windows with a higher margin for error. The player will still attempt to gain an advantage by controlling the opponent’s court position, but the advantage tends to be smaller than on a successful first serve.</p><p>Now, let’s move to the question of whether players would benefit from using their first serve twice. It’s not a particularly difficult question to answer, and it only requires four variables:</p><ol><li><strong>First Serve Percentage: </strong>The percentage of one’s first serves that are in and thus begin the point;</li><li><strong>First Serve Win Percentage: </strong>The percentage of points the player wins after successfully getting the first serve in;</li><li><strong>Second Serve Percentage: </strong>The percentage of one’s second serves that are in and thus begin the point;</li><li><strong>Second Serve Win Percentage: </strong>The percentage of points the player wins after successfully getting the second serve in. Double faults count against the player’s second-serve win percentage.</li></ol><p>That leads us to the key question: is the expected value, <em>E(p), </em>of using two first serves greater or less than the expected value of a traditional first-and-second-serve strategy?</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/880/1*PNMsDobR4Z3gvUwQGKcF9Q.png" /><figcaption>Figure 1: Expected Value formulas for tennis serves (screenshot created by author)</figcaption></figure><p>To answer the question of serving strategy, I analyzed the excellent data provided by Jeff Sackmann, founder of <a href="http://www.tennisabstract.com/cgi-bin/player.cgi?p=JeffSackmann">TennisAbstract.com</a> (thanks to Jeff for giving his permission to use his data for this article). I pulled the data from <a href="https://github.com/JeffSackmann/tennis_atp">Jeff’s GitHub</a> and merged the datasets spanning from 2000 to 2020. The analyses used in the rest of this article were generated using Python.</p><p>The datasets detail all ATP singles matches over the timeframe, including the tournament and surface. However, my primary focus is the serve data (i.e., total first serves in, aces, double faults, etc.). Additionally, since the ATP is the men’s tour, this data is subsetted for male players only. I intend to add WTA data to this analysis and the Dash app.</p><p><strong>The Analysis</strong></p><p>So as not to bury the lede, here it is: fully 1-in-5 players on the ATP circuit who played between 2000–2020 would be better off adopting the two-first-serve strategy. I’m no Uncle Toni, but the fact that 20% of players on the circuit would benefit from adopting a more aggressive serving strategy seems like a fairly large market inefficiency to me.</p><p>The first step I took when preparing the data — outside of creating our key variables such as first-serve percentage — was to roll the observations to the player level. At the match level, there is too much variance to extrapolate a comprehensive serving strategy. Figure 2 below is a histogram of the expected value of a two-first-serve strategy for Rafael Nadal on a match-by-match basis. Notice how, even for one of the greatest tennis players of all time, Nadal’s expected value varies fairly significantly.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1022/1*r5JAnvBxmWug_dzmU3OTWA.png" /><figcaption>25th Percentile: 60% | Mean: 65% | 75th Percentile: .71% (plot generated by author using Plotly)</figcaption></figure><p>To further demonstrate this variance, I compared match-level and player-level data. I found that in any given match, around 35% of players would have fared better by using two first serves. However, when looking at each player’s career data, only 24% of players are better off using two first serves. When I subset for players who played at least 50 matches over their career, that number drops further to 20%.</p><p><strong>The Dash App</strong></p><p>To gain a deeper understanding of the factors, determinants, and covariants of a player’s serve percentages, I built and deployed a Dash app using Heroku. For the uninitiated, Dash is a powerful tool that allows users to create custom dashboards and Heroku is a cloud platform-as-a-service that allows individual users to deploy simple applications.</p><p><a href="https://atp-serve-dash.herokuapp.com/">The dashboard </a>I created for this analysis is, fittingly, quite simple. Users select an x-, y-, and color-variable. The default x- and y-variables are the Expected Value of a First-Second Serve Strategy and the Expected Value of a Two-First Serve Strategy, respectively. This chart is captured below.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*faMm9IdaGUCxhYv7qVG1Ow.png" /><figcaption>Figure 2: Comparison of Serving Strategies (Screenshot created by author)</figcaption></figure><p>Points coded in red are players for whom a two-first-serve strategy would have a higher expected value than their current first-second-serve strategy. The chart above is informative to be sure, but it really only tells us who might benefit from employing such a strategy. What if I want to know <em>what about</em> a player makes them more likely to benefit from a two-first-serve strategy?</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*9ITo0w1RuoYhAITb83shIA.png" /><figcaption>Figure 3: Relationship Between Height and Optimal Serving Strategy (Screenshot created by author)</figcaption></figure><p>For years, analysts have recognized height as a key factor in serving success. Even casual fans may remember John Isner, whose 11-hour and 5-minute showdown with Nicolas Mahut shattered match-length records. Isner, who measures 6 foot 10, dominated his service games, not losing a single break point during the final set of the match. And, the numbers corroborate the common wisdom of tennis analysts and the lived experience of Isner himself. Looking at the relationship between height and the two-first-serve strategy, the players who would benefit the most appear to be the giants of the sport. Ivo Karlovic, another towering ATP pro (coincidentally also known for his long-lasting matches), reaches the top of the list, peaking in 2009 at an expected value of over 0.75 points using a two-first-serve strategy.</p><p>For the giants of the sport, the benefit of a two-first-serve strategy derives from their ability to win points when their first serves go in. Karlovic in 2009 netted a first-serve win percentage of almost 85%, significantly above the sample average of approximately 71%. Similarly, Isner notched a first-serve win percentage of 82%. Such a high rate of success, paired with even a modest first-serve percentage — the rate at which a player is able to put the ball into play with their first serve — is often enough to vault the server to a higher expected scoring value under a two-first-serve strategy.</p><p><strong>Conclusion</strong></p><p>So, what does this mean for pros on the ATP circuit? Well, for the majority, not much. 4-in-5 players are better off maintaining their traditional first-second-serve strategy. However, for the remaining 1-in-5 players, especially players whose height exceeds 6 feet 4 inches (193cm), I would encourage trying out a two-first-serve strategy (although, I might not wait for a tournament final to give it a go). Players who can demonstrate exceptional ability to win their points on a first-serve might benefit from pressuring their opponents with a two-first-serve strategy, even at the risk of double faulting more often.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=b5cfcdb4901a" width="1" height="1" alt=""><hr><p><a href="https://medium.com/data-science/two-first-serves-analyzing-atp-service-data-from-2000-2020-b5cfcdb4901a">Two First Serves: Analyzing ATP Service Data from 2000–2020</a> was originally published in <a href="https://medium.com/data-science">TDS Archive</a> on Medium, where people are continuing the conversation by highlighting and responding to this story.</p>]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Supply, Demand, and the Instrumental Variable: Lessons for Data Scientists from the Economist’s…]]></title>
            <link>https://medium.com/data-science/supply-demand-and-the-instrumental-variable-lessons-for-data-scientists-from-the-economists-21af225187cd?source=rss-c7c83ac0b074------2</link>
            <guid isPermaLink="false">https://medium.com/p/21af225187cd</guid>
            <category><![CDATA[statistics]]></category>
            <category><![CDATA[business]]></category>
            <category><![CDATA[economics]]></category>
            <category><![CDATA[towards-data-science]]></category>
            <category><![CDATA[data-science]]></category>
            <dc:creator><![CDATA[Sean Holland]]></dc:creator>
            <pubDate>Tue, 23 Jun 2020 06:57:51 GMT</pubDate>
            <atom:updated>2020-06-23T19:12:41.799Z</atom:updated>
            <content:encoded><![CDATA[<h3>Supply, Demand, and the Instrumental Variable: Lessons for Data Scientists from the Economist’s Toolbox</h3><h4>Pretend with me for just a moment.</h4><p>Pretend — your well-meaning but data-averse former college roommate comes to you for advice. See, he’s got the next big gadget to disrupt the wearables industry: the smart-anklet (the clear successor to the smartwatch). The smart anklet’s going to have it all — fitness monitor, a foot massager, and a sleep tracker that will tell your Keurig when it’s time to queue up your morning cup of coffee.</p><p>Only one issue remains. Your friend needs some market analysis to convince seed investors that he can bring the smart-anklet to Millennials everywhere at a price that they are willing to pay. Here’s where you come in. You start scouring the web for data on the wearables industry (Kaggle won’t cut it this time). Finally, you come across some market research data and start plugging away, using what residual information lingers in your brain from your Principles of Econ class to start estimating demand curves. The work seems simple enough — some basic linear regressions, no need for Keras or LightGBM, or XGBoost.</p><p>So, you start your exploratory data analysis. You expect your scatterplots to show a clear negative relationship between price and quantity and coinciding negative price coefficients in your regression models.</p><p>You know, something like this.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/566/1*5lQ1bIwcQ7O5KvBA98bBJg.png" /><figcaption>Look Familiar? (Created by Author)</figcaption></figure><p>Instead, you end up with something a little bit more like this:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/586/1*NDCZXbIycYRzi8UXJIdD3A.png" /><figcaption>Not exactly what you had in mind. (Created by Author)</figcaption></figure><p>“Well that just flies in the face of like 200 years of price theory,” you think to yourself. You then turn to the two reliable friends you always turn to when things don’t work out the way you want them to — Google and StackExchange. And, as usual, you find that dozens of people have had the exact same issue.</p><p>The problem, it turns out, is pretty simple. Prices are set by the intersection of demand and supply curves. This relationship gives us our first insight. To estimate the demand curve, we need variation or shifts in the supply curve. By observing shifts in the supply curve as they intersect with the demand curve, we can trace out the demand curve. Something like this:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/566/1*G1xf6NHeubh2nk3b_JJTWA.png" /><figcaption>Created by Author</figcaption></figure><p>That’s great, problem solved. Or, it would be if it were a simple feat to shift the supply curve while keeping demand constant. See, although we need the supply curve to shift, we have no way to keep our demand curve constant with ordinary least squares (OLS). Our inability to keep demand constant gives us biased and inconsistent coefficient estimates of the effect of price on quantity demanded. That is, in this scenario, OLS gives us estimates that might closely reflect the <em>true</em> nature of the price-quantity relationship, even in large samples. Rather, we might observe no relationship at all, like in the example below.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/614/1*YUHj7ABNg64qMW8l8n2Zvg.png" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/610/1*rkQDGIgYvVFpAoW1m0wKGw.png" /><figcaption>Left: What is really happening. | Right: What we can see. (Created by Author)</figcaption></figure><p>Thankfully, our friends at StackExchange have a solution for you that hails from the minds of Phillip and Sewall Wright: instrumental variables regression. See, at the tail end of the Roaring 20s — while flapper girls were piling into their Ford Model As and heading down to the jazz club — Phillip Wright and his son Sewall were pining over the equally exciting problem of estimating the demand for vegetable and animal oils. Of course, their scatterplots demonstrated the same weak relationship between price and quantity that your scatterplots show. So, they pioneered what is now called instrumental variables regression. The problem they faced in 1928 is no different than the problem you face today, except you get to analyze smart-anklet data and they were stuck with butter and olive oil.</p><h3>What is an Instrumental Variable?</h3><p>Let’s talk endogeneity. A variable can be described as endogenous when its value is correlated with the error term, <em>u. </em>A variable might be endogenous for a variety of reasons related to statistical bias. Perhaps the most common source of endogeneity that researchers encounter comes from omitted variable bias. Omitted variable bias occurs when trying to determine the effect of some variable, <em>X, </em>on our dependent variable, <em>Y, </em>without including another explanatory variable, <em>W</em>, that is correlated with both X and Y.</p><p>For example, smoking and drinking are habits that are both likely to be negatively correlated with life expectancy. However, smoking and drinking are likely to be correlated themselves as well. Therefore, if we create a model to estimate the effect of smoking on life expectancy without including drinking habits, we might overstate the effect of smoking on life expectancy. Neglecting to include alcohol consumption in our model gives us a <em>biased</em> regression coefficient for smoking.</p><p>Omitted variable bias has a relatively simple solution — include the omitted variable in the model. However, there are occasions in which overcoming statistical bias becomes much more difficult. Consider the case of omitted variable bias where we simply do not have data for the omitted variable. Another common issue is the case of simultaneous causality bias — the scenario in which <em>X</em> affects <em>Y</em> but <em>Y </em>also increases <em>X. </em>Economists encounter this issue when trying to determine the effect of police funding on crime. More police should theoretically decrease crime rates, but higher crime rates are likely to invite more police funding to combat those crime rates. In both of these cases, running simple linear regression will give us biased regression coefficients. We have no reason to believe that the coefficients we observe in these models reflect the real nature of the effect that <em>X </em>has on <em>Y.</em></p><p><strong>That is where instrumental variables come in.</strong></p><p>An instrumental variable is a variable (that we will call <em>Z</em>) that allows us to circumvent the problem of endogeneity. When we implement instrumental variable regression, we essentially look at the endogenous variable and break it down into two constituent parts. The first part is the problematic, endogenous part. This is the part of the variable that produces statistical bias. In the omitted variable bias example, this is the part that is correlated with alcohol consumption. In the simultaneous causality example, this is the part that comes from high crime rates causing increased police funding.</p><p>However, the second part is the unproblematic, exogenous part of the variable that we are interested in measuring. If we can capture the effect of this part of the variable, we can obtain unbiased regression coefficients that allow us to estimate the <em>true nature </em>of the effect that X has on Y.</p><p>Instrumental variables, or instruments for short, allow us to isolate the unproblematic part of the endogenous variable. If the instrumental variable, <em>Z, </em>meets two specific criteria, then instrumental variables regression will give us an estimate of our regression coefficient that is closer to its <em>true</em> value than estimates from simple ordinary least squares.</p><p>The two criteria are as follows:</p><ol><li><strong>Instrument relevance: </strong>The instrumental variable, <em>Z, </em>must be correlated with our endogenous variable, <em>X</em>. Expressed mathematically, corr (<em>Z</em>, <em>X</em>) ≠ 0. Intuitively, if <em>Z </em>is uncorrelated with <em>X</em>, we will be unable to capture any variation in <em>X </em>based on our instrumental variable.</li><li><strong>Instrument exogeneity </strong>or <strong>instrument validity: </strong>The instrumental variable, <em>Z</em>, must be exogenous — uncorrelated with the error term. Expressed mathematically, corr (<em>Z</em>, u) = 0. If <em>Z </em>is correlated with the error term, then we will have violated the Gauss-Markov Theorem and be unable to ascertain the unbiased and consistent regression coefficients between X and Y.</li></ol><p>An appropriate instrument meets this description: variable Z is correlated with variable Y <strong>only through its correlation with X.</strong></p><p>To further understand what makes for a good instrument, let’s look at another example from economic research. Labor economists are often interested in the returns to schooling, the effect that an additional year of school will have on an individual’s wages. However, there are several confounding and unobservable factors that can impact an individual’s decision to attend school for an additional year. One unobservable factor is innate ability. Individuals with higher levels of innate ability are more likely to attend school for an additional year. Because attending an additional year of school is correlated with ability and we are unable to appropriately include ability in our OLS model, years of schooling will be an endogenous variable.</p><p>Therefore, papers like Card (1995) take advantage of geographical data to estimate the true nature of the schooling-earnings relationship. Geographical proximity to a college makes attending an additional year of school more likely. This satisfies the <strong>instrument relevance condition. </strong>Meanwhile, the individual’s parents typically decide where to live. As long as geographical proximity is uncorrelated with ability, which can be accomplished by controlling for observable factors like parental education and income, then the proximity variable should be exogenous. This satisfies the <strong>instrument validity condition. </strong>In the context of returns to schooling, geographical proximity is correlated with lifetime earnings <em>only through</em> the positive effect that it has on the likelihood of attaining additional education. That is the makings of a relevant and valid instrument.</p><h3>How does IV Regression Work?</h3><p>While OLS regression involves simply regressing Y on X, IV regression involves a two-step process (which is why another name for IV regression is two steps least squares). In the first step, we regress X on Z. This gives us a set of predicted values, X̂. In the second step, we regress Y on the predicted values, X̂. Below is a demonstration of the IV regression process.</p><p><strong>Step 1)</strong></p><blockquote><em>X̂ = Π0+Π1(Z)+v</em></blockquote><p>Where <em>v </em>is the error term.</p><p><strong>Step 2)</strong></p><blockquote><em>Y = ß0+ß1(X̂)+</em>ε</blockquote><p>Where ε is the error term.</p><p>Because our instrumental variable must be exogenous, the values of X̂ that are predicted by the regression of <em>X </em>on<em> Z </em>will be exogeneous too. Therefore, this first step removes the problematic, endogenous part of our explanatory variable, <em>X. </em>This<em> </em>allows us to regress <em>Y </em>on <em>X̂</em> without having to worry about endogeneity.</p><p>Let’s return for a moment to Philip and Sewall Wright. The father-son duo realized that to estimate the demand curve for butter, they needed to isolate shifts in supply while keeping demand constant. By keeping demand constant while supply shifts, the Wright duo knew they would be able to estimate all the points at which the various supply curves intersected with the demand curve. To do this, the Wright duo used rainfall as their instrument. Low levels of rainfall, the father and son reasoned, should decrease grazing and thus reduce butter production. This would impact supply but rainfall should not have any meaningful impact on butter demand. As an instrument, rainfall meets the relevance condition — rainfall is positively correlated with butter prices. And rainfall meets the exogeneity condition — rainfall only affects butter prices through supply.</p><p>Philip and Sewall Wright have provided legions of economists and smart-anklet analysts with valuable insight. By implementing IV regressions, using variables that shift supply but not demand as instruments, we can obtain consistent estimates of demand curves. We are now prepared to trudge forward with an example from real data.</p><h3>Data</h3><p>Okay, full disclosure — I do not have any data on smart-anklets or smart-watches or smart-anythings to analyze for this article. What I do have, however, is a very exciting dataset of broiler chicken prices between 1960 and 1999. Fun, I know. However, the principles of IV regression for estimating demand are applicable regardless of product.</p><p>The data, which can be accessed <a href="https://ocw.mit.edu/courses/economics/14-271-industrial-organization-i-fall-2005/assignments/broiler.csv">here</a>, come from Epple and McCallum (2006). The dataset consists of annual panel data of chicken and beef prices, chicken feed prices, population, per capita income, and inflation.</p><p>Below is a scatterplot of log quantity and log chicken prices (with price on the y-axis as is the custom for economics).</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/880/1*D_SQO4_ZNd43rydI7LHRhg.png" /></figure><p>As we can see, this relationship appears to be in the exact opposite direction of a demand curve, as quantity is increasing in price. Therefore, this problem necessitates an instrumental variables approach.</p><h3>Discerning the Demand Curve</h3><p>As I previously discussed, determining the demand curve requires holding demand constant while detecting shifts in the supply curve. As the previous 1700 or so words should have made clear, the key for doing this is instrumental variables regression. Specifically, we need to identify an exogenous variable that affects price <em>only through</em> its effect on supply.</p><p>For the Wright duo and their butter-based analysis, the instrumental variable of choice was rainfall. Low rates of rainfall decreased the amount of land that cows could graze on, thus decreasing butter yields. However, there is no reason to believe that rainfall had any meaningful effect on the demand for butter. For our chicken or smart-anklet data, we need to identify variables that have a similar effect — inducing variation in supply while not having any impact on chicken/smart-anklet demand.</p><p>The first place to look for the variables in question is the inputs. In our chicken data, we have information on corn and chicken feed. The price of these inputs is correlated with the price of the output product via their effect on the cost of producing the output. When chicken feed prices decrease, chicken prices decrease as it becomes cheaper to produce chicken. Cheaper inputs mean that final products can be produced more cheaply. Profit-maximizing firms then have an incentive to produce more, increasing quantity while decreasing prices. The variation of input prices causes the supply curve to shift, allowing us to trace out the demand curve.</p><p>These principles transfer to the smart-anklet just as easily — simply replace “chicken feed” prices with the prices of similar input materials such as steel, silicon, aluminum, and crude oil.</p><p>The first step in deploying our instrumental variables approach is regressing price on our instruments. Most statistical software packages have functions that compute IV regressions without having to manually compute the first step OLS regression. However, computing first step regression allows us to diagnose whether the instrument that we are using is a valid instrument for our problem.</p><p>One important consideration is whether or not our instrument is relevant. Recall that instruments are relevant when corr(X, Z) ≠ 0. If an instrument fails to explain much of the variation in the endogenous X variable, then it is considered a “weak instrument.” Without delving too deep (more information can be found <a href="http://econ.lse.ac.uk/staff/spischke/ec533/Weak%20IV.pdf">here</a>), the results of IV regression with weak instruments can create parameter estimates that are biased in the direction of OLS. Not ideal. However, a simple rule of thumb is that an instrument can be considered <em>not </em>weak so long as the F-statistic of the first-stage regression exceeds 10. For that reason, we will manually compute the first-stage of the regression.</p><p>The first step of our IV regression approach is to regress log chicken prices on the instruments: log-chicken feed prices and log-corn prices, such that our equation looks like:</p><blockquote>ln(Chicken Price) = ß0+ß1*ln(Chicken Feed)+ß2*ln(Corn Price).</blockquote><p>Below are the first stage regression outputs produced using the jtools package. The F-statistic of 287.95 greatly exceeds the rule of thumb to determine whether our instruments are relevant. And, the adjusted-R² value of 0.94 tells us that these instruments fit chicken prices quite well.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/570/1*kwSOuykOhxYVUUTbX4bT0w.png" /></figure><p>Thus, we can move on to stage two with confidence.</p><p>In stage two of IV regression, we use regress our dependent variable on predicted values of our endogenous independent variable and any additional exogenous independent variables. In this case, the dependent variable is log quantity, the predicted variable is log chicken prices. To ensure that our regression coefficients are not biased due to omitted variables, we are going to include additional predictors such as income, inflation, population, and the price of beef. Beef prices are included as they represent a substitute good for chicken. Our model is specified as:</p><blockquote>ln(Q) = ß0+ß1*ln(Pred. Chick Price)+ß2*ln(Y)+ß3(CPI)+ß4(Beef Price)+ß4(Population)</blockquote><p>Where Q represents quantity, Y represents income, and CPI represents the consumer price index.</p><p>So let’s estimate our models. Below are the model estimates for a set of OLS regressions in which I <em>do not </em>implement instrumental variables.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/782/1*sJfs8oujXt7c7A2-WUHVWA.png" /></figure><p>As we can see in the “Price Only” model, the effect of price on quantity is positive — contradicting our expectations of the demand curve relationship. However, when we add control variables in the subsequent two models, the sign of the price coefficient changes to be in line with our expectations.</p><p>After consulting with Philip and Sewall Wright, however, we are too wise to fall for these biased regression coefficients. Rather, we need to implement our instrumental variables methods. When we do so, with log corn and chicken feed prices as our instruments, we will obtain unbiased regression coefficients. Below are the instrumental variables model estimates with the same control variables as above.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/828/1*6FZ8yQ1O1J_r5Dafem9IZw.png" /></figure><p>Interestingly, in the first model without additional controls, the price variable has the wrong sign, just like in the traditional OLS model above. This indicates that there is significant omitted variable bias in the price-quantity relationship. The key difference between the OLS models and the IV models, however, lies in the “Full Model” specifications.</p><p>The OLS model indicates that a 1 percent increase in price is associated with a 0.42 percent decrease in the quantity of chicken demanded. However, the IV model indicates that a 1 percent increase in price is associated with a 0.54 percent decrease in the quantity of chicken demanded. The results of the IV model suggest that the OLS estimates of the price-quantity relationship are biased towards zero and therefore <em>understate</em> the effect of price on quantity.</p><h3>Application to the Smart-Anklet Industry</h3><p>The difference between the biased OLS results and the unbiased IV results in our example is quite significant, especially to the data scientists in the fast-paced chicken production industry. For your friend in the smart-anklet industry, such a difference would be quite important as well.</p><p>For applications in business, it is important to have an accurate assessment of the underlying market. Your friend looking to bring the smart-anklet to the wearables industry needs to have a thorough understanding of how consumers value price in deciding which wearable product to purchase. If you had provided your friend with the OLS results instead of the IV results from our example above, he would underestimate how sensitive consumers are to prices. As a result, he might bring his product to market at a price that is too high for what consumers are willing to pay.</p><p>So, let’s recap the key steps to estimating accurate demand curves.</p><p><strong>Step 1) Identify Your Instruments</strong></p><p>Recall that prices are set at the intersection of supply and demand curves. As Philip and Sewall Wright realized, we can trace out a demand curve by holding demand constant, exploiting shifts in the supply curves, and determining the intersection points. Statistically, we can achieve this by using supply-shifters as instruments in the IV regression process. Key variables to include as instruments are variables that impact the cost of production, such as the cost of input materials. In the technology sector, such inputs might include silicon, cobalt, and aluminum. In meat-products, these inputs might be the price of corn, wheat, or other goods that farmers buy for their livestock. In any case, we need to think critically about what impacts the cost of producing goods in whatever market we are interested in analyzing and then using those variables as instruments in our model.</p><p><strong>Step 2) Vet your Instruments</strong></p><p>Recall our two conditions: instrument relevance and instrument exogeneity. These can be summed up in one sentence — the Z-variable should affect the Y-variable only through its relationship with the X-variable. In the case of demand curves, the instrument should affect price only through its effect on supply curves. That is, the variation in the instrument should not have any impact on demand. This last part, which is related to instrument exogeneity, is generally not a testable condition. That means that we need to use our industry-expertise and intuition to determine whether our instrument only shifts supply as intended.</p><p>In Philip Wright’s problem, rainfall could tenably impact demand as well as supply. Higher rates of rainfall might discourage market-goers from leaving the comfort of their cottages to buy butter. However, using our intuition, we can conclude that this relationship is likely small, hard to observe, or non-existent. The important point to remember, however, is that we must critically think about whether our instruments meet the two necessary conditions.</p><p><strong>Step 3) Consider Omitted Variables and Model Specification</strong></p><p>Just as simultaneous equations prove to be an issue in determining demand curves, so too can omit variables. As I previously discussed, omitted variables can induce statistical bias in our models and that is why it is important to use control variables, even in IV models. Income is a key variable to include when estimating demand curves. Income is a demand-shifter — as income increases, consumers tend to demand more of a product at the same price. For market analysts, understanding the relationship between a consumer’s income and their willingness to buy a product at a certain price is a key piece of information. As we saw in our example above, including variables like income and the price of a substitute good can substantially change the regression coefficients towards the value of the unbiased, true coefficient values. Therefore, we should make an effort to pursue and include any variables we think might shift the demand curve as exogenous variables in our models.</p><p>Additionally, it is important to understand the model specification. The two most common specifications are linear demand curves and logarithmic demand curves. The decision about which specification to implement largely depends on which interpretation fits the data better. In linear demand curves, a one-unit increase in price decreases quantity demanded by ß1. Meanwhile, with logarithmic demand curves, a one <em>percent </em>increase in price decreases quantity demanded by ß1 percent. In any case, we can test which model fits the data better by estimating two models — one in which quantity and price are log-transformed and one in which they are not — and comparing the goodness-of-fit measures such as R².</p><p><strong>Step 4) Go Forth into the World</strong></p><p>Once you have identified potential instruments, vetted them for exogeneity and relevance, and considered your model specifications, you are ready to deploy instrumental variables regression. Whether you are a startup formulating your pricing strategy or an established company trying to better understand your customer base, instrumental variables can play an <strong><em>instrumental </em></strong>role in your data science arsenal.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=21af225187cd" width="1" height="1" alt=""><hr><p><a href="https://medium.com/data-science/supply-demand-and-the-instrumental-variable-lessons-for-data-scientists-from-the-economists-21af225187cd">Supply, Demand, and the Instrumental Variable: Lessons for Data Scientists from the Economist’s…</a> was originally published in <a href="https://medium.com/data-science">TDS Archive</a> on Medium, where people are continuing the conversation by highlighting and responding to this story.</p>]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Millennials’ Favorite Fruit: Forecasting Avocado Prices with ARIMA Models]]></title>
            <link>https://medium.com/data-science/millennials-favorite-fruit-forecasting-avocado-prices-with-arima-models-5b46e4e0e914?source=rss-c7c83ac0b074------2</link>
            <guid isPermaLink="false">https://medium.com/p/5b46e4e0e914</guid>
            <category><![CDATA[forecasting]]></category>
            <category><![CDATA[statistics]]></category>
            <category><![CDATA[food]]></category>
            <category><![CDATA[millennials]]></category>
            <category><![CDATA[avocado]]></category>
            <dc:creator><![CDATA[Sean Holland]]></dc:creator>
            <pubDate>Thu, 25 Jul 2019 09:00:36 GMT</pubDate>
            <atom:updated>2021-04-28T16:18:03.804Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*11nsx-jlBJ5_cGkY" /><figcaption>It’s a fruit. — Photo by <a href="https://unsplash.com/@thoughtcatalog?utm_source=medium&amp;utm_medium=referral">Thought Catalog</a> on <a href="https://unsplash.com/?utm_source=medium&amp;utm_medium=referral">Unsplash</a></figcaption></figure><p>If you know the first thing about finance, you know that the single obstacle standing between Millenials and the white picket fence is <a href="https://money.cnn.com/2017/05/15/news/millennials-home-buying-avocado-toast/index.html">avocado toast.</a> If the kids of the Information Age would just get off their butts, walk away from the brunch table, and leave their smashed avocado and poached egg on whole grain behind then maybe they could afford their <a href="https://medium.com/@sean.holland20/a-stroll-through-small-town-america-real-estate-data-from-ames-iowa-d02c285bb464">dream two-bedroom in Ames, Iowa</a>. <em>Obviously</em>.</p><p>In solidarity with Millenials’ avocado toast-induced financial woes, I wanted to take a deeper look at <a href="https://www.californiaavocado.com/blog/avocado-fruit-or-vegetable">America’s favorite fruit</a>. Yes, the avocado is a fruit — a berry even. My research also suggests that the avocado is not, in fact, a conspiracy by toast manufacturers to sell more toast.</p><p>So, in this post, I will be analyzing data from the <a href="https://hassavocadoboard.com/inside-hab/">Hass Avocado Board (HAB) </a>— a trade organization that provides industry professionals with research and data on avocado prices around the world. If you are looking to get a taste of avocado-related research, you can find the data <a href="https://www.kaggle.com/neuromusic/avocado-prices">here</a>.</p><p><strong>Data</strong></p><p>The HAB dataset is comprised of weekly time series data spanning 168 weeks from January 4, 2015, to March 25, 2018. For this period, the dataset provides average price and total volume data for conventional and organic avocados in 54 regions of the United States, totaling over 18,000 observations.</p><p>So let’s get into it — what do our avocados look like?</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/712/1*Pd6u22OE7c5m4rx-nh5NrA.png" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/962/1*rrlpheaY5CLX5QGpHL6VEg.png" /></figure><p>The eye test tells us that organic avocado prices are both higher on average and more volatile than conventional avocados. Digging into the numbers, conventional avocados cost on average $1.16 across all regions with a standard deviation of $0.26. Meanwhile, organic avocados cost on $1.65 on average with a standard deviation of $0.36.</p><p>Looking at avocados sold, however, reveals that organic avocados only constitute about 3 percent of all avocados sold in the US over this period. Between January 2015 and March 2018, consumers bought over 33 million conventional avocados and under one million organic avocados.</p><p>We know that conventional avocados are more expensive on average and vastly outpace organic avocados in terms of sales. So, this raises the question — what is the nature of the relationship between price and volume sold?</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/712/1*dQyxxj4GiALqJzLc_Ui53Q.png" /><figcaption>(Conventional) Pearson’s Correlation = -0.51 p-value&lt;0.001 | (Organic) Pearson’s Correlation = 0.02 p-value=0.75</figcaption></figure><p>For the 168 weeks studied, conventional avocados demonstrated a moderate negative correlation between average prices and units sold. Nothing out of the ordinary here, rather basic principles of economics — quantity demanded increases as price decreases.</p><p>Organic avocados tell a different story. There is no statistically significant relationship between the price tag and units sold for organic avocados. Demand is flat, meaning that regardless of price, consumers are unlikely to significantly change the quantity they demand. Context is important in understanding this relationship.</p><p>Research has shown that <a href="https://pdfs.semanticscholar.org/816c/142e6d87f747d3aa0660515239e0fc1bf0ce.pdf">consumers with higher incomes, young children, and/or college degrees are more likely to be “devoted” organic consumers than their peers.</a> In this context, “devoted” indicates that the consumer spends a higher-than-average portion of their household income on organic fruits and vegetables. Therefore, it is reasonable to think that regular organic avocado consumers belong to a non-typical segment of the population. Unfortunately, I don’t have the resources to find the causal factors behind this flat relationship, but I can certainly (and will gladly) venture a guess. Consumers who regularly buy organic goods are (probably) more likely to do so out of some principle. Perhaps the consumer believes organic foods to be healthier or more ethical than non-organic foods. Therefore, the organic consumer would not likely consume non-organic foods due to simply shifts in organic food prices, giving us the flat demand curve for organic avocados.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*LXTPvn5T94vXtIWSTGSh3A.png" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*ucKYxDc1GEbqcoPyODuTjg.png" /><figcaption>Right: Average Price (USD) | Left: Total Volume (Avocados Sold)</figcaption></figure><p>Next, I wanted to take a quick look at prices and volume by region. Northeasterners (my people) and Washingtonians (also my people) pay amongst the highest rates for organic and conventional avocados in the country. Northeasterners pay $1.34 on average for conventional and $1.86 for organic avocados. Meanwhile, the national average for avocado prices stands at $1.09 for conventional and $1.55 for organic.</p><p>In terms of volume, Westerners consume the most avocados, both conventional and organic, per week on average. Westerners consumed over 6,180,000 conventional and 220,000 organic avocados per week. Compared to national averages, Westerners consume about 18 percent of all conventional and 23% of all organic avocados sold in the US.</p><p>That’s a lot of avocado toast.</p><p><strong>Forecasts</strong></p><p>I think it’s pretty safe to say that the ship has sailed for Millenials in terms of being able to afford that two-bedroom I mentioned earlier. I mean Americans are spending around $7,000,000 a week on avocados so all hopes of the white picket fence should be dashed for Millenials.</p><p>Thankfully, according to the <a href="https://www.pewresearch.org/fact-tank/2019/01/17/where-millennials-end-and-generation-z-begins/">Pew Research Center</a>, I belong to the Gen Z cohort. Of course, this means that I need to have some idea of how the avocado economy is going to affect <em>my </em>chances at picket-fence related dreams.</p><p>To do so, I turned to ARIMA forecasting. <a href="https://www.investopedia.com/terms/a/autoregressive-integrated-moving-average-arima.asp"><strong>A</strong>uto-<strong>R</strong>egressive<strong> I</strong>ntegrated<strong> M</strong>oving<strong> A</strong>verage</a> models are a general class of models that allow for forecasting models to be made stationary through “differencing.” Stationarity is an important condition in forecasting, as nonstationarity can undermine the reliability of traditional confidence intervals, hypothesis tests, and forecasts.</p><p>ARIMA models can be broken down into three components, AR, I, and MA. First, the AR component describes a linear multiple regression with a given number of previous values of <em>Y </em>as the predictors for <em>Y(t). </em>The I component describes the order of differencing necessary to make the model stationary. The MA component is similar to the AR component in that it introduces a lagged value into the model. However, the lagged value is the previous error terms, not the previous values.</p><p>Thankfully for an ARIMA novice such as myself, Rob Hyndman’s “Forecast” package in R comes equipped with the auto.arima function. Auto.arima tests several ARIMA models and selects the best one based on Akaike Information Criteria, providing an excellent starting point from which to select a final model.</p><p>Using Augmented Dickey-Fuller tests, which tests for unit roots that can bias the OLS estimators, I concluded that one order of differencing was necessary for each of my four models — conventional prices, conventional volume, organic prices, and organic volume. Additionally, I elected to use seasonal ARIMA models, which contain another set of AR, I, and MA parameters for a given period (in this case 52 weeks or one year).</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/894/1*Jq1arehmJr14VIGQSROIcA.png" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*7_CSMfw0ajFhYJDGI1LyEA.png" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*KteT3vre45fR_jud1jrEjQ.png" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/964/1*JO0DhjR0Cp6tD79u0QLPVQ.png" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/966/1*hrGjeqFRwrr4lMe-rX2JaA.png" /></figure><p>So, what can we learn from our models? Well, first of all, our average price models seem to show us that avocado prices reach their peak each year in the Autumn. In October 2017, conventional avocados peaked at $1.65 and our model forecasts that Autumn spikes will continue to occur through 2018 and 2019. However, the model predicts that conventional avocado prices will trend downwards over the following two years. Between 2015 and 2018, the average conventional avocado price was $1.09. Between 2018 and 2020, the forecasted average price is $1.01, a decrease of about 7 percent.</p><p>In stark contrast, the model forecasts that organic avocado prices will experience moderate growth, bolstered by less volatility. The forecasted average price between 2018 and 2020 is $1.84, compared to $1.55 between 2015 and 2018. The model certainly demonstrated a moderate upward trend for organic avocado prices.</p><p>However, the growth in average prices is also due in part to decreased volatility, with the standard deviation of prices down to $0.16 for the forecasted period from the $0.36 standard deviation experienced between 2015 and 2018.</p><p>Both conventional and organic avocados are forecasted to experience strong growth in terms of units sold over the 2018–2020 period. Conventional avocado production is forecasted to grow over 40 percent from 33.7 million to 47.6 million avocados sold each week on average.</p><p>Organic avocados are forecasted to experience even more meteoric growth. A consistent growth trend between 2015 and 2018 is predicted to continue through 2019 with a whopping 74 percent growth between 2018 and 2020. Between 2015 and 2018, suppliers sold about 970,000 organic avocados weekly. Between 2018 and 2020, the number is forecasted to jump to <em>1.68 million </em>organic avocados.</p><p><strong>Discussion</strong></p><p>I think these models are really exciting. First, in terms of pattern recognition, it is interesting to see the models picking up on seasonal trends. The price models captured the Autumn price hikes and the volume models captured the spikes that occur in avocado volume each February.</p><p>Additionally, the diagnostics look pretty good. Mean Absolute Percentage Error, or MAPE, measures the error between the forecast and observed values, so a lower value indicates a better fitting model. The highest MAPE amongst the four models is for the organic volume model, at around 6 percent, indicating the model is about 94 percent accurate. I am very happy with this level of fit and I am confident in all of the models. At least, I am as confident as an forecasting newbie could be.</p><p>If I had to editorialize (which I will gladly do) I would say that the growth forecast for organic avocado volume is somewhat bullish. I am not sure how realistic 74 percent growth is over only two years, but testing several models yielded similar results.</p><p>Alternatively, I think that the conventional avocado price model is somewhat bearish. With the Autumn price hike increasing each year since 2015, I was surprised that the model forecasted overall price decreases. However, if it ends up being the case through 2020, you will not see me complaining at brunch.</p><p><strong>Conclusion</strong></p><p>So there it is folks — my little introduction to ARIMA forecasting and with a worthy test subject like avocados. And although conventional avocado prices might be decreasing, it looks like the increased volume of avocados sold is going to keep yet another generation from attaining suburban, property-owning paradise.</p><p>I hope you enjoyed my foray into forecasting and I hope to return to this subject soon with more improved ARIMA models and other more complex models. And hey, maybe invest in organic avocado growers — you just might see a 74 percent return.</p><p>Well, probably not.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=5b46e4e0e914" width="1" height="1" alt=""><hr><p><a href="https://medium.com/data-science/millennials-favorite-fruit-forecasting-avocado-prices-with-arima-models-5b46e4e0e914">Millennials’ Favorite Fruit: Forecasting Avocado Prices with ARIMA Models</a> was originally published in <a href="https://medium.com/data-science">TDS Archive</a> on Medium, where people are continuing the conversation by highlighting and responding to this story.</p>]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Under the Dome: A Look at Data from the 116th Congress]]></title>
            <link>https://medium.com/@sean.holland20/under-the-dome-a-look-at-data-from-the-116th-congress-c052c3d7b0bd?source=rss-c7c83ac0b074------2</link>
            <guid isPermaLink="false">https://medium.com/p/c052c3d7b0bd</guid>
            <category><![CDATA[politics]]></category>
            <category><![CDATA[congress]]></category>
            <category><![CDATA[statistics]]></category>
            <dc:creator><![CDATA[Sean Holland]]></dc:creator>
            <pubDate>Wed, 17 Jul 2019 05:31:23 GMT</pubDate>
            <atom:updated>2019-07-17T05:31:23.230Z</atom:updated>
            <content:encoded><![CDATA[<p><em>Note: All data are accurate as of July 10, 2019.</em></p><p>This Spring I had the pleasure of working with the super bright people over at <a href="https://www.quorum.us/about/">Quorum Analytics.</a> And, even though I was just an intern on the marketing and communications team, the company is generous enough to offer accounts to its alumni.</p><p>For background, Quorum Analytics offers an integrated software platform that offers products and solutions in stakeholder engagement, legislative tracking, and grassroots advocacy. I will be using data from Quorum’s comprehensive databases on local, state, and federal legislators, which seems appropriate since Quorum started out as an algorithm to see who members of Congress most often worked with. Quorum’s legislative tracking allows users to see where a given bill or resolution stands in the legislative process and monitor/search legislators’ public statements, including press statements and social media posts.</p><p>For today’s post, I will focus on data on legislators from the 116th Congress. Quorum allows its users to use “Sheets” to select legislators, their biographical data, and variables such as how often they vote with their party.</p><p>While my last few posts have attempted to answer specific questions regarding real estate pricing, NBA salaries, and the 2009 labor market, this post will be much more of a data exploration — profiling makeup of our current Congress.</p><p><strong>Data</strong></p><p>The data I pulled from Quorum Sheets included 539 federal legislators — 100 Senators, 433 Representatives, 5 US Delegates, and Puerto Rico’s Resident Commissioner. However, for the sake of consistency, I will only be looking at Senators and Representatives.</p><p>Additionally, while almost all federal legislators are either registered Democrats or Republicans, there are three Independents — two in the Senate and one in the House. I grouped Sens. Bernie Sanders and Angus King with the Democrats and Sen. Justin Amash with the Republicans based on their voting record and the political lean of their respective districts.</p><p>Anyway, let’s dive in.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/678/1*boCoc4sVF1p1FdPDspgsAQ.png" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/698/1*WtwCOvi21NuifWMRH0-0vQ.png" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/694/1*H3NVBgBdeOxkswDkRBEWkA.png" /></figure><p>The data reveal that, demographically, Democrats in the House and Senate tend to be more diverse. Non-white minorities and those of two or more races make up 37.5 percent of Democrats, indicating that racial/ethnic minorities are slightly “over-represented” in the Democratic Party. However, women are clearly underrepresented in the party, comprising only 37.5 percent of the party’s federal legislators.</p><p>The Republican Party fares far worse on with both minorities and women. Only 9 Republicans — or 3.6 percent of the party — are minorities. Similarly, women only comprise 16.7 percent of the party’s legislators, indicating significant underrepresentation of both women and minorities amongst the party’s legislators.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1010/1*CQW-uRh3SM7-1fIllMaRpg.png" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/1010/1*CjfudCQbYixx9JYG83YEXg.png" /></figure><p>Looking at histograms measuring age in the House and Senate reveals that House Representatives are, on average, about 5 years younger than their Senate counterparts. Representatives have average and median ages of 57.47 and 58 years respectively. Meanwhile, Senators have average and median ages of 63.01 and 64 years respectively.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*IseUmMPbGPa_x8pEdYRnfA.png" /></figure><p>Histograms measuring legislative activity (the sum of the number of bills a legislator has sponsored or been a primary co-sponsor of) reveal high variation in Democrats’ legislative activity.</p><p>Since a quarter of legislators have spent less than 5 years in the House and Senate, I wanted to take a look at the indicators for legislative activity, accounting for party, age, years in office, and other factors.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*pF6Oaygpom5jmgqblzpPlA.png" /><figcaption>Dependent Variable: Legislative Activity (Sponsored Bills+Primary Co-sponsorships)</figcaption></figure><p>Based on the regression model, I concluded that there is a clear linear relationship between the amount of time a legislator spends in office and their legislative activity. Interestingly, this relationship and the relationship between age and legislative activity are both positive and significant. These indicators signify that, given a certain number of years in office, older legislators sponsor and primary co-sponsor more legislation than their younger counterparts.</p><p>Additionally, accounting for gender, race, and chamber, Democrats sponsor and primary co-sponsor more legislation than Republicans, which seems on-brand for the party of big government. Interesting, Democrats in the Senate produce around 224 bills more bills than House Democrats on average when accounting for age and years in office.</p><p>It also appears that polarity, as measured by adjusted Cook PVI, has little to do with legislative activity. This contradicted my expectations as I expected that legislators in less partisan districts might face more competition and thus produce more legislation in order to produce a legislative track record to aid in campaigning. However, when controlling for party, years in office, and other factors, there is no significant relationship between adjusted Cook PVI and legislative activity.</p><p>Note:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*Fkb1frrqPJGfUbbjOm8xPA.png" /></figure><p>While looking at this graph, demonstrating a relationship between years in office and legislative activity, I realized that none of my previous posts have accounted for heteroskedasticity.</p><p>While I don’t miss having to walk to GWU’s library to use Stata, I do miss Stata’s robust command, which calculates robust standard errors. Thankfully, <a href="https://economictheoryblog.com/2016/08/08/robust-standard-errors-in-r/">Economic Theory Blog has created a function to calculate robust standard errors in R as simply as in Stata.</a></p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*ePXNxJMdnC-KeEvVAZDHqg.png" /></figure><p>The Cook Partisan Voting Index is a measure of the partisan lean of each congressional district. The further from zero a given district’s PVI lies, the more partisan the district. The PVI is generally notated as R+13 for a district with a 13-point Republican-lean. However, simplicity, I have organized Republican districts as negative.</p><p>The data are in line confirm the basic idea that Democrats are more likely to be elected in districts that lean further left and vice versa. While there are certainly a few exceptions, at least three of the Republicans elected in firmly Democratic-leaning districts are a product of recent redistricting. Reps. Brian Fitzpatrick (R-PA-01), Guy Reschenthaler (R-PA-14), and John Joyce (R-PA-13) were elected in districts that measured D+33, D+17, and D+15 respectively. However, all three Representatives represent districts that were redistricted in Pennsylvania’s 2018 redistricting and both Reschenthaler and Joyce were first elected in November 2018. Before the redistricting, <a href="https://ballotpedia.org/Pennsylvania%27s_13th_Congressional_District">Joyce’s district had been controlled by a Democrat since at least 2000.</a></p><p>This raised the question, however, whether there exists a relationship between a district’s partisanship and party allegiance. To test the relationship, I tested the correlation between a district’s adjusted PVI (corrected so that the PVI is positive if the lean matches the Representative’s party and is negative if the PVI leans towards the opposite party) and the Representative’s tendency to vote against their party.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*_md53K-p0CnS5CbOGM-ICw.png" /><figcaption>Pearson’s Correlation = -0.161 ± 0.09 P-Value = 0.0008</figcaption></figure><p>The scatterplot shows a significant, if small, relationship between adjusted PVI and a Representative’s percent of votes against their party. Representatives in districts that lean towards their own party tend to break party lines less often than Representatives in less partisan or opposite party-leaning districts.</p><p>Finally, I want to look at the idea of bipartisanship. Bipartisanship is often a loaded word, suggesting a solution that rises above the fray of partisan politics although the term is more often used to characterize a given party as uncooperative and unreasonable for holding a principled stance. Don’t worry, I won’t be trying to answer any overly complex questions about bipartisanship like <a href="https://www.currentaffairs.org/2018/01/the-curse-of-bipartisanship">if it is even good in the first place.</a></p><p>Rather, I simply want to look at what factors share a relationship with bipartisanship. As there is no single bipartisanship variable, I analyzed the percentage of bills that a lawmaker has co-sponsored that was sponsored by an opposite party legislator. While I cannot account for the scale of the bills in question — dozens of bills each year are written to name post offices or commemorate awareness months — this percentage should act as a reasonable proxy for bipartisanship.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*xU3BLhl0SEkHzKEdP2T1ZA.png" /></figure><p>The very first thing I picked out from this model is the R²-value. At only 0.11, the R² indicates that this model accounts for only 10 percent of the variation in the percentage of opposite party co-sponsorships. This is not particularly surprising, given the various, hard-to-capture variables that determine a legislator’s voting record. Thankfully, these indicators give us insight, even if small, into bipartisanship in Congress</p><p>First, Democrats tend to co-sponsor a higher percentage of Republican-sponsored legislation than the inverse. However, women in the Democratic party tend to co-sponsor less Republican legislation than their male counterparts proportionally.</p><p>Additionally, Senators and longer-tenured legislators tend to co-sponsor a higher proportion of opposite party-sponsored legislation. While I don’t have a definitive answer as to why this relationship exists, I believe that it has to do with relationship building. At any given time in the Senate, a legislator might have between 40 and 60 opposite party colleagues in the chamber, making the prospect of becoming acquainted and working with those colleagues far easier than in the 435-member House of Reps. Meanwhile, as a legislator accumulates experience in Congress, so too is a legislator likely to accumulate a network of legislative allies, especially on issues like veteran affairs which are <a href="https://www.pewresearch.org/fact-tank/2019/02/04/state-of-the-union-2019-how-americans-see-major-national-issues/">less polarizing than immigration and health care.</a></p><p>Our most interesting indicator is adjusted Cook PVI. As a reminder, the higher the adjusted PVI, the more partisan the district is in favor of the legislator’s party. The model depicts a negative relationship between the adjusted PVI and co-sponsoring opposite party legislation. Again, we can’t discern one particular reason, but I posit that legislator’s in districts that lean heavily towards their party have less incentive to work with the opposite party.</p><p>A Republican lawmaker who is elected in a highly Republican-leaning district is likely to share his or her political convictions with a large portion of the district. Therefore, he or she has little incentive to compromise with Democratic lawmakers rather than hold on to those convictions. Alternatively, lawmakers in swing districts might try to curry support from conservative and liberal voters by working across the aisle on legislation.</p><p>In any case, it is clear that there are several factors at play in determining a lawmaker’s voting record — many of which I cannot hope to capture in this post.</p><p>Thank you for reading. I hope you enjoyed this data exploration of the 116th Congress. If you enjoyed this post, make sure to <a href="http://medium.com/@sean.holland20">check out some of my other posts.</a></p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=c052c3d7b0bd" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[A Stroll Through Small-Town America: Real Estate Data from Ames, Iowa]]></title>
            <link>https://medium.com/@sean.holland20/a-stroll-through-small-town-america-real-estate-data-from-ames-iowa-d02c285bb464?source=rss-c7c83ac0b074------2</link>
            <guid isPermaLink="false">https://medium.com/p/d02c285bb464</guid>
            <category><![CDATA[real-estate]]></category>
            <category><![CDATA[statistics]]></category>
            <category><![CDATA[economics]]></category>
            <dc:creator><![CDATA[Sean Holland]]></dc:creator>
            <pubDate>Wed, 10 Jul 2019 08:02:27 GMT</pubDate>
            <atom:updated>2019-07-26T20:33:45.216Z</atom:updated>
            <content:encoded><![CDATA[<p>If you have read up on your trivia of small-town American cities, you might know Ames, Iowa as the home to Iowa State University and a city boasting over 65,000 residents — at least when school is in session when ISU is home to about 30,000 students. If you happen to be a real expert you might even know that Ames is the seventh largest city in the 31st largest state by population.</p><p>Or, if you are like me and the 99 percent of Americans who do not live in Iowa, you have not once heard of or given thought to the bustling metropolis of Ames. Thankfully, dear Reader, I have done enough research for the both of us.</p><p>This past Spring, I took Introduction to Econometrics and our final empirical project involved analyzing real estate data in Fairfax County, Virginia. So when I saw a<a href="https://www.kaggle.com/c/house-prices-advanced-regression-techniques/data"> Kaggle competition for predicting real estate values in the hip, hot market of Ames, Iowa</a> I could not possibly resist. So here it is, my analysis of real estate values in everybody’s seventh favorite Iowa city.</p><p>You’re welcome.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*7B7qdPVsdKlsFbjIreWbQg.jpeg" /><figcaption>The very first result when I typed “Ames, Iowa” into a royalty-free image site. Warning: may not actually be Ames, Iowa</figcaption></figure><p><strong>Data</strong></p><p>Okay, that’s probably enough bagging on small-town America. These data were pretty fun to work with. The dataset is relatively small, with only 1,450 residential properties to analyze, all of which were sold between 2006 and 2010. However, there are 80 explanatory variables with a combination of continuous, discrete, and categorical variables. The categorical variables posed an initial challenge and I am henceforth eternally grateful for Christopher Brown’s “<a href="https://cran.r-project.org/web/packages/dummies/dummies.pdf">dummies</a>” package in R which saved me hours of manually coding categoricals into dummies.</p><p>In terms of continuous and discrete variables, notable variables included lot area, above grade living area, basement size, number of bedrooms, year built, and overall quality and condition. Categorical variables included sale type and condition (such as foreclosure or family sale), neighborhood, and building type (such as single family or townhouse). And, of course, we have our dependent variable: sale price.</p><p>As with most real estate data, some data transformations are necessary. From the real estate data I’ve worked with in the past, I’ve noticed that housing prices and living and lot areas are best understood with natural logarithmic transformations. These data tend to be right-skewed by large, high-value properties that, if I had to guess, include mansions and farmland. Plus, log-log models still provide for easy interpretation — even if I have to look it up just about every time. A model that looks like</p><p><strong><em>ln(Sale Price) = ß0 + ß1*ln(Lot Area)</em></strong></p><p>indicates that every 1 percentage increase in “Lot Area” is associated with a ß1 percentage increase in “Sale Price”. And, as a newly-minted apartment lessee in downtown DC, I’m quite certain that an extra 50 square feet are a lot more valuable to a broke Iowa State student than a corn farmer in North Ridge Heights</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*15mZyc4VH-pzM6sDhP2SmQ.png" /></figure><p>Starting with the sale price, we can certainly see evidence of right-skewness. The mean house price in Ames is $181,654.90, while the median price is $163,945. This gives us a skew of 1.9, which in economic academia, is known as gross. Of course, there’s no need to worry since we have our hero, natural log, to get everything back to normal.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*lYOE20H0d82zRiEk1rCpjA.png" /></figure><p>Much Better.</p><p>Our new mean is 12.01 log-dollars with a median of 12.03 log-dollars. And skewness is at a much more palatable 0.23.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*XRnC4-14kGQqs4ijBUEINw.png" /></figure><p>The histogram for lot area is just ugly. There’s a tight grouping of properties around the median of around 9,500 square feet. And then there are some monstrosities that can only be effectively described in acres (our max lot area is about 4.5 acres). Those properties give us a skew of 12.15. Gross. But, the natural log transformation normalizes our distribution and skewness is down to -0.14 with a mean and median of 9.11 and 9.14 respectively.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*R_9wUGUNQr5rrTr5ga7-ow.png" /></figure><p>Like lot area and sale price, above grade living area (ABLA) gets the natural log treatment. The mean ABLA is 1517.7 square feet with a median of 1466 square feet and a skew of 1.37. Again, gross. After applying a log transformation, we have a mean of 7.27 log-ABLA and a skew of 0.01.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/548/1*6uGeyA5N-R0BKN1jUJ9dWQ.png" /></figure><p>Before starting a more in-depth analysis I want to take a quick look at two charts. The first is a scatterplot with ABLA and sale price, and the second is a scatterplot with log-ABLA and log-sale price.</p><p>Just applying the eye test shows us that the log-model has a tighter grouping of points which should indicate lower residuals and thus a better model. Of course, no one has won the Nobel Prize in Economics with the eye test, so I ran two simple regression models. Using R² as a diagnostic, the linear-linear model records an R² of 0.5022 while the log-log model gives us an R² of 0.5364. The log-log model wins out.</p><p>Also, side note, but I want to see some of these houses in North Ridge. Seriously, $750,000 houses in 2006–2010 in Iowa? I have questions and I want answers, Ames.</p><p><strong>Analysis</strong></p><p>In my article about <a href="https://medium.com/@sean.holland20/nba-salaries-2018-a-hedonic-pricing-model-for-the-2018-2019-nba-season-ef10ad9e4c73?source=friends_link&amp;sk=ac5c20b57fa1c49c1020c56b30ec6248">NBA salaries</a>, I discussed hedonic pricing models. In case you missed it, hedonic pricing models allow us to breakdown the prices of heterogeneous goods like residential properties by analyzing the impact of individual characteristics of that good.</p><p>When you’re at Trader Joe’s picking out hormone-free hot dogs for a Fourth of July cookout, the unit price is probably the determining factor in which brand you select. Rational consumers want to pay less for very similar products. However, there is no single demand curve for houses the way there might be one demand curve for hormone-free hot dogs. Rather, real estate valuation can be broken down into the relationships between demand-generating characteristics such as size, number of bedrooms, and age of the building.</p><p>So, we first need to pick out a selection of characteristics that determine housing prices in the tropical paradise of Ames, Iowa. Since I already determined that log-ABLA accounts for 53.64 percent of the variation in log-sale price, that’s a good place to start.</p><p><strong>Model Set 1</strong></p><figure><img alt="" src="https://cdn-images-1.medium.com/max/840/1*kml3nW5cjFxVJvS-eRX1CA.png" /></figure><p>I started by just looking at the relationship between lot dimensions and price. Adding basement and garage area indicators helped boost our R²-value by a decent amount, but there is still plenty of variation to account for. So, back to the drawing board.</p><p><strong>Model Set 2: Miscellaneous</strong></p><p>Before choosing my final pricing model, I had some miscellaneous questions about the Ames housing market. First, I wanted to know what housing prices are like across each towns neighborhoods, both controlling and not controlling for house characteristics. The first model, not controlling for characteristics, gives us average prices for houses in each neighborhood. The second model should be able to tell us which neighborhoods actually provide a value-add. If a neighborhood has a significant, positive relationship with the sale price, controlling for house-level characteristics, then we can conclude that the neighborhood adds value to the property.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/918/1*KQpw2HSaHT2mvvS2s6k5Sw.png" /></figure><p>Our big winners in this model are North Ridge, Stone Bridge, and North Ridge Heights, all of which have significant coefficients, indicating average housing prices over $300,000.</p><p>Brookdale and Meadow Village housing prices pale in comparison with average house prices around $100,000</p><p>Our second model, controlling for house-level characteristics gives us more insight into the value-add of each individual neighborhood. Note that the dependent variable here is log-sale price while in the previous model the dependent variable was the standard sale price.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/932/1*REI3d-qs86ZxjVqkiAiF7g.png" /></figure><p>Controlling for lot size, ABLA, overall quality, and other characteristics, several neighborhoods have significant value-adds.</p><p>The most notable winners are Somerset, Stonebridge, and the North Ridges. These four neighborhoods all have significant, positive coefficients indicating that these neighborhoods provide a value-add to property values given a certain size and quality.</p><p>I also wanted to see what impact, if any, the Great Recession had on Ames’ property values. Bloomberg Business named Ames one of the “<a href="https://www.bloomberg.com/news/articles/2015-06-22/here-are-the-15-cities-that-have-done-the-best-and-the-worst-since-the-recession">15 Cities That Have Done the Best Since the Recession</a>” and I wanted to see if housing prices reflected that since these sales occurred between 2006–2010.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/918/1*SuaRIo4qief3bRJxDy2ORg.png" /></figure><p>Nothing.</p><p>Not even a little. The intercept represents 2006 housing prices. The slight decrease in housing prices in 2008 is not significant at any meaningful level of confidence. Looks like Bloomberg got this one right.</p><p><strong>Final Model Set</strong></p><p>After toiling away at log-transformations and coding categorical variables I have finally arrived at my final two models.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/644/1*w0Eoe9OwYE_7uz8ODBfe9w.png" /></figure><p>Now I know this table rounds to two decimal places, but Model 1 actually has an adjusted R²-value of 0.8726 compared to Model 2’s adjusted R²-value of 0.8717, so Model 2 is officially my final model for predicting housing models in Ames, Iowa. And there are certainly some interesting findings to discuss.</p><p>First, there is a negative relationship between bedrooms above grade and log-sale price. While I can’t hope to give an exact explanation as to why this relationship exists, my intuition tells me that bedrooms are a necessity when considering housing. A buyer only demands enough bedrooms to house themselves and their family/friends. Therefore each additional bedroom occupies space that could instead function as a den or office, in which to read my articles.</p><p>Further, the sale type and condition are important factors to consider in evaluating home prices. Newly constructed homes sold for more on average than houses being resold.</p><p>Houses sold between family members or occurring under abnormal circumstances such as foreclosure sold for less than sales under normal conditions.</p><p>Townhouses sold for less than single-family homes, even when controlling for size, number of bedrooms, and other characteristics. However, the interaction term between log-lot area and townhouses indicates that the coefficient for the log-lot area for townhouses is actually around 0.16 as opposed to 0.09 for single-family homes.</p><p>Finally, and perhaps most shockingly, pools are <em>negatively</em> related to sale prices. Okay, maybe I shouldn’t be as shocked as I am. While Iowa summers tend to be hot and humid — an ideal climate for pool volleyball — winters are cold with <a href="https://www.britannica.com/place/Iowa-state/Climate">January temperatures averaging about 14 degrees Fahrenheit</a>, boosting the costs of pool maintenance for half the year. But still, come on Iowa.</p><p><strong>Conclusion</strong></p><p>Well, it has sure been a journey. I hope you enjoyed this little tour of small-town America and its apparent disdain for pools.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=d02c285bb464" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[NBA Salaries 2018: A Hedonic Pricing Model for the 2018–2019 NBA Season]]></title>
            <link>https://medium.com/@sean.holland20/nba-salaries-2018-a-hedonic-pricing-model-for-the-2018-2019-nba-season-ef10ad9e4c73?source=rss-c7c83ac0b074------2</link>
            <guid isPermaLink="false">https://medium.com/p/ef10ad9e4c73</guid>
            <category><![CDATA[statistics]]></category>
            <category><![CDATA[nba]]></category>
            <dc:creator><![CDATA[Sean Holland]]></dc:creator>
            <pubDate>Wed, 26 Jun 2019 05:29:41 GMT</pubDate>
            <atom:updated>2019-06-26T05:29:41.158Z</atom:updated>
            <content:encoded><![CDATA[<p>Over the 2017–2018 NBA season we saw the number one draft pick play a grand total of 10 games (and still managed to be the youngest player to record a triple-double), James Harden win his first MVP award after finishing as runner-up in 2014 and 2017, and JR Smith pull off one of the most impressive blunders in NBA finals history.</p><iframe src="https://cdn.embedly.com/widgets/media.html?src=https%3A%2F%2Fwww.youtube.com%2Fembed%2FjsXtGKbwRI8%3Ffeature%3Doembed&amp;url=http%3A%2F%2Fwww.youtube.com%2Fwatch%3Fv%3DjsXtGKbwRI8&amp;image=https%3A%2F%2Fi.ytimg.com%2Fvi%2FjsXtGKbwRI8%2Fhqdefault.jpg&amp;key=a19fcc184b9711e1b4764040d3dc5c07&amp;type=text%2Fhtml&amp;schema=youtube" width="854" height="480" frameborder="0" scrolling="no"><a href="https://medium.com/media/4354234ff83ead6c86faecce7b4334a1/href">https://medium.com/media/4354234ff83ead6c86faecce7b4334a1/href</a></iframe><p>Now, none of these events or achievements are why I am looking at data from the 2017–2018 NBA season. Rather, it is the season for which we have the most up-to-date salary data for the following season — in this case, the 2018–2019 season. With the 2017–2018 data, I will be analyzing how player stats for one season impact their pay for the following season.</p><p>I will be using data from the 2017–2018 season to compose a hedonic pricing model — a pricing strategy often used in real estate valuation to estimate the demand for heterogeneous characteristics in a good. In real estate valuation, the strategy is used to deconstruct the price of a building into several demand-generating characteristics such as the number of bedrooms, lot size, and distance from city centers or public transportation hubs.</p><p>In this player-salary model, I will deconstruct player salaries for the 2018–2019 season based on characteristics including typical per-game statistics such as points and assists, advanced statistics like win-shares and player-efficiency rating, and biographical information such as age.</p><p><strong>Data</strong></p><p>The dataset, which I scrapped from Basketball-reference.com, includes data on 331 players who logged minutes in the 2017–2018 season. Two notable players who I excluded from this analysis are Jeremy Lin and Gordon Hayward — both of whom sustained season-ending injuries in their season openers.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/485/1*0HIunuAQSDfAhHygmqRU4g.png" /><figcaption>Mean: 9,315,813 | Median: 6,500,000</figcaption></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/485/1*pJ4csCAD0tRRQt7JmyQM8w.png" /><figcaption>Mean: 10.5 | Median: 9.3</figcaption></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/485/1*jh6UHRU7fryJQlYf3_PANA.png" /><figcaption>Mean: 60.2 | Median: 69</figcaption></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/485/1*kADt9vJ9-rm1t8ZMFUVZqA.png" /><figcaption>Mean 26.95 | Median: 27</figcaption></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/564/1*8BuEyGlcOB7vXK96VxHyug.png" /><figcaption>Mean: 3.38 | Median: 2.8</figcaption></figure><p>The salary histogram demonstrates that salaries are heavily right skewed, with a median yearly salary of $6.5 million inflated by salaries like Steph Curry’s $37 million 2018–2019 income.</p><p>Like salaries, points per game are right-skewed, although not as heavily as salary. The average player scored 10.5 points per game, with James Harden recording the highest PPG of 30.4</p><p>The plurality of players recorded seasons of nearly 82 games and almost half of all players recorded more than 70 games. However, several players missed large swaths of the season. Players like Zach Lavine lost time due to injury while journeymen like Marshon Brooks were late season pick-ups.</p><p>The average NBA player is about 27 years old, but a few hold-outs like Vince Carter, Manu Ginobili, and Dirk Nowitzki helped skew the distribution slightly to the right.</p><p>Win shares are an advanced metric first conceived by Bill James for use in baseball. Justin Kubatko, the founder of Basketball-Reference has since adapted the concept to basketball. Without getting too deep into the calculation and methodology, <a href="https://www.basketball-reference.com/about/ws.html">win shares can be interpreted as the number of wins the given player has contributed to his team</a></p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*vhPOUKA76cWP52ZWHKlnIw.png" /></figure><p>In my cursory analysis, I discovered that points-per-game is the statistic most correlated to salaries. While I expect that there is a significant level of omitted variable bias belying the true relationship between PPG and salary, it still makes for a pretty convincing graph. And that blueish blip to the far right of the graph? That’s Steph Curry, who just so happened to be the highest paid player of the 2018–2019 season.</p><p><strong>Models</strong></p><p><em>Basic Statistics Models</em></p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*bWT_GMZ0ug9lEP_z1iScqw.png" /></figure><p>The above models demonstrate a few key findings in this research. First, it appears that NBA front offices decreed that a player’s “prime” — the period of his career over which he plays his best basketball — ends at the age of about 30. The polynomial term “Age2” shows us that a player’s salary will max out at the age of 30, all else held equal.</p><p>Second, NBA front offices seem to undervalue the importance of defensive statistics. In fairness, part of this can be attributed to the inability of basic defensive statistics to capture the actual impact a player has on the defensive end of the court. Andre Iguodala, a player who earned the 2014–2015 NBA finals MVP award almost entirely for his ability to lock down Lebron James, only recorded 0.8 steals and 0.6 blocks per game during the 2017–2018 season. Stats like blocks and steals simply fail to capture the impact a player can have by deflecting passes, rotating correctly, and contesting shots.</p><p><em>Defensive Statistics Models</em></p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*QbiU_vylYijmEHZXw-rHUQ.png" /></figure><p>The second group of models I analyzed seek to quantify the monetary value of advanced defensive statistics. The two defensive statistics I focused on were defensive box plus-minus and defensive win shares. DBPM is derived from box plus-minus which uses a complex regression model to quantify how many points per 100-possessions a player contributes. DBPM is overall BPM minus the calculation for offensive BPM, signifying that DBPM is essentially the number of opponent points that a player prevents per 100-possession. In this dataset, the mean DBPM is -0.7 and the median DBPM is -0.2</p><p>Defensive win shares, simply put, take another regression model to analyze how many wins a player contributes through their defensive work over the course of a season. In this dataset, the mean DWS is 1.53 with a median of 1.4.</p><p>However, upon investigation, it does not appear that either DBPM or DWS are great indicators of a player’s future salary. I attempted to create formulas that accounted for both sides of the court, offensive and defensive, by taking offensive statistics like points-per-game and assists-per-game and total rebounds per game, which accounts for offensive and defensive rebounds, and adding the advanced defensive statistics. In both models which included PPG, APG, and RPG, the defensive statistics failed hypothesis tests at 5% significance. The only model for which all indicators were statistically significant was Model 2; however, Model 3 from the basic statistics models had a higher R²-value, indicating that it accounts for more of the variation in salaries. Therefore, I conclude that <strong>NBA front offices simply</strong> <strong>undervalue defensive performance.</strong></p><p><em>Advanced Statistics Models</em></p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*HhyEQmPFI-H-FEwLp8KDcA.png" /></figure><p>The final set of models I evaluated attempted to estimate how advanced statistics like usage rate, value over replacement, true shooting percentage, and win shares per 48 minutes relate to player salaries.</p><p>First, it is important to understand what these metrics mean. Usage rate estimates the percentage of team possessions that a player uses while on the floor, characterized as ending in a shot, free throws, or a turnover. The 2017–2018 season saw James Harden rank first in usage rate with 36.1 percent of team possessions ending with a Harden shot, free throw, or turnover.</p><p>Value over replacement is a <a href="https://www.basketball-reference.com/about/glossary.html">“box score estimate of the points per 100 TEAM possessions that a player contributed above a replacement-level (-2.0) player.” </a>Lebron James recorded the highest VORP in the league at 8.9, highlighting his impact on the defensive and offensive sides of the court.</p><p>True shooting percentage is a weighted average of a player’s shooting percentage, accounting for the point value of the shot. The formula is points/(2*total shots attempted). This formula gives appropriate weight to three-point shots, and in line with that weight, Steph Curry ranked fourth with a true shooting percentage of 67.5 percent.</p><p>Now, turning to the model estimates, there are a few interesting findings. First, perhaps expectedly, Model 1 demonstrates that minutes per game, usage rate, and VORP are positively correlated with salaries. The number of minutes and the amount of usage a player is given reflects the trust of the coaching staff and front office. Players that record high usage and minutes tend to be team leaders and vital role players and that could present a leveraging talking point in contract negotiations.</p><p>In contrast, Model 2 raised a few questions. Model 2 demonstrates that, when accounting for usage rate, minutes per game, and VORP, true shooting percentage is not a significant factor in determining salaries. This finding contradicts the notion of the NBA as an efficiency-oriented, Moreyball league. So, to answer this question, I generated a model with a dummy variable for players with low usage rates. I defined low usage as being one standard deviation below the league average for usage.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/728/1*O6BWhrQ7KlGOPCFh_kQ4lg.png" /></figure><p>The model demonstrates that true shooting is not a significant indicator of salaries even for low-usage players when the model controls for points-per-game. Personally, I found this somewhat surprising. For star players with high usage rates and field goal attempts like James Harden and Russell Westbrook, one might expect that true shooting percentage would be less important than points scored. However, considering low-usage, catch-and-shoot players like Robert Covington, I would expect that the TS% and low-usage interaction term would be a significant indicator of salaries. While future contract years might see a strong relationship between efficient scoring and salaries, the relationship was not robust for 2018–2019 salaries.</p><p><strong>Conclusions</strong></p><p>After analyzing three different sets of hedonic pricing models, I found myself coming back to the earlier, “basic statistics” models. There is a certain elegance that comes with analyzing a player’s raw stats as an indicator of their value. Using points, assists, and rebounds to predict salaries is an easily interpretable model. On their own, advanced metrics like VORP, win shares, and box plus-minus fail to convey important information to casual fans and luddites in NBA front offices the way points-per-game does. I look forward to analyzing the 2019–2020 salary data to see if advanced metrics, defensive statistics, and efficient scoring assume a stronger relationship with player salaries.</p><p>In any case, below is the final model I concluded on to estimate player salaries</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/732/1*z5EV4-p82Z0o3K5MYycrKQ.png" /><figcaption>Simple can be beautiful</figcaption></figure><p>Initially, it was hard to appreciate the simplicity of this model. After all, I went through dozens of models involving advanced metrics, defensive metrics, and dummy variables for each position with several of these yielding insignificant coefficients or poor goodness-of-fit diagnostics.</p><p>While the R²-value on this model is slightly lower than the “advanced statistics” models, the coefficients and independent variables are much easier to interpret. With a model like this, it should be easy to see which players are underpaid and which players and overpaid in the market.</p><p>With this model, we can see that JJ Redick, who re-signed with the Philadelphia 76ers as an unrestricted free agent, is a steal for the Sixers. Redick signed a deal that earned him $12.25 million for the 2018–2019 season. However, according to the above model, an efficient price for a player like Redick is $14 million, thanks in large part to his 17.1 points-per-game.</p><p>In stark contrast, Chris Paul’s contract extension with the Rockets earned him a bloated, $35.6 million salary for the 2018–2019 season that makes him one of the most overvalued players in the league. Given Paul’s age and solid, but not earth-shattering stats, the model estimates that his value is closer to $20.3 million. Even running Paul’s stats through Model 1 of the “advanced stats” models only yields a salary of $21.9 million. Simply put, Chris Paul won that deal.</p><p>Most importantly, I should note, is that there is still plenty left to discover here. While basic statistics do a decent job of helping us understand player salaries, there are significant other factors at play when players and teams make deals. A player’s significance to his team’s city, jersey sales, loyalty to his team, defensive skills, and untapped potential are all variables that these models could not capture, and I hope to analyze those data in research to come.</p><p>Source: <a href="https://www.basketball-reference.com/">https://www.basketball-reference.com/</a></p><ul><li><a href="https://www.basketball-reference.com/about/glossary.html">Glossary | Basketball-Reference.com</a></li><li><a href="https://www.basketball-reference.com/leagues/NBA_2018_advanced.html">2017-18 NBA Player Stats: Advanced | Basketball-Reference.com</a></li><li><a href="https://www.basketball-reference.com/contracts/players.html">2018-19 NBA Player Contracts | Basketball-Reference.com</a></li><li><a href="https://www.basketball-reference.com/leagues/NBA_2018_per_game.html">2017-18 NBA Player Stats: Per Game | Basketball-Reference.com</a></li></ul><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=ef10ad9e4c73" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Modeling Employment and Income: Data from the Great Recession]]></title>
            <link>https://medium.com/@sean.holland20/modeling-employment-and-income-data-from-the-great-recession-5b9f64085c66?source=rss-c7c83ac0b074------2</link>
            <guid isPermaLink="false">https://medium.com/p/5b9f64085c66</guid>
            <category><![CDATA[economics]]></category>
            <dc:creator><![CDATA[Sean Holland]]></dc:creator>
            <pubDate>Tue, 18 Jun 2019 00:53:05 GMT</pubDate>
            <atom:updated>2019-06-18T00:53:05.572Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/1000/0*W2VV96k7RKSi8oCZ" /></figure><p>In April 2008, the United States unemployment rate stood at around 5.0 percent. By April 2009, the unemployment rate ballooned to 9.0 percent, peaking in October of that year around 10.0 percent.</p><p>That figure, 10.0 percent unemployment, represents the highest unemployment rate in the US since November 1982 and the Great Depression before that.</p><p>To gain a deeper understanding of how the Great Recession impacted women, minorities, and workers across different income levels and regions, I analyzed a sample of 5412 workers. The sample was randomly selected from workers who reported that they had full-time employment in the 2008 Current Population Survey. The data includes their employment status as recorded in the CPS the following year. By analyzing these data, I hoped to answer two questions — what factors were most predictive of income in 2008, and what factors were most predictive of becoming unemployed in 2009.</p><p><strong>Weekly Earnings</strong></p><p>First I wanted to understand the composition of wages in 2008. The data from the CPS included respondent demographic information, such as age, race, gender, marital status and education. I analyzed several models to discern significant predictors of weekly earnings.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*cj3dIrfugtUxfYp9Y4LSCA.png" /></figure><p>These models all provide some intuitive discoveries. Respondents who reported higher levels of education also reported higher incomes, government employees earned less than their private sector counterparts, and workers from rural areas like southern and central states earned less than workers on the east and west coasts.</p><p>However, these models also provide findings that raise questions regarding the labor market’s treatment of women, minorities, and older workers. Holding all else equal, workers experience wage increases until the age of 50, at which age wages begin to trail off. At the age of 50, the models estimate that workers earn around $1350 each week, while a 66-year-old retirement-age worker earns around $1200 each week.</p><p>Additionally, these models estimate that women and racial minorities earn less on average than their male and white counterparts. The effect is even greater for minority women. According to Model 5, white women earn $259.59 less per week compared to men, men of color earn $159.84 less per week than white workers, and women of color earn $291.01 less per week than their white male counterparts. Model 5 also reveals that women who have Associate’s and Bachelor’s degrees earn less than their male counterparts who have the same respective degrees.</p><p>Of course, there are reasonable limitations to these models. While evidence reveals that women and racial minorities are earning less on average than their male counterparts, the pay discrepancies are not necessarily <em>due to</em> their race and gender. Rather, omitted variables, such as field of study and field of work might explain the gender and racial pay discrepancies, especially given the relatively low R²-values for these models. It is possible that women and racial minorities are more likely to pursue careers in social work or obtain degrees in the liberal arts than white males. Unfortunately, the dataset analyzed for this project did not include respondents’ data for such questions.</p><p><strong>Employment</strong></p><p>This dataset included information regarding the respondents’ full-time employment status the year after they responded to the CPS. An analysis of the data revealed that about 87.5 percent of respondents — all of whom had been employed in April 2008 — were still employed by April 2009.</p><p>For racial minorities, only 84.3 percent of respondents were still employed by April 2009, 86.5 percent of women were still employed by April 2009.</p><p>To assess the probability of workers employed in 2008 maintaining employment by 2009, I constructed a logistic regression model to understand the factors behind layoffs and firings during the Great Recession.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/762/1*q5T7xVmw75A5fx0Fzioukg.png" /><figcaption>Model 1: McFadden Pseudo-R² = 0.21</figcaption></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/780/1*jAqTV3xkk8Y8Q6Tf4gR4Og.png" /><figcaption>Model 2: McFadden Pseudo-R² = 0.22</figcaption></figure><p>For these models, neither women nor minorities experienced a statistically significant difference in their chances of maintaining employment, when predictors like weekly earnings are accounted for.</p><p>Model 2 demonstrates the parabolic effect of weekly earnings on the likelihood of maintaining employment. Workers were increasingly likely to remain employed up until earning about $1955 each month, after which time the likelihood began to decrease. This suggests that lower-income workers who worked more “replaceable” jobs and high-income workers whose salaries were burdensome on their firms were more likely to be fired or laid off, demonstrated by the lay-offs that <a href="https://www.economist.com/business/2010/01/21/laid-off-lawyers-cast-off-consultants">devastated professional-services firms.</a></p><p>Interestingly, Model 1 reveals that Bachelor’s and advanced degrees did not offer any statistically significant boost in the likelihood that their holders would remain employed, while those with only some college education or an Associate’s degree did see a boost in their chances of maintaining employment. One potential explanation is that workers who have pursued an Associate’s degree are more likely to pursue a “recession-proof” field like <a href="https://www.cnbc.com/2016/10/10/see-which-jobs-will-survive-the-next-recession.html">nursing or trade employment in utilities.</a></p><p><strong>Conclusion</strong></p><p>After building out models to predict employment and earnings, it is clear that the labor market does not treat workers equally. The models captured a number of findings — women and minorities earning less on average than white men, rural workers earning less but experiencing more job security, and union workers earning more but experiencing less job security. And with nearly half of <a href="https://www.cnn.com/2019/06/12/economy/2020-recession-cfos-duke/index.html">US chief financial officers predicting a recession by the middle of 2020</a>, these findings aren’t great for this soon-to-be college grad.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=5b9f64085c66" width="1" height="1" alt="">]]></content:encoded>
        </item>
    </channel>
</rss>