metachronistic http://swingleydev.com/blog/ Latest metachronistic posts en-us Sun, 13 Sep 2020 09:48:28 -0800 Equinox Marathon Weather, 2019 update http://swingleydev.com/blog/p/2015/ <div class="document"> <div class="section" id="introduction"> <h1>Introduction</h1> <p>Several years ago I wrote a post about past <a class="reference external" href="https://swingleydev.com/blog/p/1999/">Equinox Marathon weather</a>. Since that post Andrea and I have run the relay twice, and I’ve run the full marathon twice. This post updates the statistics and plots to include last year’s weather data.</p> <p>The official race this year was cancelled due to covid-19, but I will run it anyway, and I have no doubt many others will too. Last year’s race featured rain down in the valley, and high winds and a mixture of snow, sleet, and rain up on Ester Dome.</p> <div class="figure"> <img alt="Conditions on Ester Dome during the 2019 Equinox Marathon" class="img-responsive" src="https://media.swingleydev.com/img/photolog/2019/09/conditions_on_ester_dome_during_the_marathon_2019-09.jpg" /> <p class="caption">Conditions on Ester Dome during the 2019 Equinox Marathon</p> </div> </div> <div class="section" id="methods"> <h1>Methods</h1> <p>Methods and data are the same as in my previous <a class="reference external" href="https://swingleydev.com/blog/p/1999/">post</a>, except the daily data has been updated to include years through 2019. The R code is available at the end of the previous post.</p> </div> <div class="section" id="results"> <h1>Results</h1> <div class="section" id="race-day-weather"> <h2>Race day weather</h2> <p>Temperatures at the airport on race day ranged from 19.9&nbsp;°F in 1972 to 68&nbsp;°F in 1969, but the average range is between 34.4 and 53.0&nbsp;°F. Using our model of Ester Dome temperatures, we get an average range of 29.7 and 47.3&nbsp;°F and an overall min / max of 16.1 / 61.3&nbsp;°F up on the Dome. Generally speaking, it is below freezing on Ester Dome, but usually before most of the runners get up there.</p> <p>Precipitation (rain, sleet or snow) has fallen on 17 out of 57 race days, or 30% of the time, and measurable snowfall has been recorded on four of those seventeen. The highest amount fell in 2014 with 0.36 inches of liquid precipitation (no snow was recorded and the temperatures were between 45 and 51&nbsp;°F so it was almost certainly all rain, even on Ester Dome). More than a quarter of an inch of precipitation fell in three of the seventeen years when it rained or snowed (1990, 1993, and 2014), but most rainfall totals are much smaller.</p> <p>Measurable snow fell at the airport in four years, or seven percent of the time: 4.1&nbsp;inches in 1993, 2.1&nbsp;inches in 1985, 1.2&nbsp;inches in 1996, and 0.4&nbsp;inches in 1992. But that’s at the airport station. Five of the 13 years where measurable precipitation fell at the airport and no snow fell, had possible minimum temperatures on Ester Dome that were below freezing. It’s likely that some of the precipitation recorded at the airport in those years was coming down as snow up on Ester Dome. If so, that means snow may have fallen on nine race days, bringing the percentage up to sixteen percent.</p> <p>Wind data from the airport has only been recorded since 1984, but from those years the average wind speed at the airport on race day is 4.8&nbsp;miles per hour. The highest 2-minute wind speed during Equinox race day was 21&nbsp;miles per hour in 2003. Unfortunately, no wind data is available for Ester Dome, but it’s likely to be higher than what is recorded at the airport.</p> </div> <div class="section" id="weather-from-the-week-prior"> <h2>Weather from the week prior</h2> <p>It’s also useful to look at the weather from the week before the race, since excessive pre-race rain or snow can make conditions on race day very different, even if the race day weather is pleasant. The first year I ran the full marathon (2013), it snowed the week before and much of the trail in the woods before the water stop near Henderson and all of the out and back were covered in snow.</p> <p>The most dramatic example of this was 1992 where 23 inches (!) of snow fell at the airport in the week prior to the race, with much higher totals up on the summit of Ester Dome. Measurable snow has been recorded at the airport in the week prior to six races, but all the weekly totals are under an inch except for the snow year of 1992.</p> <p>Precipitation has fallen in 45 of 57 pre-race weeks (79% of the time). Three years have had more than an inch of precipitation prior to the race: 1.49&nbsp;inches in 2015, 1.26&nbsp;inches in 1992 (most of which fell as snow), and 1.05&nbsp;inches in 2007. On average, just over two tenths of an inch of precipitation falls in the week before the race.</p> </div> </div> <div class="section" id="summary"> <h1>Summary</h1> <p>The following stacked plots shows the weather for all 57 runnings of the Equinox marathon. The top panel shows the range of temperatures on race day from the airport station (wide bars) and estimated on Ester Dome (thin lines below bars). The shaded area at the bottom shows where temperatures are below freezing. The orange horizonal lines represent average high and low temperature in the valley (dashed lines) and on Ester Dome (solid orange lines).</p> <p>The middle panel shows race day liquid precipitation (rain, melted snow). Bars marked with an asterisk indicate years where snow was also recorded at the airport, but remember that five of the other years with liquid precipitation probably experienced snow on Ester Dome (1977, 1986, 1991, 1994, and 2016) because the temperatures were likely to be below freezing at elevation.</p> <p>The bottom panel shows precipitation totals from the week prior to the race. Bars marked with an asterisk indicate weeks where snow was also recorded at the airport.</p> <div class="figure"> <a class="reference external image-reference" href="//media.swingleydev.com/img/blog/2020/09/equinox_weather_thru_2019.pdf"><img alt="Equinox Marathon Weather" class="img-responsive" src="//media.swingleydev.com/img/blog/2020/09/equinox_weather_thru_2019.svgz" /></a> </div> <p>Here’s a table with most of the data from the analysis.</p> <table border="1" class="docutils"> <colgroup> <col width="17%" /> <col width="8%" /> <col width="8%" /> <col width="13%" /> <col width="13%" /> <col width="7%" /> <col width="7%" /> <col width="7%" /> <col width="10%" /> <col width="10%" /> </colgroup> <thead valign="bottom"> <tr><th class="head">Date</th> <th class="head">min t</th> <th class="head">max t</th> <th class="head">ED min t</th> <th class="head">ED max t</th> <th class="head">awnd</th> <th class="head">prcp</th> <th class="head">snow</th> <th class="head">p prcp</th> <th class="head">p snow</th> </tr> </thead> <tbody valign="top"> <tr><td>1963-09-21</td> <td>32.0</td> <td>54.0</td> <td>27.5</td> <td>48.2</td> <td>&nbsp;</td> <td>0.00</td> <td>0.0</td> <td>0.01</td> <td>0.0</td> </tr> <tr><td>1964-09-19</td> <td>34.0</td> <td>57.9</td> <td>29.4</td> <td>51.8</td> <td>&nbsp;</td> <td>0.00</td> <td>0.0</td> <td>0.03</td> <td>0.0</td> </tr> <tr><td>1965-09-25</td> <td>37.9</td> <td>60.1</td> <td>33.1</td> <td>53.9</td> <td>&nbsp;</td> <td>0.00</td> <td>0.0</td> <td>0.80</td> <td>0.0</td> </tr> <tr><td>1966-09-24</td> <td>36.0</td> <td>62.1</td> <td>31.3</td> <td>55.8</td> <td>&nbsp;</td> <td>0.00</td> <td>0.0</td> <td>0.01</td> <td>0.0</td> </tr> <tr><td>1967-09-23</td> <td>35.1</td> <td>57.9</td> <td>30.4</td> <td>51.8</td> <td>&nbsp;</td> <td>0.00</td> <td>0.0</td> <td>0.00</td> <td>0.0</td> </tr> <tr><td>1968-09-21</td> <td>23.0</td> <td>44.1</td> <td>19.1</td> <td>38.9</td> <td>&nbsp;</td> <td>0.00</td> <td>0.0</td> <td>0.04</td> <td>0.0</td> </tr> <tr><td>1969-09-20</td> <td>35.1</td> <td>68.0</td> <td>30.4</td> <td>61.3</td> <td>&nbsp;</td> <td>0.00</td> <td>0.0</td> <td>0.00</td> <td>0.0</td> </tr> <tr><td>1970-09-19</td> <td>24.1</td> <td>39.9</td> <td>20.1</td> <td>34.9</td> <td>&nbsp;</td> <td>0.00</td> <td>0.0</td> <td>0.42</td> <td>0.0</td> </tr> <tr><td>1971-09-18</td> <td>35.1</td> <td>55.9</td> <td>30.4</td> <td>50.0</td> <td>&nbsp;</td> <td>0.00</td> <td>0.0</td> <td>0.14</td> <td>0.0</td> </tr> <tr><td>1972-09-23</td> <td>19.9</td> <td>42.1</td> <td>16.1</td> <td>37.0</td> <td>&nbsp;</td> <td>0.00</td> <td>0.0</td> <td>0.01</td> <td>0.2</td> </tr> <tr><td>1973-09-22</td> <td>30.0</td> <td>44.1</td> <td>25.6</td> <td>38.9</td> <td>&nbsp;</td> <td>0.00</td> <td>0.0</td> <td>0.05</td> <td>0.0</td> </tr> <tr><td>1974-09-21</td> <td>48.0</td> <td>60.1</td> <td>42.5</td> <td>53.9</td> <td>&nbsp;</td> <td>0.08</td> <td>0.0</td> <td>0.00</td> <td>0.0</td> </tr> <tr><td>1975-09-20</td> <td>37.9</td> <td>55.9</td> <td>33.1</td> <td>50.0</td> <td>&nbsp;</td> <td>0.02</td> <td>0.0</td> <td>0.02</td> <td>0.0</td> </tr> <tr><td>1976-09-18</td> <td>34.0</td> <td>59.0</td> <td>29.4</td> <td>52.9</td> <td>&nbsp;</td> <td>0.00</td> <td>0.0</td> <td>0.54</td> <td>0.0</td> </tr> <tr><td>1977-09-24</td> <td>36.0</td> <td>48.9</td> <td>31.3</td> <td>43.4</td> <td>&nbsp;</td> <td>0.06</td> <td>0.0</td> <td>0.20</td> <td>0.0</td> </tr> <tr><td>1978-09-23</td> <td>30.0</td> <td>42.1</td> <td>25.6</td> <td>37.0</td> <td>&nbsp;</td> <td>0.00</td> <td>0.0</td> <td>0.10</td> <td>0.3</td> </tr> <tr><td>1979-09-22</td> <td>35.1</td> <td>62.1</td> <td>30.4</td> <td>55.8</td> <td>&nbsp;</td> <td>0.00</td> <td>0.0</td> <td>0.17</td> <td>0.0</td> </tr> <tr><td>1980-09-20</td> <td>30.9</td> <td>43.0</td> <td>26.5</td> <td>37.8</td> <td>&nbsp;</td> <td>0.00</td> <td>0.0</td> <td>0.35</td> <td>0.0</td> </tr> <tr><td>1981-09-19</td> <td>37.0</td> <td>43.0</td> <td>32.2</td> <td>37.8</td> <td>&nbsp;</td> <td>0.15</td> <td>0.0</td> <td>0.04</td> <td>0.0</td> </tr> <tr><td>1982-09-18</td> <td>42.1</td> <td>61.0</td> <td>37.0</td> <td>54.8</td> <td>&nbsp;</td> <td>0.02</td> <td>0.0</td> <td>0.22</td> <td>0.0</td> </tr> <tr><td>1983-09-17</td> <td>39.9</td> <td>46.9</td> <td>34.9</td> <td>41.5</td> <td>&nbsp;</td> <td>0.00</td> <td>0.0</td> <td>0.05</td> <td>0.0</td> </tr> <tr><td>1984-09-22</td> <td>28.9</td> <td>60.1</td> <td>24.6</td> <td>53.9</td> <td>5.8</td> <td>0.00</td> <td>0.0</td> <td>0.08</td> <td>0.0</td> </tr> <tr><td>1985-09-21</td> <td>30.9</td> <td>42.1</td> <td>26.5</td> <td>37.0</td> <td>6.5</td> <td>0.14</td> <td>2.1</td> <td>0.57</td> <td>0.0</td> </tr> <tr><td>1986-09-20</td> <td>36.0</td> <td>52.0</td> <td>31.3</td> <td>46.3</td> <td>8.3</td> <td>0.07</td> <td>0.0</td> <td>0.21</td> <td>0.0</td> </tr> <tr><td>1987-09-19</td> <td>37.9</td> <td>61.0</td> <td>33.1</td> <td>54.8</td> <td>6.3</td> <td>0.00</td> <td>0.0</td> <td>0.00</td> <td>0.0</td> </tr> <tr><td>1988-09-24</td> <td>37.0</td> <td>45.0</td> <td>32.2</td> <td>39.7</td> <td>4.0</td> <td>0.00</td> <td>0.0</td> <td>0.11</td> <td>0.0</td> </tr> <tr><td>1989-09-23</td> <td>36.0</td> <td>61.0</td> <td>31.3</td> <td>54.8</td> <td>8.5</td> <td>0.00</td> <td>0.0</td> <td>0.07</td> <td>0.5</td> </tr> <tr><td>1990-09-22</td> <td>37.9</td> <td>50.0</td> <td>33.1</td> <td>44.4</td> <td>7.8</td> <td>0.26</td> <td>0.0</td> <td>0.00</td> <td>0.0</td> </tr> <tr><td>1991-09-21</td> <td>36.0</td> <td>57.0</td> <td>31.3</td> <td>51.0</td> <td>4.5</td> <td>0.04</td> <td>0.0</td> <td>0.03</td> <td>0.0</td> </tr> <tr><td>1992-09-19</td> <td>24.1</td> <td>33.1</td> <td>20.1</td> <td>28.5</td> <td>6.7</td> <td>0.01</td> <td>0.4</td> <td>1.26</td> <td>23.0</td> </tr> <tr><td>1993-09-18</td> <td>28.0</td> <td>37.0</td> <td>23.8</td> <td>32.2</td> <td>4.9</td> <td>0.29</td> <td>4.1</td> <td>0.37</td> <td>0.3</td> </tr> <tr><td>1994-09-24</td> <td>27.0</td> <td>51.1</td> <td>22.8</td> <td>45.5</td> <td>6.0</td> <td>0.02</td> <td>0.0</td> <td>0.08</td> <td>0.0</td> </tr> <tr><td>1995-09-23</td> <td>43.0</td> <td>66.9</td> <td>37.8</td> <td>60.3</td> <td>4.0</td> <td>0.00</td> <td>0.0</td> <td>0.00</td> <td>0.0</td> </tr> <tr><td>1996-09-21</td> <td>28.9</td> <td>37.9</td> <td>24.6</td> <td>33.1</td> <td>6.9</td> <td>0.06</td> <td>1.2</td> <td>0.26</td> <td>0.0</td> </tr> <tr><td>1997-09-20</td> <td>27.0</td> <td>55.0</td> <td>22.8</td> <td>49.1</td> <td>3.8</td> <td>0.00</td> <td>0.0</td> <td>0.03</td> <td>0.0</td> </tr> <tr><td>1998-09-19</td> <td>42.1</td> <td>60.1</td> <td>37.0</td> <td>53.9</td> <td>4.9</td> <td>0.00</td> <td>0.0</td> <td>0.37</td> <td>0.0</td> </tr> <tr><td>1999-09-18</td> <td>39.0</td> <td>64.9</td> <td>34.1</td> <td>58.4</td> <td>3.8</td> <td>0.00</td> <td>0.0</td> <td>0.26</td> <td>0.0</td> </tr> <tr><td>2000-09-16</td> <td>28.9</td> <td>50.0</td> <td>24.6</td> <td>44.4</td> <td>5.6</td> <td>0.00</td> <td>0.0</td> <td>0.30</td> <td>0.0</td> </tr> <tr><td>2001-09-22</td> <td>33.1</td> <td>57.0</td> <td>28.5</td> <td>51.0</td> <td>1.6</td> <td>0.00</td> <td>0.0</td> <td>0.00</td> <td>0.0</td> </tr> <tr><td>2002-09-21</td> <td>33.1</td> <td>48.9</td> <td>28.5</td> <td>43.4</td> <td>3.8</td> <td>0.00</td> <td>0.0</td> <td>0.03</td> <td>0.0</td> </tr> <tr><td>2003-09-20</td> <td>26.1</td> <td>46.0</td> <td>22.0</td> <td>40.7</td> <td>9.6</td> <td>0.00</td> <td>0.0</td> <td>0.00</td> <td>0.0</td> </tr> <tr><td>2004-09-18</td> <td>26.1</td> <td>48.0</td> <td>22.0</td> <td>42.5</td> <td>4.3</td> <td>0.00</td> <td>0.0</td> <td>0.25</td> <td>0.0</td> </tr> <tr><td>2005-09-17</td> <td>37.0</td> <td>63.0</td> <td>32.2</td> <td>56.6</td> <td>0.9</td> <td>0.00</td> <td>0.0</td> <td>0.09</td> <td>0.0</td> </tr> <tr><td>2006-09-16</td> <td>46.0</td> <td>64.0</td> <td>40.7</td> <td>57.6</td> <td>4.3</td> <td>0.00</td> <td>0.0</td> <td>0.00</td> <td>0.0</td> </tr> <tr><td>2007-09-22</td> <td>25.0</td> <td>45.0</td> <td>20.9</td> <td>39.7</td> <td>4.7</td> <td>0.00</td> <td>0.0</td> <td>1.05</td> <td>0.0</td> </tr> <tr><td>2008-09-20</td> <td>34.0</td> <td>51.1</td> <td>29.4</td> <td>45.5</td> <td>4.5</td> <td>0.00</td> <td>0.0</td> <td>0.08</td> <td>0.0</td> </tr> <tr><td>2009-09-19</td> <td>39.0</td> <td>50.0</td> <td>34.1</td> <td>44.4</td> <td>5.8</td> <td>0.00</td> <td>0.0</td> <td>0.25</td> <td>0.0</td> </tr> <tr><td>2010-09-18</td> <td>35.1</td> <td>64.9</td> <td>30.4</td> <td>58.4</td> <td>2.5</td> <td>0.00</td> <td>0.0</td> <td>0.00</td> <td>0.0</td> </tr> <tr><td>2011-09-17</td> <td>39.9</td> <td>57.9</td> <td>34.9</td> <td>51.8</td> <td>1.3</td> <td>0.00</td> <td>0.0</td> <td>0.44</td> <td>0.0</td> </tr> <tr><td>2012-09-22</td> <td>46.9</td> <td>66.9</td> <td>41.5</td> <td>60.3</td> <td>6.0</td> <td>0.00</td> <td>0.0</td> <td>0.33</td> <td>0.0</td> </tr> <tr><td>2013-09-21</td> <td>24.3</td> <td>44.1</td> <td>20.3</td> <td>38.9</td> <td>5.1</td> <td>0.00</td> <td>0.0</td> <td>0.13</td> <td>0.6</td> </tr> <tr><td>2014-09-20</td> <td>45.0</td> <td>51.1</td> <td>39.7</td> <td>45.5</td> <td>1.6</td> <td>0.36</td> <td>0.0</td> <td>0.00</td> <td>0.0</td> </tr> <tr><td>2015-09-19</td> <td>37.9</td> <td>44.1</td> <td>33.1</td> <td>38.9</td> <td>2.9</td> <td>0.01</td> <td>0.0</td> <td>1.49</td> <td>0.0</td> </tr> <tr><td>2016-09-17</td> <td>34.0</td> <td>57.9</td> <td>29.4</td> <td>51.8</td> <td>2.2</td> <td>0.01</td> <td>0.0</td> <td>0.61</td> <td>0.0</td> </tr> <tr><td>2017-09-16</td> <td>33.1</td> <td>66.0</td> <td>28.5</td> <td>59.5</td> <td>3.1</td> <td>0.00</td> <td>0.0</td> <td>0.02</td> <td>0.0</td> </tr> <tr><td>2018-09-15</td> <td>44.1</td> <td>60.1</td> <td>38.9</td> <td>53.9</td> <td>3.8</td> <td>0.00</td> <td>0.0</td> <td>0.00</td> <td>0.0</td> </tr> <tr><td>2019-09-21</td> <td>37.0</td> <td>45.0</td> <td>32.2</td> <td>39.7</td> <td>7.6</td> <td>0.13</td> <td>0.0</td> <td>0.40</td> <td>0.0</td> </tr> </tbody> </table> </div> </div> Sun, 13 Sep 2020 09:48:28 -0800 http://swingleydev.com/blog/p/2015/ Equinox Marathon R running weather Comparing between year Equinox Marathon results http://swingleydev.com/blog/p/2014/ <div class="document"> <div class="section" id="introduction"> <h1>Introduction</h1> <p>At the 57th running of the Equinox Marathon last weekend Aaron Fletcher broke Stan Justice’s 1985 course record, one of the oldest running records in Alaska sports. On the <a class="reference external" href="https://www.facebook.com/EquinoxMarathon/posts/2536394219739598?comment_id=2538264686219218&amp;reply_comment_id=2540131996032487">Equinox Marathon Facebook page</a> Stan and Matias Saari were discussing whether more favorable weather might have meant an even faster record-breaking effort. Stan writes:</p> <blockquote> Where is a statistician when you need one. Would be interesting to compare times of all 2018 runners with their 2019 times.</blockquote> <p>I’m not a statistician, but let’s take a look.</p> </div> <div class="section" id="results"> <h1>Results</h1> <p>We’ve got Equinox Marathon finish time data going back to 1997, so we’ll compare the finish times for all runners who competed in consecutive years, subtracting their current year finish times (in hours) from the previous year. By this metric, negative values indicate individuals who ran faster in the current year than the previous. For example, I completed the race in 4:40:05 in 2018, and finished in 4:33:42 this year. My “hours_delta” for 2019 is -0.106 hours, or 6 minutes, 23 seconds faster.</p> <p>Here’s the distribution of this statistic for 2019:</p> <div class="figure"> <a class="reference external image-reference" href="//media.swingleydev.com/img/blog/2019/09/twenty_nineteen_histogram.pdf"><img alt="//media.swingleydev.com/img/blog/2019/09/twenty_nineteen_histogram.svgz" class="img-responsive" src="//media.swingleydev.com/img/blog/2019/09/twenty_nineteen_histogram.svgz" /></a> </div> <p>There are several people who were dramatically faster (on the left side of the graph), but the overall picture shows that times in 2019 were slower than 2018. The dark cyan line is the median value, which is at 0.18 hours or 10 minutes, 35 seconds slower. There were 53 runners that ran the race faster in 2019 than 2018 (including me), and 115 who were slower. That’s a pretty dramatic difference.</p> <p>Here’s that relationship for all the years where we have data:</p> <div class="figure"> <a class="reference external image-reference" href="//media.swingleydev.com/img/blog/2019/09/slower_faster.pdf"><img alt="//media.swingleydev.com/img/blog/2019/09/slower_faster.svgz" class="img-responsive" src="//media.swingleydev.com/img/blog/2019/09/slower_faster.svgz" /></a> </div> <p>The orange bars are runners who ran that year’s Equinox faster than the previous year and the dark cyan bars are those who were slower. 2019 is dramatically different than most other years for how much slower most people ran. 2013 is another particularly slow year. Fast years include 2007, 2009, and last year.</p> <p>Here’s another way to look at the data. It shows the median number of minutes runners ran Equinox faster (negative numbers) or slower (positive) in consecutive years.</p> <div class="figure"> <a class="reference external image-reference" href="//media.swingleydev.com/img/blog/2019/09/median_diff_one_year.pdf"><img alt="//media.swingleydev.com/img/blog/2019/09/median_diff_one_year.svgz" class="img-responsive" src="//media.swingleydev.com/img/blog/2019/09/median_diff_one_year.svgz" /></a> </div> <p>You can see that finish times were dramatically slower in 2019, and much faster in 2018. Since this comparison is using paired comparisons between years, at least part of the reason 2019 seemed like such a slow race is that 2018 was a fast one.</p> </div> <div class="section" id="two-year-lag"> <h1>Two-year lag</h1> <p>Let’s see what happens if we use a two-year lag to calculate the differences. Instead of comparing the current year’s results with the previous year for individual runners that raced in both years, we’ll compare the current year with two years prior. For example runners that ran the race this year and in 2017.</p> <p>Here’s what the distribution looks like comparing 2019 and 2017 results from the same runner.</p> <div class="figure"> <a class="reference external image-reference" href="//media.swingleydev.com/img/blog/2019/09/two_year_histogram.pdf"><img alt="//media.swingleydev.com/img/blog/2019/09/two_year_histogram.svgz" class="img-responsive" src="//media.swingleydev.com/img/blog/2019/09/two_year_histogram.svgz" /></a> </div> <p>It’s a similar pattern, with the median values at 0.18 hours, indicating that runners were almost 10 minutes slower in 2019 when compared against their 2017 times. This strengthens the evidence that 2019 was a particularly difficult year to run the race.</p> <p>Median difference by year for all years of the two-year lag data:</p> <div class="figure"> <a class="reference external image-reference" href="//media.swingleydev.com/img/blog/2019/09/two_year_diffs.pdf"><img alt="//media.swingleydev.com/img/blog/2019/09/two_year_diffs.svgz" class="img-responsive" src="//media.swingleydev.com/img/blog/2019/09/two_year_diffs.svgz" /></a> </div> <p>Remember that the dark cyan bars are years with slower finish times and orange are faster. 2019 still comes out as an outlier, along with 2013. 2007 is the clear winner for fast times.</p> </div> <div class="section" id="all-pairwise-race-results"> <h1>All pairwise race results</h1> <p>If we can do one and two year lags, how about combining <em>all</em> the pairwise race results? At some point the comparison is no longer a good one because of the large time interval between races, so we will restrict the comparisons to six or fewer years between results. We’ll also remove the earliest years from the results because those years are likely biased by having fewer long lag results.</p> <p>Here’s the same plot showing difference times in minutes for all pairwise race results, six years and fewer.</p> <div class="figure"> <a class="reference external image-reference" href="//media.swingleydev.com/img/blog/2019/09/all_through_six_median_diff_minutes.pdf"><img alt="//media.swingleydev.com/img/blog/2019/09/all_through_six_median_diff_minutes.svgz" class="img-responsive" src="//media.swingleydev.com/img/blog/2019/09/all_through_six_median_diff_minutes.svgz" /></a> </div> <p>You can see that there’s a pretty strong bias toward slower times, which is likely due to people aging and their times getting slower. The conditions were good enough in 2007 that this aging effect was offset and people running in that race tended to do it faster than their earlier performances despite being older. Even so, 2019 still stands out as one of the most difficult races.</p> <p>Here’s the aging effect:</p> <pre class="literal-block"> ## ## Call: ## lm(formula = hours_delta ~ years_delta, data = all_through_six) ## ## Residuals: ## Min 1Q Median 3Q Max ## -6.3242 -0.3639 -0.0415 0.3115 6.4441 ## ## Coefficients: ## Estimate Std. Error t value Pr(&gt;|t|) ## (Intercept) -0.03390 0.01934 -1.752 0.0797 . ## years_delta 0.05152 0.00558 9.234 &lt;0.0000000000000002 *** ## --- ## Signif. codes: 0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1 ## ## Residual standard error: 0.8845 on 8664 degrees of freedom ## Multiple R-squared: 0.009745, Adjusted R-squared: 0.00963 ## F-statistic: 85.26 on 1 and 8664 DF, p-value: &lt; 0.00000000000000022 </pre> <p>There’s a very significant positive relationship between the difference in years and the difference in marathon times for those runners (<tt class="docutils literal">years_delta</tt> in the coefficient results above). The longer the gap between races, the slower a runner is by just over 3 minutes each year. Notice, however, that the noise in the data is so great that this model, no matter how significant the coefficients, explains almost none of the variation in the difference in marathon times (dismally small <tt class="docutils literal"><span class="pre">R-squared</span></tt> values).</p> </div> <div class="section" id="weather"> <h1>Weather</h1> <p>The conditions in this year’s race were particularly harsh with a fairly constant 40 °F temperature and light rain falling at valley level; and below freezing temperatures, high winds, and snow falling up on Ester Dome. The trail was muddy, soft, and slippery in places, especially the single track and the on the unpaved section of Henderson Road. Compare this with last year when the weather was gorgeous: dry, sunny, and temperatures ranging from 39—60 °F.</p> <p>We took a look at the differences in weather between years to see if there is a relationship between weather differences and finish time differences, but none of the models we tried were any good at predicting differences in finish times, probably because of the huge variation in finish times that had nothing to do with the weather. There are too many other factors contributing to an individual’s performance from one year to the next to be able to pull out just the effects of weather on the results.</p> </div> <div class="section" id="conclusion"> <h1>Conclusion</h1> <p>2019 was a very slow year when we compared runners who completed Equinox in 2019 and earlier years. In fact, there’s some evidence that it’s the slowest year of all the years considered here (1997—2019). We could find no statistical evidence to show that weather was the cause of this, but anyone who was out there on race day this year knows it played a part in their finish times. I ran the race this year and last and managed to improve on my time despite the conditions, but I don’t think there’s any question that I would have improved my time even more had it been warm and sunny instead of cold, windy, and wet. Congratulations to all the competitors in this year’s race. It was a fun, but challenging year for Equinox.</p> <!-- vim: set ft=rmd fenc=utf-8 tw=80 ts=4 sw=4 sts=4: --></div> </div> Sat, 28 Sep 2019 18:46:12 -0800 http://swingleydev.com/blog/p/2014/ Equinox Marathon R running Equinox Marathon Weather, 2019 update http://swingleydev.com/blog/p/2013/ <div class="document"> <div class="section" id="introduction"> <h1>Introduction</h1> <p>A couple years ago I wrote a post about past <a class="reference external" href="https://swingleydev.com/blog/p/1999/">Equinox Marathon weather</a>. Since that post Andrea and I have run the relay twice, and I ran the full marathon. This post updates the statistics and plots to include two more years of the race.</p> </div> <div class="section" id="methods"> <h1>Methods</h1> <p>Methods and data are the same as in my previous <a class="reference external" href="https://swingleydev.com/blog/p/1999/">post</a>, except the daily data has been updated to include 2018. The R code is available at the end of the previous post.</p> </div> <div class="section" id="results"> <h1>Results</h1> <div class="section" id="race-day-weather"> <h2>Race day weather</h2> <p>Temperatures at the airport on race day ranged from 19.9&nbsp;°F in 1972 to 35.1&nbsp;°F in 1969, but the average range is between 34.3 and 53.2&nbsp;°F. Using our model of Ester Dome temperatures, we get an average range of 29.7 and 47.4&nbsp;°F and an overall min / max of 16.1 / 61.3&nbsp;°F. Generally speaking, it will be below freezing on Ester Dome, but possibly before most of the runners get up there.</p> <p>Precipitation (rain, sleet or snow) has fallen on 16 out of 56 race days, or 29% of the time, and measurable snowfall has been recorded on four of those sixteen. The highest amount fell in 2014 with 0.36 inches of liquid precipitation (no snow was recorded and the temperatures were between 45 and 51&nbsp;°F so it was almost certainly all rain, even on Ester Dome). More than a quarter of an inch of precipitation fell in three of the sixteen years when it rained or snowed (1990, 1993, and 2014), but most rainfall totals are much smaller.</p> <p>Measurable snow fell at the airport in four years, or seven percent of the time: 4.1&nbsp;inches in 1993, 2.1&nbsp;inches in 1985, 1.2&nbsp;inches in 1996, and 0.4&nbsp;inches in 1992. But that’s at the airport station. Five of the 12 years where measurable precipitation fell at the airport and no snow fell, had possible minimum temperatures on Ester Dome that were below freezing. It’s likely that some of the precipitation recorded at the airport in those years was coming down as snow up on Ester Dome. If so, that means snow may have fallen on nine race days, bringing the percentage up to sixteen percent.</p> <p>Wind data from the airport has only been recorded since 1984, but from those years the average wind speed at the airport on race day is 4.8&nbsp;miles per hour. The highest 2-minute wind speed during Equinox race day was 21&nbsp;miles per hour in 2003. Unfortunately, no wind data is available for Ester Dome, but it’s likely to be higher than what is recorded at the airport.</p> </div> <div class="section" id="weather-from-the-week-prior"> <h2>Weather from the week prior</h2> <p>It’s also useful to look at the weather from the week before the race, since excessive pre-race rain or snow can make conditions on race day very different, even if the race day weather is pleasant. The year I ran the full marathon (2013), it snowed the week before and much of the trail in the woods before the water stop near Henderson and all of the out and back were covered in snow.</p> <p>The most dramatic example of this was 1992 where 23 inches (!) of snow fell at the airport in the week prior to the race, with much higher totals up on the summit of Ester Dome. Measurable snow has been recorded at the airport in the week prior to six races, but all the weekly totals are under an inch except for the snow year of 1992.</p> <p>Precipitation has fallen in 44 of 56 pre-race weeks (79% of the time). Three years have had more than an inch of precipitation prior to the race: 1.49&nbsp;inches in 2015, 1.26&nbsp;inches in 1992 (most of which fell as snow), and 1.05&nbsp;inches in 2007. On average, just over two tenths of an inch of precipitation falls in the week before the race.</p> </div> </div> <div class="section" id="summary"> <h1>Summary</h1> <p>The following stacked plots shows the weather for all 56 runnings of the Equinox marathon. The top panel shows the range of temperatures on race day from the airport station (wide bars) and estimated on Ester Dome (thin lines below bars). The shaded area at the bottom shows where temperatures are below freezing.</p> <p>The middle panel shows race day liquid precipitation (rain, melted snow). Bars marked with an asterisk indicate years where snow was also recorded at the airport, but remember that five of the other years with liquid precipitation probably experienced snow on Ester Dome (1977, 1986, 1991, 1994, and 2016) because the temperatures were likely to be below freezing at elevation.</p> <p>The bottom panel shows precipitation totals from the week prior to the race. Bars marked with an asterisk indicate weeks where snow was also recorded at the airport.</p> <div class="figure"> <a class="reference external image-reference" href="//media.swingleydev.com/img/blog/2019/09/equinox_weather_thru_2018.pdf"><img alt="Equinox Marathon Weather" class="img-responsive" src="//media.swingleydev.com/img/blog/2019/09/equinox_weather_thru_2018.svgz" /></a> </div> <p>Here’s a table with most of the data from the analysis. A CSV with this data can be downloaded from <a class="reference external" href="//media.swingleydev.com/img/blog/2019/09/all_wx.csv">all_wx.csv</a></p> <table border="1" class="docutils"> <colgroup> <col width="17%" /> <col width="8%" /> <col width="8%" /> <col width="13%" /> <col width="13%" /> <col width="7%" /> <col width="7%" /> <col width="7%" /> <col width="10%" /> <col width="10%" /> </colgroup> <thead valign="bottom"> <tr><th class="head">Date</th> <th class="head">min t</th> <th class="head">max t</th> <th class="head">ED min t</th> <th class="head">ED max t</th> <th class="head">awnd</th> <th class="head">prcp</th> <th class="head">snow</th> <th class="head">p prcp</th> <th class="head">p snow</th> </tr> </thead> <tbody valign="top"> <tr><td>1963-09-21</td> <td>32.0</td> <td>54.0</td> <td>27.5</td> <td>48.2</td> <td>&nbsp;</td> <td>0.00</td> <td>0.0</td> <td>0.01</td> <td>0.0</td> </tr> <tr><td>1964-09-19</td> <td>34.0</td> <td>57.9</td> <td>29.4</td> <td>51.8</td> <td>&nbsp;</td> <td>0.00</td> <td>0.0</td> <td>0.03</td> <td>0.0</td> </tr> <tr><td>1965-09-25</td> <td>37.9</td> <td>60.1</td> <td>33.1</td> <td>53.9</td> <td>&nbsp;</td> <td>0.00</td> <td>0.0</td> <td>0.80</td> <td>0.0</td> </tr> <tr><td>1966-09-24</td> <td>36.0</td> <td>62.1</td> <td>31.3</td> <td>55.8</td> <td>&nbsp;</td> <td>0.00</td> <td>0.0</td> <td>0.01</td> <td>0.0</td> </tr> <tr><td>1967-09-23</td> <td>35.1</td> <td>57.9</td> <td>30.4</td> <td>51.8</td> <td>&nbsp;</td> <td>0.00</td> <td>0.0</td> <td>0.00</td> <td>0.0</td> </tr> <tr><td>1968-09-21</td> <td>23.0</td> <td>44.1</td> <td>19.1</td> <td>38.9</td> <td>&nbsp;</td> <td>0.00</td> <td>0.0</td> <td>0.04</td> <td>0.0</td> </tr> <tr><td>1969-09-20</td> <td>35.1</td> <td>68.0</td> <td>30.4</td> <td>61.3</td> <td>&nbsp;</td> <td>0.00</td> <td>0.0</td> <td>0.00</td> <td>0.0</td> </tr> <tr><td>1970-09-19</td> <td>24.1</td> <td>39.9</td> <td>20.1</td> <td>34.9</td> <td>&nbsp;</td> <td>0.00</td> <td>0.0</td> <td>0.42</td> <td>0.0</td> </tr> <tr><td>1971-09-18</td> <td>35.1</td> <td>55.9</td> <td>30.4</td> <td>50.0</td> <td>&nbsp;</td> <td>0.00</td> <td>0.0</td> <td>0.14</td> <td>0.0</td> </tr> <tr><td>1972-09-23</td> <td>19.9</td> <td>42.1</td> <td>16.1</td> <td>37.0</td> <td>&nbsp;</td> <td>0.00</td> <td>0.0</td> <td>0.01</td> <td>0.2</td> </tr> <tr><td>1973-09-22</td> <td>30.0</td> <td>44.1</td> <td>25.6</td> <td>38.9</td> <td>&nbsp;</td> <td>0.00</td> <td>0.0</td> <td>0.05</td> <td>0.0</td> </tr> <tr><td>1974-09-21</td> <td>48.0</td> <td>60.1</td> <td>42.5</td> <td>53.9</td> <td>&nbsp;</td> <td>0.08</td> <td>0.0</td> <td>0.00</td> <td>0.0</td> </tr> <tr><td>1975-09-20</td> <td>37.9</td> <td>55.9</td> <td>33.1</td> <td>50.0</td> <td>&nbsp;</td> <td>0.02</td> <td>0.0</td> <td>0.02</td> <td>0.0</td> </tr> <tr><td>1976-09-18</td> <td>34.0</td> <td>59.0</td> <td>29.4</td> <td>52.9</td> <td>&nbsp;</td> <td>0.00</td> <td>0.0</td> <td>0.54</td> <td>0.0</td> </tr> <tr><td>1977-09-24</td> <td>36.0</td> <td>48.9</td> <td>31.3</td> <td>43.4</td> <td>&nbsp;</td> <td>0.06</td> <td>0.0</td> <td>0.20</td> <td>0.0</td> </tr> <tr><td>1978-09-23</td> <td>30.0</td> <td>42.1</td> <td>25.6</td> <td>37.0</td> <td>&nbsp;</td> <td>0.00</td> <td>0.0</td> <td>0.10</td> <td>0.3</td> </tr> <tr><td>1979-09-22</td> <td>35.1</td> <td>62.1</td> <td>30.4</td> <td>55.8</td> <td>&nbsp;</td> <td>0.00</td> <td>0.0</td> <td>0.17</td> <td>0.0</td> </tr> <tr><td>1980-09-20</td> <td>30.9</td> <td>43.0</td> <td>26.5</td> <td>37.8</td> <td>&nbsp;</td> <td>0.00</td> <td>0.0</td> <td>0.35</td> <td>0.0</td> </tr> <tr><td>1981-09-19</td> <td>37.0</td> <td>43.0</td> <td>32.2</td> <td>37.8</td> <td>&nbsp;</td> <td>0.15</td> <td>0.0</td> <td>0.04</td> <td>0.0</td> </tr> <tr><td>1982-09-18</td> <td>42.1</td> <td>61.0</td> <td>37.0</td> <td>54.8</td> <td>&nbsp;</td> <td>0.02</td> <td>0.0</td> <td>0.22</td> <td>0.0</td> </tr> <tr><td>1983-09-17</td> <td>39.9</td> <td>46.9</td> <td>34.9</td> <td>41.5</td> <td>&nbsp;</td> <td>0.00</td> <td>0.0</td> <td>0.05</td> <td>0.0</td> </tr> <tr><td>1984-09-22</td> <td>28.9</td> <td>60.1</td> <td>24.6</td> <td>53.9</td> <td>5.8</td> <td>0.00</td> <td>0.0</td> <td>0.08</td> <td>0.0</td> </tr> <tr><td>1985-09-21</td> <td>30.9</td> <td>42.1</td> <td>26.5</td> <td>37.0</td> <td>6.5</td> <td>0.14</td> <td>2.1</td> <td>0.57</td> <td>0.0</td> </tr> <tr><td>1986-09-20</td> <td>36.0</td> <td>52.0</td> <td>31.3</td> <td>46.3</td> <td>8.3</td> <td>0.07</td> <td>0.0</td> <td>0.21</td> <td>0.0</td> </tr> <tr><td>1987-09-19</td> <td>37.9</td> <td>61.0</td> <td>33.1</td> <td>54.8</td> <td>6.3</td> <td>0.00</td> <td>0.0</td> <td>0.00</td> <td>0.0</td> </tr> <tr><td>1988-09-24</td> <td>37.0</td> <td>45.0</td> <td>32.2</td> <td>39.7</td> <td>4.0</td> <td>0.00</td> <td>0.0</td> <td>0.11</td> <td>0.0</td> </tr> <tr><td>1989-09-23</td> <td>36.0</td> <td>61.0</td> <td>31.3</td> <td>54.8</td> <td>8.5</td> <td>0.00</td> <td>0.0</td> <td>0.07</td> <td>0.5</td> </tr> <tr><td>1990-09-22</td> <td>37.9</td> <td>50.0</td> <td>33.1</td> <td>44.4</td> <td>7.8</td> <td>0.26</td> <td>0.0</td> <td>0.00</td> <td>0.0</td> </tr> <tr><td>1991-09-21</td> <td>36.0</td> <td>57.0</td> <td>31.3</td> <td>51.0</td> <td>4.5</td> <td>0.04</td> <td>0.0</td> <td>0.03</td> <td>0.0</td> </tr> <tr><td>1992-09-19</td> <td>24.1</td> <td>33.1</td> <td>20.1</td> <td>28.5</td> <td>6.7</td> <td>0.01</td> <td>0.4</td> <td>1.26</td> <td>23.0</td> </tr> <tr><td>1993-09-18</td> <td>28.0</td> <td>37.0</td> <td>23.8</td> <td>32.2</td> <td>4.9</td> <td>0.29</td> <td>4.1</td> <td>0.37</td> <td>0.3</td> </tr> <tr><td>1994-09-24</td> <td>27.0</td> <td>51.1</td> <td>22.8</td> <td>45.5</td> <td>6.0</td> <td>0.02</td> <td>0.0</td> <td>0.08</td> <td>0.0</td> </tr> <tr><td>1995-09-23</td> <td>43.0</td> <td>66.9</td> <td>37.8</td> <td>60.3</td> <td>4.0</td> <td>0.00</td> <td>0.0</td> <td>0.00</td> <td>0.0</td> </tr> <tr><td>1996-09-21</td> <td>28.9</td> <td>37.9</td> <td>24.6</td> <td>33.1</td> <td>6.9</td> <td>0.06</td> <td>1.2</td> <td>0.26</td> <td>0.0</td> </tr> <tr><td>1997-09-20</td> <td>27.0</td> <td>55.0</td> <td>22.8</td> <td>49.1</td> <td>3.8</td> <td>0.00</td> <td>0.0</td> <td>0.03</td> <td>0.0</td> </tr> <tr><td>1998-09-19</td> <td>42.1</td> <td>60.1</td> <td>37.0</td> <td>53.9</td> <td>4.9</td> <td>0.00</td> <td>0.0</td> <td>0.37</td> <td>0.0</td> </tr> <tr><td>1999-09-18</td> <td>39.0</td> <td>64.9</td> <td>34.1</td> <td>58.4</td> <td>3.8</td> <td>0.00</td> <td>0.0</td> <td>0.26</td> <td>0.0</td> </tr> <tr><td>2000-09-16</td> <td>28.9</td> <td>50.0</td> <td>24.6</td> <td>44.4</td> <td>5.6</td> <td>0.00</td> <td>0.0</td> <td>0.30</td> <td>0.0</td> </tr> <tr><td>2001-09-22</td> <td>33.1</td> <td>57.0</td> <td>28.5</td> <td>51.0</td> <td>1.6</td> <td>0.00</td> <td>0.0</td> <td>0.00</td> <td>0.0</td> </tr> <tr><td>2002-09-21</td> <td>33.1</td> <td>48.9</td> <td>28.5</td> <td>43.4</td> <td>3.8</td> <td>0.00</td> <td>0.0</td> <td>0.03</td> <td>0.0</td> </tr> <tr><td>2003-09-20</td> <td>26.1</td> <td>46.0</td> <td>22.0</td> <td>40.7</td> <td>9.6</td> <td>0.00</td> <td>0.0</td> <td>0.00</td> <td>0.0</td> </tr> <tr><td>2004-09-18</td> <td>26.1</td> <td>48.0</td> <td>22.0</td> <td>42.5</td> <td>4.3</td> <td>0.00</td> <td>0.0</td> <td>0.25</td> <td>0.0</td> </tr> <tr><td>2005-09-17</td> <td>37.0</td> <td>63.0</td> <td>32.2</td> <td>56.6</td> <td>0.9</td> <td>0.00</td> <td>0.0</td> <td>0.09</td> <td>0.0</td> </tr> <tr><td>2006-09-16</td> <td>46.0</td> <td>64.0</td> <td>40.7</td> <td>57.6</td> <td>4.3</td> <td>0.00</td> <td>0.0</td> <td>0.00</td> <td>0.0</td> </tr> <tr><td>2007-09-22</td> <td>25.0</td> <td>45.0</td> <td>20.9</td> <td>39.7</td> <td>4.7</td> <td>0.00</td> <td>0.0</td> <td>1.05</td> <td>0.0</td> </tr> <tr><td>2008-09-20</td> <td>34.0</td> <td>51.1</td> <td>29.4</td> <td>45.5</td> <td>4.5</td> <td>0.00</td> <td>0.0</td> <td>0.08</td> <td>0.0</td> </tr> <tr><td>2009-09-19</td> <td>39.0</td> <td>50.0</td> <td>34.1</td> <td>44.4</td> <td>5.8</td> <td>0.00</td> <td>0.0</td> <td>0.25</td> <td>0.0</td> </tr> <tr><td>2010-09-18</td> <td>35.1</td> <td>64.9</td> <td>30.4</td> <td>58.4</td> <td>2.5</td> <td>0.00</td> <td>0.0</td> <td>0.00</td> <td>0.0</td> </tr> <tr><td>2011-09-17</td> <td>39.9</td> <td>57.9</td> <td>34.9</td> <td>51.8</td> <td>1.3</td> <td>0.00</td> <td>0.0</td> <td>0.44</td> <td>0.0</td> </tr> <tr><td>2012-09-22</td> <td>46.9</td> <td>66.9</td> <td>41.5</td> <td>60.3</td> <td>6.0</td> <td>0.00</td> <td>0.0</td> <td>0.33</td> <td>0.0</td> </tr> <tr><td>2013-09-21</td> <td>24.3</td> <td>44.1</td> <td>20.3</td> <td>38.9</td> <td>5.1</td> <td>0.00</td> <td>0.0</td> <td>0.13</td> <td>0.6</td> </tr> <tr><td>2014-09-20</td> <td>45.0</td> <td>51.1</td> <td>39.7</td> <td>45.5</td> <td>1.6</td> <td>0.36</td> <td>0.0</td> <td>0.00</td> <td>0.0</td> </tr> <tr><td>2015-09-19</td> <td>37.9</td> <td>44.1</td> <td>33.1</td> <td>38.9</td> <td>2.9</td> <td>0.01</td> <td>0.0</td> <td>1.49</td> <td>0.0</td> </tr> <tr><td>2016-09-17</td> <td>34.0</td> <td>57.9</td> <td>29.4</td> <td>51.8</td> <td>2.2</td> <td>0.01</td> <td>0.0</td> <td>0.61</td> <td>0.0</td> </tr> <tr><td>2017-09-16</td> <td>33.1</td> <td>66.0</td> <td>28.5</td> <td>59.5</td> <td>3.1</td> <td>0.00</td> <td>0.0</td> <td>0.02</td> <td>0.0</td> </tr> <tr><td>2018-09-15</td> <td>44.1</td> <td>60.1</td> <td>38.9</td> <td>53.9</td> <td>3.8</td> <td>0.00</td> <td>0.0</td> <td>0.00</td> <td>0.0</td> </tr> </tbody> </table> </div> </div> Wed, 18 Sep 2019 13:14:09 -0800 http://swingleydev.com/blog/p/2013/ Equinox Marathon R running weather Tallys, 2009—2019 http://swingleydev.com/blog/p/2012/ <div class="document"> <div class="figure align-right"> <a class="reference external image-reference" href="//media.swingleydev.com/img/photolog/2012/03/tallys_pick_me_up.jpg"><img alt="Pick me up!" src="//media.swingleydev.com/img/blog/2019/08/tallys_pick_me_up_300.jpg" style="width: 300px; height: 300px;" /></a> <p class="caption">Pick me up!</p> </div> <p>Tallys died today after a short fight with an unknown disease. We got him and his two brothers from a shelter foster litter and as soon as we met him as a tiny kitten, we knew he was one of the kittens we wanted to adopt. He was the smallest kitten in the litter, was extremely friendly and very snuggly, and he remained that way for his short life. He would spend all night curled up at my feet, or under the covers with Andrea, and in the morning he’d come downstairs and ask to be picked up while I made breakfast. He loved to be up on my shoulders, purring and kneading, and occasionally scolding me if I wasn’t petting him enough. He played with my feet under the covers, and would bring cat toys downstairs during the day while we were at work and the dogs were outside. He also made friends with all the dogs, and especially Monte, who would come in the house and bark until his friend Tallys came down to nuzzle him and play.</p> <p>He also loved heat, so he was always the cat baking himself in the direct sun in the window, and especially liked winter because of the heat the wood stove put out. He’d lay in front of it (or sometimes directly under it) and his fur would get hot enough it seemed like he should be melting. And when the wood stove wasn’t cranking he’d flop down in front of our Toyo and soak up as much heat as he could.</p> <p>He is survived by his brothers, Jenson and Caslon, and his two sisters living in another home in Fairbanks. Tallys, Jenson, and Caslon all got along at our house, sleeping in a ball on the bed, or chasing each other around. Tallys and Caslon would often sit opposite each other and lazily swat at each other until someone got in a good punch and they’d go bolting after each other.</p> <p>He was a super sweet little cat, and our time with him was too short, but in those years he was a constant bright spot in our lives. We will miss him.</p> <div class="figure align-center"> <a class="reference external image-reference" href="//media.swingleydev.com/img/photolog/2018/10/monte_and_tallys_enjoying_the_wood_stove_2018-10.jpg"><img alt="Monte and Tallys enjoing the wood stove" src="//media.swingleydev.com/img/photolog/2018/10/monte_and_tallys_enjoying_the_wood_stove_2018-10_600.jpg" /></a> <p class="caption">Monte and Tallys enjoying the wood stove</p> </div> <div class="figure align-center"> <a class="reference external image-reference" href="//media.swingleydev.com/img/photolog/2018/06/tallys_bug_hunting_2018-06.jpg"><img alt="Tallys bug hunting" src="//media.swingleydev.com/img/photolog/2018/06/tallys_bug_hunting_2018-06_600.jpg" /></a> <p class="caption">Tallys bug hunting</p> </div> <div class="figure align-center"> <a class="reference external image-reference" href="//media.swingleydev.com/img/photolog/2019/05/tallys_enjoying_the_view_out_the_west_window_2019-05.jpg"><img alt="Tallys bug hunting" src="//media.swingleydev.com/img/photolog/2019/05/tallys_enjoying_the_view_out_the_west_window_2019-05_600.jpg" /></a> <p class="caption">Tallys looking out the window</p> </div> </div> Thu, 29 Aug 2019 17:43:15 -0800 http://swingleydev.com/blog/p/2012/ memorial Tallys Predicting Snow Depth http://swingleydev.com/blog/p/2011/ <div class="document"> <div class="section" id="introduction"> <h1>Introduction</h1> <p>It’s November 10th in Fairbanks and we have only an inch of snow on the ground. The average depth on this date is 6.1 inches, but that a little deceptive because snow depth doesn’t follow a normal distribution; it can never be below zero, and has a long tail toward deeper snow depths. In the 92 years of snow depth data for the Fairbanks Airport, we’ve had less than an inch of snow only six times (6.5%). At the other end of the distribution, there have been seven years with more than 14 inches of snow on November 10th.</p> <p>My question is: what does snow depth on November 10th tell us about how much snow we are going to get later on in the winter? Is there a relationship between depth on November 10th and depths later in the winter, and if there is, how much snow can we expect this winter?</p> </div> <div class="section" id="data"> <h1>Data</h1> <p>We’ll use the 92-year record of snow depth data from the Fairbanks International Airport station that’s in the <a class="reference external" href="https://www.ncdc.noaa.gov/data-access/land-based-station-data/land-based-datasets/global-historical-climatology-network-ghcn">Global Historical Climate Network</a>.</p> <p>The correlation coefficients (a 1 means a perfect correlation, and a 0 is no correlation) between snow depth on November 10th, and the first of the months of December, January and February of that same winter are shown below:</p> <table border="1" class="docutils"> <colgroup> <col width="20%" /> <col width="20%" /> <col width="20%" /> <col width="20%" /> <col width="20%" /> </colgroup> <thead valign="bottom"> <tr><th class="head">&nbsp;</th> <th class="head">nov_10</th> <th class="head">dec_01</th> <th class="head">jan_01</th> <th class="head">feb_01</th> </tr> </thead> <tbody valign="top"> <tr><td>nov_10</td> <td>1.00</td> <td>0.65</td> <td>0.49</td> <td>0.46</td> </tr> <tr><td>dec_01</td> <td>0.65</td> <td>1.00</td> <td>0.60</td> <td>0.39</td> </tr> <tr><td>jan_01</td> <td>0.49</td> <td>0.60</td> <td>1.00</td> <td>0.74</td> </tr> <tr><td>feb_01</td> <td>0.46</td> <td>0.39</td> <td>0.74</td> <td>1.00</td> </tr> </tbody> </table> <p>Looking down the <tt class="docutils literal">nov_10</tt> column, you can see a high correlation between snow depth on November 10th and depth on December 1st, but lower (and similar) correlations with depths in January and February.</p> <p>This makes sense. In Fairbanks, snow that falls after the second week in October is likely to be around for the rest of the winter, so all the snow on the ground on November 10th, will still be there in December, and throughout the winter.</p> <p>But what can a snow depth of one inch on November 10th tell us about how much snow we will have in December or later on?</p> <p>Here’s the data for those six years with a snow depth of 1 inch on November 10th:</p> <table border="1" class="docutils"> <colgroup> <col width="22%" /> <col width="26%" /> <col width="26%" /> <col width="26%" /> </colgroup> <thead valign="bottom"> <tr><th class="head">wyear</th> <th class="head">dec_01</th> <th class="head">jan_01</th> <th class="head">feb_01</th> </tr> </thead> <tbody valign="top"> <tr><td>1938</td> <td>5</td> <td>11</td> <td>24</td> </tr> <tr><td>1940</td> <td>6</td> <td>8</td> <td>9</td> </tr> <tr><td>1951</td> <td>12</td> <td>22</td> <td>31</td> </tr> <tr><td>1953</td> <td>1</td> <td>5</td> <td>17</td> </tr> <tr><td>1954</td> <td>9</td> <td>15</td> <td>12</td> </tr> <tr><td>1979</td> <td>3</td> <td>8</td> <td>14</td> </tr> </tbody> </table> <p>Not exactly encouraging data for our current situation, although 1951 gives us some hope of a good winter.</p> </div> <div class="section" id="methods"> <h1>Methods</h1> <p>We used Bayesian linear regression to predict snow depth on December 1st, January 1st and February 1st, based on our snow depth data and the current snow depth in Fairbanks. We used the <tt class="docutils literal">rstanarm</tt> R package, which mimics the <tt class="docutils literal">glm</tt> function that’s part of base R.</p> <p>Because of the non-zero, skewed nature of the distribution of snow depths, a log-linked Gamma distribution is appropriate. We used the <tt class="docutils literal">rstanarm</tt> defaults for priors.</p> <p>One of the great things about Bayesian linear regression is that it incorporates our uncertainty about the model coefficients to produce a distribution of predicted values. The more uncertainty there is in our model, the wider the range of predicted values. We examine the distribution of these predicted snow depth values and compare them with the distribution of actual values.</p> <p>The code for the analysis appears at the bottom of the post.</p> </div> <div class="section" id="results"> <h1>Results</h1> <p>The following figure shows a histogram and density function plot for the predicted snow depth on December 1st (top pane) for this year, and the actual December 1st snow depth data in past years (bottom).</p> <div class="figure"> <a class="reference external image-reference" href="//media.swingleydev.com/img/blog/2018/11/december_comparison.pdf"><img alt="December Snow Depth" class="img-responsive" src="//media.swingleydev.com/img/blog/2018/11/december_comparison.svgz" /></a> </div> <p>The predicted snow depth ranges from zero to almost 27 inches of snow, but the distribution is concentrated around 5 inches. The lower plot showing the distribution of actual snow depth on December 1st isn’t as smooth, but it has a similar shape and peaks at 9 inches.</p> <p>If we run the same analysis for January and February, we get a set of frequency distributions that look like the following plot, again with the predicted snow depth distribution on top and the distribution of actual data on the bottom.</p> <div class="figure"> <a class="reference external image-reference" href="//media.swingleydev.com/img/blog/2018/11/dec_jan_feb.pdf"><img alt="Snow Depth Distribution" class="img-responsive" src="//media.swingleydev.com/img/blog/2018/11/dec_jan_feb.svgz" /></a> </div> <p>The December densities are repeated here, in red, along with the January (green) and February (blue) results. In the top plot, you can clearly see that the shape of the distribution gets more spread out as we get farther from November, indicating our increasing uncertainty in our predictions, although some of that pattern is also from the source data (below), which also gets more spread out in January and February.</p> <p>Despite our increasing uncertainty, it’s clear from comparing the peaks in these curves that our models expect there to be less snow in December, January and February this year, compared with historical values. By my reckoning, we can expect around 5 inches on December 1st, 10 inches on January 1st, and 12 or 13 inches by February. In an average year, these values would be closer to 9, 12, and 15 inches.</p> </div> <div class="section" id="conclusion"> <h1>Conclusion</h1> <p>There is a relationship between snow depth on November 10th and depths later in the winter, but the distributions of predicted values are so spread out that we could easily receive as much or more snow as we have in previous years. Last year on this date we had 5 inches, on December 1st we had 11 inches, 13 inches on New Year’s Day, and 20 inches on February 1st. Here’s hoping we quickly reach, and surpass those values in 2018/2019.</p> </div> <div class="section" id="appendix"> <h1>Appendix</h1> <div class="highlight"><pre><span></span><span class="kn">library</span><span class="p">(</span>tidyverse<span class="p">)</span> <span class="kn">library</span><span class="p">(</span>glue<span class="p">)</span> <span class="kn">library</span><span class="p">(</span>ggpubr<span class="p">)</span> <span class="kn">library</span><span class="p">(</span>scales<span class="p">)</span> <span class="kn">library</span><span class="p">(</span>lubridate<span class="p">)</span> <span class="kn">library</span><span class="p">(</span>RPostgres<span class="p">)</span> <span class="kn">library</span><span class="p">(</span>rstanarm<span class="p">)</span> noaa <span class="o">&lt;-</span> dbConnect<span class="p">(</span>Postgres<span class="p">(),</span> dbname <span class="o">=</span> <span class="s">&quot;noaa&quot;</span><span class="p">)</span> ghcnd_stations <span class="o">&lt;-</span> noaa <span class="o">%&gt;%</span> tbl<span class="p">(</span><span class="s">&quot;ghcnd_stations&quot;</span><span class="p">)</span> <span class="o">%&gt;%</span> filter<span class="p">(</span>station_name <span class="o">==</span> <span class="s">&quot;FAIRBANKS INTL AP&quot;</span><span class="p">)</span> ghcnd_variables <span class="o">&lt;-</span> noaa <span class="o">%&gt;%</span> tbl<span class="p">(</span><span class="s">&quot;ghcnd_variables&quot;</span><span class="p">)</span> <span class="o">%&gt;%</span> filter<span class="p">(</span>variable <span class="o">==</span> <span class="s">&quot;SNWD&quot;</span><span class="p">)</span> ghcnd_obs <span class="o">&lt;-</span> noaa <span class="o">%&gt;%</span> tbl<span class="p">(</span><span class="s">&quot;ghcnd_obs&quot;</span><span class="p">)</span> <span class="o">%&gt;%</span> inner_join<span class="p">(</span>ghcnd_stations<span class="p">,</span> by <span class="o">=</span> <span class="s">&quot;station_id&quot;</span><span class="p">)</span> <span class="o">%&gt;%</span> inner_join<span class="p">(</span>ghcnd_variables<span class="p">,</span> by <span class="o">=</span> <span class="s">&quot;variable&quot;</span><span class="p">)</span> <span class="o">%&gt;%</span> mutate<span class="p">(</span>month <span class="o">=</span> date_part<span class="p">(</span><span class="s">&quot;month&quot;</span><span class="p">,</span> dte<span class="p">),</span> day <span class="o">=</span> date_part<span class="p">(</span><span class="s">&quot;day&quot;</span><span class="p">,</span> dte<span class="p">))</span> <span class="o">%&gt;%</span> filter<span class="p">((</span>month <span class="o">==</span> <span class="m">11</span> <span class="o">&amp;</span> day <span class="o">==</span> <span class="m">10</span><span class="p">)</span> <span class="o">|</span> <span class="p">(</span>month <span class="o">==</span> <span class="m">12</span> <span class="o">&amp;</span> day <span class="o">==</span> <span class="m">1</span><span class="p">)</span> <span class="o">|</span> <span class="p">(</span>month <span class="o">==</span> <span class="m">1</span> <span class="o">&amp;</span> day <span class="o">==</span> <span class="m">1</span><span class="p">)</span> <span class="o">|</span> <span class="p">(</span>month <span class="o">==</span> <span class="m">2</span> <span class="o">&amp;</span> day <span class="o">==</span> <span class="m">1</span><span class="p">),</span> <span class="kp">is.na</span><span class="p">(</span>meas_flag<span class="p">)</span> <span class="o">|</span> meas_flag <span class="o">==</span> <span class="s">&quot;&quot;</span><span class="p">)</span> <span class="o">%&gt;%</span> mutate<span class="p">(</span>value <span class="o">=</span> raw_value <span class="o">*</span> raw_multiplier<span class="p">)</span> <span class="o">%&gt;%</span> select<span class="p">(</span>dte<span class="p">,</span> month<span class="p">,</span> day<span class="p">,</span> variable<span class="p">,</span> value<span class="p">)</span> <span class="o">%&gt;%</span> collect<span class="p">()</span> snow_depths <span class="o">&lt;-</span> ghcnd_obs <span class="o">%&gt;%</span> mutate<span class="p">(</span>wyear <span class="o">=</span> year<span class="p">(</span>dte <span class="o">-</span> days<span class="p">(</span><span class="m">91</span><span class="p">)),</span> mmdd <span class="o">=</span> <span class="kp">factor</span><span class="p">(</span>glue<span class="p">(</span><span class="s">&quot;{str_to_lower(month.abb[month])}&quot;</span><span class="p">,</span> <span class="s">&quot;_{sprintf(&#39;%02d&#39;, day)}&quot;</span><span class="p">),</span> levels <span class="o">=</span> <span class="kt">c</span><span class="p">(</span><span class="s">&quot;nov_10&quot;</span><span class="p">,</span> <span class="s">&quot;dec_01&quot;</span><span class="p">,</span> <span class="s">&quot;jan_01&quot;</span><span class="p">,</span> <span class="s">&quot;feb_01&quot;</span><span class="p">)),</span> value <span class="o">=</span> value <span class="o">/</span> <span class="m">25.4</span><span class="p">)</span> <span class="o">%&gt;%</span> select<span class="p">(</span>wyear<span class="p">,</span> mmdd<span class="p">,</span> value<span class="p">)</span> <span class="o">%&gt;%</span> spread<span class="p">(</span>mmdd<span class="p">,</span> value<span class="p">)</span> <span class="o">%&gt;%</span> filter<span class="p">(</span><span class="o">!</span><span class="kp">is.na</span><span class="p">(</span>nov_10<span class="p">))</span> write_csv<span class="p">(</span>snow_depths<span class="p">,</span> <span class="s">&quot;snow_depths.csv&quot;</span><span class="p">,</span> na <span class="o">=</span> <span class="s">&quot;&quot;</span><span class="p">)</span> dec <span class="o">&lt;-</span> stan_glm<span class="p">(</span>dec_01 <span class="o">~</span> nov_10<span class="p">,</span> data <span class="o">=</span> snow_depths<span class="p">,</span> family <span class="o">=</span> Gamma<span class="p">(</span>link <span class="o">=</span> <span class="s">&quot;log&quot;</span><span class="p">),</span> <span class="c1"># prior = normal(0.7, 3),</span> <span class="c1"># prior_intercept = normal(1, 3),</span> iter <span class="o">=</span> <span class="m">5000</span><span class="p">)</span> <span class="c1"># What does the model day about 2018?</span> dec_prediction_mat <span class="o">&lt;-</span> posterior_predict<span class="p">(</span>dec<span class="p">,</span> newdata <span class="o">=</span> tibble<span class="p">(</span>nov_10 <span class="o">=</span> <span class="m">1</span><span class="p">))</span> dec_prediction <span class="o">&lt;-</span> tibble<span class="p">(</span>pred_dec_01 <span class="o">=</span> dec_prediction_mat<span class="p">[,</span><span class="m">1</span><span class="p">])</span> dec_hist <span class="o">&lt;-</span> ggplot<span class="p">(</span>data <span class="o">=</span> dec_prediction<span class="p">,</span> aes<span class="p">(</span>x <span class="o">=</span> pred_dec_01<span class="p">,</span> y <span class="o">=</span> <span class="m">..</span>density..<span class="p">))</span> <span class="o">+</span> theme_bw<span class="p">()</span> <span class="o">+</span> geom_histogram<span class="p">(</span>binwidth <span class="o">=</span> <span class="m">0.25</span><span class="p">,</span> color <span class="o">=</span> <span class="s">&#39;black&#39;</span><span class="p">,</span> fill <span class="o">=</span> <span class="s">&#39;darkorange&#39;</span><span class="p">)</span> <span class="o">+</span> geom_density<span class="p">()</span> <span class="o">+</span> scale_x_continuous<span class="p">(</span>name <span class="o">=</span> <span class="s">&quot;Snow depth (inches)&quot;</span><span class="p">,</span> limits <span class="o">=</span> <span class="kt">c</span><span class="p">(</span><span class="m">0</span><span class="p">,</span> <span class="m">40</span><span class="p">),</span> breaks <span class="o">=</span> <span class="kp">seq</span><span class="p">(</span><span class="m">0</span><span class="p">,</span> <span class="m">40</span><span class="p">,</span> <span class="m">5</span><span class="p">))</span> <span class="o">+</span> scale_y_continuous<span class="p">(</span>name <span class="o">=</span> <span class="s">&quot;Frequency&quot;</span><span class="p">)</span> <span class="o">+</span> theme<span class="p">(</span>plot.margin <span class="o">=</span> unit<span class="p">(</span><span class="kt">c</span><span class="p">(</span><span class="m">1</span><span class="p">,</span> <span class="m">1</span><span class="p">,</span> <span class="m">0</span><span class="p">,</span> <span class="m">0.5</span><span class="p">),</span> <span class="s">&#39;lines&#39;</span><span class="p">))</span> <span class="o">+</span> theme<span class="p">(</span>axis.text.x <span class="o">=</span> element_blank<span class="p">(),</span> axis.title.x <span class="o">=</span> element_blank<span class="p">(),</span> axis.ticks.x <span class="o">=</span> element_blank<span class="p">())</span> <span class="o">+</span> labs<span class="p">(</span>title <span class="o">=</span> <span class="s">&quot;December Snow Depth&quot;</span><span class="p">,</span> subtitle <span class="o">=</span> <span class="s">&quot;Fairbanks Airport Station&quot;</span><span class="p">)</span> actual_december <span class="o">&lt;-</span> ggplot<span class="p">(</span>data <span class="o">=</span> snow_depths<span class="p">,</span> aes<span class="p">(</span>x <span class="o">=</span> dec_01<span class="p">,</span> y <span class="o">=</span> <span class="m">..</span>density..<span class="p">))</span> <span class="o">+</span> theme_bw<span class="p">()</span> <span class="o">+</span> geom_histogram<span class="p">(</span>binwidth <span class="o">=</span> <span class="m">1</span><span class="p">,</span> color <span class="o">=</span> <span class="s">&#39;black&#39;</span><span class="p">,</span> fill <span class="o">=</span> <span class="s">&#39;darkorange&#39;</span><span class="p">)</span> <span class="o">+</span> geom_density<span class="p">()</span> <span class="o">+</span> scale_x_continuous<span class="p">(</span>name <span class="o">=</span> <span class="s">&quot;Snow depth (inches)&quot;</span><span class="p">,</span> limits <span class="o">=</span> <span class="kt">c</span><span class="p">(</span><span class="m">0</span><span class="p">,</span> <span class="m">40</span><span class="p">),</span> breaks <span class="o">=</span> <span class="kp">seq</span><span class="p">(</span><span class="m">0</span><span class="p">,</span> <span class="m">40</span><span class="p">,</span> <span class="m">5</span><span class="p">))</span> <span class="o">+</span> scale_y_continuous<span class="p">(</span>name <span class="o">=</span> <span class="s">&quot;Frequency&quot;</span><span class="p">)</span> <span class="o">+</span> theme<span class="p">(</span>plot.margin <span class="o">=</span> unit<span class="p">(</span><span class="kt">c</span><span class="p">(</span><span class="m">0</span><span class="p">,</span> <span class="m">1</span><span class="p">,</span> <span class="m">0.5</span><span class="p">,</span> <span class="m">0.5</span><span class="p">),</span> <span class="s">&#39;lines&#39;</span><span class="p">))</span> height <span class="o">&lt;-</span> <span class="m">9</span> width <span class="o">&lt;-</span> <span class="m">16</span> rescale <span class="o">&lt;-</span> <span class="m">0.75</span> heights <span class="o">&lt;-</span> <span class="kt">c</span><span class="p">(</span><span class="m">0.5</span><span class="p">,</span> <span class="m">0.5</span><span class="p">)</span> <span class="o">*</span> height gt <span class="o">&lt;-</span> ggarrange<span class="p">(</span>dec_hist<span class="p">,</span> actual_december<span class="p">,</span> ncol <span class="o">=</span> <span class="m">1</span><span class="p">,</span> nrow <span class="o">=</span> <span class="m">2</span><span class="p">,</span> align <span class="o">=</span> <span class="s">&quot;v&quot;</span><span class="p">,</span> widths <span class="o">=</span> <span class="kt">c</span><span class="p">(</span><span class="m">1</span><span class="p">,</span> <span class="m">1</span><span class="p">),</span> heights <span class="o">=</span> heights<span class="p">)</span> svg<span class="p">(</span><span class="s">&#39;december_comparison.svg&#39;</span><span class="p">,</span> width<span class="o">=</span>width<span class="o">*</span>rescale<span class="p">,</span> height<span class="o">=</span>height<span class="o">*</span>rescale<span class="p">)</span> gt dev.off<span class="p">()</span> jan <span class="o">&lt;-</span> stan_glm<span class="p">(</span>jan_01 <span class="o">~</span> nov_10<span class="p">,</span> data <span class="o">=</span> snow_depths<span class="p">,</span> <span class="c1"># family = gaussian(link = &quot;identity&quot;),</span> family <span class="o">=</span> Gamma<span class="p">(</span>link <span class="o">=</span> <span class="s">&quot;log&quot;</span><span class="p">),</span> <span class="c1"># prior = normal(0.7, 3),</span> <span class="c1"># prior_intercept = normal(1, 3),</span> iter <span class="o">=</span> <span class="m">5000</span><span class="p">)</span> jan_prediction_mat <span class="o">&lt;-</span> posterior_predict<span class="p">(</span>jan<span class="p">,</span> newdata <span class="o">=</span> tibble<span class="p">(</span>nov_10 <span class="o">=</span> <span class="m">1</span><span class="p">))</span> jan_prediction <span class="o">&lt;-</span> tibble<span class="p">(</span>pred_jan_01 <span class="o">=</span> jan_prediction_mat<span class="p">[,</span><span class="m">1</span><span class="p">])</span> feb <span class="o">&lt;-</span> stan_glm<span class="p">(</span>feb_01 <span class="o">~</span> nov_10<span class="p">,</span> data <span class="o">=</span> snow_depths<span class="p">,</span> <span class="c1"># family = gaussian(link = &quot;identity&quot;),</span> family <span class="o">=</span> Gamma<span class="p">(</span>link <span class="o">=</span> <span class="s">&quot;log&quot;</span><span class="p">),</span> <span class="c1"># family = poisson(link = &quot;identity&quot;),</span> <span class="c1"># prior = normal(0.7, 3),</span> <span class="c1"># prior_intercept = normal(1, 3),</span> iter <span class="o">=</span> <span class="m">5000</span><span class="p">)</span> feb_prediction_mat <span class="o">&lt;-</span> posterior_predict<span class="p">(</span>feb<span class="p">,</span> newdata <span class="o">=</span> tibble<span class="p">(</span>nov_10 <span class="o">=</span> <span class="m">1</span><span class="p">))</span> feb_prediction <span class="o">&lt;-</span> tibble<span class="p">(</span>pred_feb_01 <span class="o">=</span> feb_prediction_mat<span class="p">[,</span><span class="m">1</span><span class="p">])</span> all_predictions <span class="o">&lt;-</span> bind_cols<span class="p">(</span>dec_prediction<span class="p">,</span> jan_prediction<span class="p">,</span> feb_prediction<span class="p">)</span> <span class="o">%&gt;%</span> rename<span class="p">(</span><span class="sb">`Dec 1`</span> <span class="o">=</span> pred_dec_01<span class="p">,</span> <span class="sb">`Jan 1`</span> <span class="o">=</span> pred_jan_01<span class="p">,</span> <span class="sb">`Feb 1`</span> <span class="o">=</span> pred_feb_01<span class="p">)</span> <span class="o">%&gt;%</span> gather<span class="p">(</span>prediction<span class="p">,</span> snow_depth_inches<span class="p">)</span> <span class="o">%&gt;%</span> mutate<span class="p">(</span>prediction <span class="o">=</span> <span class="kp">factor</span><span class="p">(</span>prediction<span class="p">,</span> levels <span class="o">=</span> <span class="kt">c</span><span class="p">(</span><span class="s">&quot;Dec 1&quot;</span><span class="p">,</span> <span class="s">&quot;Jan 1&quot;</span><span class="p">,</span> <span class="s">&quot;Feb 1&quot;</span><span class="p">)))</span> pred_density_plot <span class="o">&lt;-</span> ggplot<span class="p">(</span>data <span class="o">=</span> all_predictions<span class="p">,</span> aes<span class="p">(</span>x <span class="o">=</span> snow_depth_inches<span class="p">,</span> colour <span class="o">=</span> prediction<span class="p">))</span> <span class="o">+</span> theme_bw<span class="p">()</span> <span class="o">+</span> geom_density<span class="p">()</span> <span class="o">+</span> scale_x_continuous<span class="p">(</span>name <span class="o">=</span> <span class="s">&quot;Snow depth (inches)&quot;</span><span class="p">,</span> limits <span class="o">=</span> <span class="kt">c</span><span class="p">(</span><span class="m">0</span><span class="p">,</span> <span class="m">55</span><span class="p">),</span> breaks <span class="o">=</span> pretty_breaks<span class="p">(</span>n <span class="o">=</span> <span class="m">10</span><span class="p">))</span> <span class="o">+</span> theme<span class="p">(</span>axis.text.x <span class="o">=</span> element_blank<span class="p">(),</span> axis.title.x <span class="o">=</span> element_blank<span class="p">(),</span> axis.ticks.x <span class="o">=</span> element_blank<span class="p">())</span> <span class="o">+</span> labs<span class="p">(</span>title <span class="o">=</span> <span class="s">&quot;Predicted and actual snow depths based on November 10 depth&quot;</span><span class="p">,</span> subtitle <span class="o">=</span> <span class="s">&quot;Fairbanks Airport Station&quot;</span><span class="p">)</span> actual_data <span class="o">&lt;-</span> snow_depths <span class="o">%&gt;%</span> transmute<span class="p">(</span><span class="sb">`Dec 1`</span> <span class="o">=</span> dec_01<span class="p">,</span> <span class="sb">`Jan 1`</span> <span class="o">=</span> jan_01<span class="p">,</span> <span class="sb">`Feb 1`</span> <span class="o">=</span> feb_01<span class="p">)</span> <span class="o">%&gt;%</span> gather<span class="p">(</span>actual<span class="p">,</span> snow_depth_inches<span class="p">)</span> <span class="o">%&gt;%</span> mutate<span class="p">(</span>actual <span class="o">=</span> <span class="kp">factor</span><span class="p">(</span>actual<span class="p">,</span> levels <span class="o">=</span> <span class="kt">c</span><span class="p">(</span><span class="s">&quot;Dec 1&quot;</span><span class="p">,</span> <span class="s">&quot;Jan 1&quot;</span><span class="p">,</span> <span class="s">&quot;Feb 1&quot;</span><span class="p">)))</span> actual_density_plot <span class="o">&lt;-</span> ggplot<span class="p">(</span>data <span class="o">=</span> actual_data<span class="p">,</span> aes<span class="p">(</span>x <span class="o">=</span> snow_depth_inches<span class="p">,</span> colour <span class="o">=</span> actual<span class="p">))</span> <span class="o">+</span> theme_bw<span class="p">()</span> <span class="o">+</span> geom_density<span class="p">()</span> <span class="o">+</span> scale_x_continuous<span class="p">(</span>name <span class="o">=</span> <span class="s">&quot;Snow depth (inches)&quot;</span><span class="p">,</span> limits <span class="o">=</span> <span class="kt">c</span><span class="p">(</span><span class="m">0</span><span class="p">,</span> <span class="m">55</span><span class="p">),</span> breaks <span class="o">=</span> pretty_breaks<span class="p">(</span>n <span class="o">=</span> <span class="m">10</span><span class="p">))</span> <span class="o">+</span> theme<span class="p">(</span>plot.margin <span class="o">=</span> unit<span class="p">(</span><span class="kt">c</span><span class="p">(</span><span class="m">0</span><span class="p">,</span> <span class="m">1</span><span class="p">,</span> <span class="m">0.5</span><span class="p">,</span> <span class="m">0.5</span><span class="p">),</span> <span class="s">&#39;lines&#39;</span><span class="p">))</span> height <span class="o">&lt;-</span> <span class="m">9</span> width <span class="o">&lt;-</span> <span class="m">16</span> rescale <span class="o">&lt;-</span> <span class="m">0.75</span> heights <span class="o">&lt;-</span> <span class="kt">c</span><span class="p">(</span><span class="m">0.5</span><span class="p">,</span> <span class="m">0.5</span><span class="p">)</span> <span class="o">*</span> height gt <span class="o">&lt;-</span> ggarrange<span class="p">(</span>pred_density_plot<span class="p">,</span> actual_density_plot<span class="p">,</span> ncol <span class="o">=</span> <span class="m">1</span><span class="p">,</span> nrow <span class="o">=</span> <span class="m">2</span><span class="p">,</span> align <span class="o">=</span> <span class="s">&quot;v&quot;</span><span class="p">,</span> widths <span class="o">=</span> <span class="kt">c</span><span class="p">(</span><span class="m">1</span><span class="p">,</span> <span class="m">1</span><span class="p">),</span> heights <span class="o">=</span> heights<span class="p">)</span> svg<span class="p">(</span><span class="s">&#39;dec_jan_feb.svg&#39;</span><span class="p">,</span> width<span class="o">=</span>width<span class="o">*</span>rescale<span class="p">,</span> height<span class="o">=</span>height<span class="o">*</span>rescale<span class="p">)</span> gt dev.off<span class="p">()</span> </pre></div> </div> </div> Sat, 10 Nov 2018 10:02:21 -0900 http://swingleydev.com/blog/p/2011/ R weather snow depth bayesian statistics regression rstanarm