# Introduction

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.

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?

# Data

We’ll use the 92-year record of snow depth data from the Fairbanks International Airport station that’s in the Global Historical Climate Network.

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:

nov_10 | dec_01 | jan_01 | feb_01 | |
---|---|---|---|---|

nov_10 | 1.00 | 0.65 | 0.49 | 0.46 |

dec_01 | 0.65 | 1.00 | 0.60 | 0.39 |

jan_01 | 0.49 | 0.60 | 1.00 | 0.74 |

feb_01 | 0.46 | 0.39 | 0.74 | 1.00 |

Looking down the `nov_10` 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.

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.

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?

Here’s the data for those six years with a snow depth of 1 inch on November 10th:

wyear | dec_01 | jan_01 | feb_01 |
---|---|---|---|

1938 | 5 | 11 | 24 |

1940 | 6 | 8 | 9 |

1951 | 12 | 22 | 31 |

1953 | 1 | 5 | 17 |

1954 | 9 | 15 | 12 |

1979 | 3 | 8 | 14 |

Not exactly encouraging data for our current situation, although 1951 gives us some hope of a good winter.

# Methods

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 `rstanarm` R package,
which mimics the `glm` function that’s part of base R.

Because of the non-zero, skewed nature of the distribution of snow depths, a
log-linked Gamma distribution is appropriate. We used the `rstanarm` defaults
for priors.

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.

The code for the analysis appears at the bottom of the post.

# Results

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).

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.

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.

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.

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.

# Conclusion

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.

# Appendix

```
library(tidyverse)
library(glue)
library(ggpubr)
library(scales)
library(lubridate)
library(RPostgres)
library(rstanarm)
noaa <- dbConnect(Postgres(),
dbname = "noaa")
ghcnd_stations <- noaa %>%
tbl("ghcnd_stations") %>%
filter(station_name == "FAIRBANKS INTL AP")
ghcnd_variables <- noaa %>%
tbl("ghcnd_variables") %>%
filter(variable == "SNWD")
ghcnd_obs <- noaa %>%
tbl("ghcnd_obs") %>%
inner_join(ghcnd_stations, by = "station_id") %>%
inner_join(ghcnd_variables, by = "variable") %>%
mutate(month = date_part("month", dte),
day = date_part("day", dte)) %>%
filter((month == 11 & day == 10) |
(month == 12 & day == 1) |
(month == 1 & day == 1) |
(month == 2 & day == 1),
is.na(meas_flag) | meas_flag == "") %>%
mutate(value = raw_value * raw_multiplier) %>%
select(dte, month, day, variable, value) %>%
collect()
snow_depths <- ghcnd_obs %>%
mutate(wyear = year(dte - days(91)),
mmdd = factor(glue("{str_to_lower(month.abb[month])}",
"_{sprintf('%02d', day)}"),
levels = c("nov_10", "dec_01",
"jan_01", "feb_01")),
value = value / 25.4) %>%
select(wyear, mmdd, value) %>%
spread(mmdd, value) %>%
filter(!is.na(nov_10))
write_csv(snow_depths, "snow_depths.csv", na = "")
dec <- stan_glm(dec_01 ~ nov_10,
data = snow_depths,
family = Gamma(link = "log"),
# prior = normal(0.7, 3),
# prior_intercept = normal(1, 3),
iter = 5000)
# What does the model day about 2018?
dec_prediction_mat <- posterior_predict(dec,
newdata = tibble(nov_10 = 1))
dec_prediction <- tibble(pred_dec_01 = dec_prediction_mat[,1])
dec_hist <- ggplot(data = dec_prediction,
aes(x = pred_dec_01, y = ..density..)) +
theme_bw() +
geom_histogram(binwidth = 0.25, color = 'black',
fill = 'darkorange') +
geom_density() +
scale_x_continuous(name = "Snow depth (inches)",
limits = c(0, 40),
breaks = seq(0, 40, 5)) +
scale_y_continuous(name = "Frequency") +
theme(plot.margin = unit(c(1, 1, 0, 0.5), 'lines')) +
theme(axis.text.x = element_blank(),
axis.title.x = element_blank(),
axis.ticks.x = element_blank()) +
labs(title = "December Snow Depth",
subtitle = "Fairbanks Airport Station")
actual_december <- ggplot(data = snow_depths,
aes(x = dec_01, y = ..density..)) +
theme_bw() +
geom_histogram(binwidth = 1, color = 'black',
fill = 'darkorange') +
geom_density() +
scale_x_continuous(name = "Snow depth (inches)",
limits = c(0, 40),
breaks = seq(0, 40, 5)) +
scale_y_continuous(name = "Frequency") +
theme(plot.margin = unit(c(0, 1, 0.5, 0.5), 'lines'))
height <- 9
width <- 16
rescale <- 0.75
heights <- c(0.5, 0.5) * height
gt <- ggarrange(dec_hist, actual_december,
ncol = 1, nrow = 2, align = "v",
widths = c(1, 1), heights = heights)
svg('december_comparison.svg',
width=width*rescale, height=height*rescale)
gt
dev.off()
jan <- stan_glm(jan_01 ~ nov_10,
data = snow_depths,
# family = gaussian(link = "identity"),
family = Gamma(link = "log"),
# prior = normal(0.7, 3),
# prior_intercept = normal(1, 3),
iter = 5000)
jan_prediction_mat <- posterior_predict(jan,
newdata = tibble(nov_10 = 1))
jan_prediction <- tibble(pred_jan_01 = jan_prediction_mat[,1])
feb <- stan_glm(feb_01 ~ nov_10,
data = snow_depths,
# family = gaussian(link = "identity"),
family = Gamma(link = "log"),
# family = poisson(link = "identity"),
# prior = normal(0.7, 3),
# prior_intercept = normal(1, 3),
iter = 5000)
feb_prediction_mat <- posterior_predict(feb,
newdata = tibble(nov_10 = 1))
feb_prediction <- tibble(pred_feb_01 = feb_prediction_mat[,1])
all_predictions <- bind_cols(dec_prediction,
jan_prediction,
feb_prediction) %>%
rename(`Dec 1` = pred_dec_01,
`Jan 1` = pred_jan_01,
`Feb 1` = pred_feb_01) %>%
gather(prediction, snow_depth_inches) %>%
mutate(prediction = factor(prediction,
levels = c("Dec 1", "Jan 1", "Feb 1")))
pred_density_plot <- ggplot(data = all_predictions,
aes(x = snow_depth_inches, colour = prediction)) +
theme_bw() +
geom_density() +
scale_x_continuous(name = "Snow depth (inches)",
limits = c(0, 55),
breaks = pretty_breaks(n = 10)) +
theme(axis.text.x = element_blank(), axis.title.x = element_blank(),
axis.ticks.x = element_blank()) +
labs(title = "Predicted and actual snow depths based on November 10 depth",
subtitle = "Fairbanks Airport Station")
actual_data <- snow_depths %>%
transmute(`Dec 1` = dec_01,
`Jan 1` = jan_01,
`Feb 1` = feb_01) %>%
gather(actual, snow_depth_inches) %>%
mutate(actual = factor(actual, levels = c("Dec 1", "Jan 1", "Feb 1")))
actual_density_plot <- ggplot(data = actual_data,
aes(x = snow_depth_inches, colour = actual)) +
theme_bw() +
geom_density() +
scale_x_continuous(name = "Snow depth (inches)",
limits = c(0, 55),
breaks = pretty_breaks(n = 10)) +
theme(plot.margin = unit(c(0, 1, 0.5, 0.5), 'lines'))
height <- 9
width <- 16
rescale <- 0.75
heights <- c(0.5, 0.5) * height
gt <- ggarrange(pred_density_plot, actual_density_plot,
ncol = 1, nrow = 2, align = "v",
widths = c(1, 1), heights = heights)
svg('dec_jan_feb.svg',
width=width*rescale, height=height*rescale)
gt
dev.off()
```

# Introduction

So far this winter we’ve gotten only 4.1 inches of snow, well below the normal 19.7 inches, and there is only 2 inches of snow on the ground. At this point last year we had 8 inches and I’d been biking and skiing on the trail to work for two weeks. In his North Pacific Temperature Update blog post, Richard James mentions that winters like this one, with a combined strongly positive Pacific Decadal Oscillation phase and strongly negative North Pacific Mode phase tend to be a “distinctly dry” pattern for interior Alaska. I don’t pretend to understand these large scale climate patterns, but I thought it would be interesting to look at snowfall and snow depth in years with very little mid-November snow. In other years like this one do we eventually get enough snow that the trails fill in and we can fully participate in winter sports like skiing, dog mushing, and fat biking?

# Data

We will use daily data from the Global Historical Climate Data set for the Fairbanks International Airport station. Data prior to 1950 is excluded because of poor quality snowfall and snow depth data and because there’s a good chance that our climate has changed since then and patterns from that era aren’t a good model for the current climate in Alaska.

We will look at both snow depth and the cumulative winter snowfall.

# Results

The following tables show the ten years with the lowest cumulative snowfall and snow depth values from 1950 to the present on November 18th.

Year | Cumulative Snowfall (inches) |
---|---|

1953 | 1.5 |

2016 | 4.1 |

1954 | 4.3 |

2014 | 6.0 |

2006 | 6.4 |

1962 | 7.5 |

1998 | 7.8 |

1960 | 8.5 |

1995 | 8.8 |

1979 | 10.2 |

Year | Snow depth (inches) |
---|---|

1953 | 1 |

1954 | 1 |

1962 | 1 |

2016 | 2 |

2014 | 2 |

1998 | 3 |

1964 | 3 |

1976 | 3 |

1971 | 3 |

2006 | 4 |

2016 has the second-lowest cumulative snowfall behind 1953 and is tied for second with 2014 for snow depth with 1953, 1954 and 1962 all having only 1 inch of snow on November 18th.

It also seems like recent years appear in these tables more frequently than would be expected. Grouping by decade and averaging cumulative snowfall and snow depth yields the pattern in the chart below. The error bars (not shown) are fairly large, so the differences between decades aren’t likely to be statistically significant, but there is a pattern of lower snowfall amounts in recent decades.

Now let’s see what happened in those years with low snowfall and snow depth values in mid-November starting with cumulative snowfall. The following plot (and the subsequent snow depth plot) shows the data for the low-value years (and one very high snowfall year—1990), with each year’s data as a separate line. The smooth dark cyan line through the middle of each plot is the smoothed line through the values for all years; a sort of “average” snowfall and snow depth curve.

In all four mid-November low-snowfall years, the cumulative snowfall values remain below average throughout the winter, but snow did continue to fall as the season went on. Even the lowest winter year here, 2006–2007, still ended the winter with 15 inches of snow on the groud.

The following plot shows snow depth for the four years with the lowest snow depth on November 18th. The data is formatted the same as in the previous plot except we’ve jittered the values slightly to make the plot easier to read.

The pattern here is similar, but the snow depths get much closer to the average values. Snow depth for all four low snow years remain low throughout November, but start rising in December, dramatically in 1954 and 2014.

One of the highest snowfall years between 1950 and 2016 was 1990–1991 (shown on both plots). An impressive 32.8 inches of snow fell in eight days between December 21st and December 28th, accounting for the sharp increase in cumulative snowfall and snow depth shown on both plots. There are five years in the record where the cumulative total for the entire winter was lower than these eight days in 1990.

# Conclusion

Despite the lack of snow on the ground to this point in the year, the record shows that we are still likely to get enough snow to fill in the trails. We may need to wait until mid to late December, but it’s even possible we’ll eventually reach the long term average depth before spring.

# Appendix

Here’s the R code used to generate the statistics, tables and plots from this post:

```
library(tidyverse)
library(lubridate)
library(scales)
library(knitr)
noaa <- src_postgres(host="localhost", dbname="noaa")
snow <- tbl(noaa, build_sql(
"WITH wdoy_data AS (
SELECT dte, dte - interval '120 days' as wdte,
tmin_c, tmax_c, (tmin_c+tmax_c)/2.0 AS tavg_c,
prcp_mm, snow_mm, snwd_mm
FROM ghcnd_pivot
WHERE station_name = 'FAIRBANKS INTL AP'
AND dte > '1950-09-01')
SELECT dte, date_part('year', wdte) AS wyear, date_part('doy', wdte) AS wdoy,
to_char(dte, 'Mon DD') AS mmdd,
tmin_c, tmax_c, tavg_c, prcp_mm, snow_mm, snwd_mm
FROM wdoy_data")) %>%
mutate(wyear=as.integer(wyear),
wdoy=as.integer(wdoy),
snwd_mm=as.integer(snwd_mm)) %>%
select(dte, wyear, wdoy, mmdd,
tmin_c, tmax_c, tavg_c, prcp_mm, snow_mm, snwd_mm) %>% collect()
write_csv(snow, "pafa_data_with_wyear_post_1950.csv")
save(snow, file="pafa_data_with_wyear_post_1950.rdata")
cum_snow <- snow %>%
mutate(snow_na=ifelse(is.na(snow_mm),1,0),
snow_mm=ifelse(is.na(snow_mm),0,snow_mm)) %>%
group_by(wyear) %>%
mutate(snow_mm_cum=cumsum(snow_mm),
snow_na=cumsum(snow_na)) %>%
ungroup() %>%
mutate(snow_in_cum=round(snow_mm_cum/25.4, 1),
snwd_in=round(snwd_mm/25.4, 0))
nov_18_snow <- cum_snow %>%
filter(mmdd=='Nov 18') %>%
select(wyear, snow_in_cum, snwd_in) %>%
arrange(snow_in_cum)
decadal_avg <- nov_18_snow %>%
mutate(decade=as.integer(wyear/10)*10) %>%
group_by(decade) %>%
summarize(`Snow depth`=mean(snwd_in),
snwd_sd=sd(snwd_in),
`Cumulative Snowfall`=mean(snow_in_cum),
snow_cum_sd=sd(snow_in_cum))
decadal_averages <- ggplot(decadal_avg %>%
gather(variable, value, -decade) %>%
filter(variable %in% c("Cumulative Snowfall",
"Snow depth")),
aes(x=as.factor(decade), y=value, fill=variable)) +
theme_bw() +
geom_bar(stat="identity", position="dodge") +
scale_x_discrete(name="Decade", breaks=c(1950, 1960, 1970, 1980,
1990, 2000, 2010)) +
scale_y_continuous(name="Inches", breaks=pretty_breaks(n=10)) +
scale_fill_discrete(name="Measurement")
print(decadal_averages)
date_x_scale <- cum_snow %>%
filter(grepl(' (01|15)', mmdd), wyear=='1994') %>%
select(wdoy, mmdd)
cumulative_snowfall <-
ggplot(cum_snow %>% filter(wyear %in% c(1953, 1954, 2014, 2006, 1990),
wdoy>183,
wdoy<320),
aes(x=wdoy, y=snow_in_cum, colour=as.factor(wyear))) +
theme_bw() +
geom_smooth(data=cum_snow %>% filter(wdoy>183, wdoy<320),
aes(x=wdoy, y=snow_in_cum),
size=0.5, colour="darkcyan",
inherit.aes=FALSE,
se=FALSE) +
geom_line(position="jitter") +
scale_x_continuous(name="",
breaks=date_x_scale$wdoy,
labels=date_x_scale$mmdd) +
scale_y_continuous(name="Cumulative snowfall (in)",
breaks=pretty_breaks(n=10)) +
scale_color_discrete(name="Winter year")
print(cumulative_snowfall)
snow_depth <-
ggplot(cum_snow %>% filter(wyear %in% c(1953, 1954, 1962, 2014, 1990),
wdoy>183,
wdoy<320),
aes(x=wdoy, y=snwd_in, colour=as.factor(wyear))) +
theme_bw() +
geom_smooth(data=cum_snow %>% filter(wdoy>183, wdoy<320),
aes(x=wdoy, y=snwd_in),
size=0.5, colour="darkcyan",
inherit.aes=FALSE,
se=FALSE) +
geom_line(position="jitter") +
scale_x_continuous(name="",
breaks=date_x_scale$wdoy,
labels=date_x_scale$mmdd) +
scale_y_continuous(name="Snow Depth (in)",
breaks=pretty_breaks(n=10)) +
scale_color_discrete(name="Winter year")
print(snow_depth)
```

Following up on my previous post, I tried the regression approach for predicting future snow depth from current values. As you recall, I produced a plot that showed how much snow we’ve had on the ground on each date at the Fairbanks Airport between 1917 and 2013. These boxplots gave us an idea of what a normal snow depth looks like on each date, but couldn’t really tell us much about what we might expect for snow depth for the rest of the winter.

# Regression

I ran a linear regression analysis looking at how snow depth on November 8th relates to snow depth on November 27th and December 25th of the same year. Here’s the SQL:

```
SELECT * FROM (
SELECT extract(year from dte) AS year,
max(CASE WHEN to_char(dte, 'mm-dd') = '11-08'
THEN round(snwd_mm/25.4, 1)
ELSE NULL END) AS nov_8,
max(CASE WHEN to_char(dte, 'mm-dd') = '11-27'
THEN round(snwd_mm/25.4, 1)
ELSE NULL END) AS nov_27,
max(CASE WHEN to_char(dte, 'mm-dd') = '12-15'
THEN round(snwd_mm/25.4, 1)
ELSE NULL END) AS dec_25
FROM ghcnd_pivot
WHERE station_name = 'FAIRBANKS INTL AP'
AND snwd_mm IS NOT NULL
GROUP BY extract(year from dte)
ORDER BY year
) AS sub
WHERE nov_8 IS NOT NULL
AND nov_27 IS NOT NULL
AND dec_25 IS NOT NULL;
```

I’m grouping on year, then grabbing the snow depth for the three dates of interest. I would have liked to include dates in January and February in order to see how the relationship weakens as the winter progresses, but that’s a lot more complicated because then we are comparing the dates from one year to the next and the grouping I used in the query above wouldn’t work.

One note on this analysis: linear regression has a bunch of assumptions that need to be met before considering the analysis to be valid. One of these assumptions is that observations are independent from one another, which is problematic in this case because snow depth is a cumulative statistic; the depth tomorrow is necessarily related to the depth of the snow today (snow depth tomorrow = snow depth today + snowfall). Whether it’s necessarily related to the depth of the snow a month from now is less certain, and I’m making the possibly dubious assumption that autocorrelation disappears when the time interval between observations is longer than a few weeks.

# Results

Here are the results comparing the snow depth on November 8th to November 27th:

```
> reg <- lm(data=results, nov_27 ~ nov_8)
> summary(reg)
Call:
lm(formula = nov_27 ~ nov_8, data = results)
Residuals:
Min 1Q Median 3Q Max
-8.7132 -3.0490 -0.6063 1.7258 23.8403
Coefficients:
Estimate Std. Error t value Pr(>|t|)
(Intercept) 3.1635 0.9707 3.259 0.0016 **
nov_8 1.1107 0.1420 7.820 1.15e-11 ***
---
Signif. codes: 0 ‘***’ 0.001 ‘**’ 0.01 ‘*’ 0.05 ‘.’ 0.1 ‘ ’ 1
Residual standard error: 4.775 on 87 degrees of freedom
Multiple R-squared: 0.4128, Adjusted R-squared: 0.406
F-statistic: 61.16 on 1 and 87 DF, p-value: 1.146e-11
```

And between November 8th and December 25th:

```
> reg <- lm(data=results, dec_25 ~ nov_8)
> summary(reg)
Call:
lm(formula = dec_25 ~ nov_8, data = results)
Residuals:
Min 1Q Median 3Q Max
-10.209 -3.195 -1.195 2.781 10.791
Coefficients:
Estimate Std. Error t value Pr(>|t|)
(Intercept) 6.2227 0.8723 7.133 2.75e-10 ***
nov_8 0.9965 0.1276 7.807 1.22e-11 ***
---
Signif. codes: 0 ‘***’ 0.001 ‘**’ 0.01 ‘*’ 0.05 ‘.’ 0.1 ‘ ’ 1
Residual standard error: 4.292 on 87 degrees of freedom
Multiple R-squared: 0.412, Adjusted R-squared: 0.4052
F-statistic: 60.95 on 1 and 87 DF, p-value: 1.219e-11
```

Both regressions are very similar. The coefficients and the overall model are
both very significant, and the *R²* value indicates that in each case, the
snow depth on November 8th explains about 40% of the variation in the snow depth
on the later date. The amount of variation explained hardly changes at all,
despite almost a month difference between the two analyses.

Here's a plot of the relationship between today’s date and Christmas (PDF version)

The blue line is the linear regression model.

# Conclusions

For 2014, we’ve got 2 inches of snow on the ground on November 8th. The models predict we’ll have 5.4 inches on November 27th and 8 inches on December 25th. That isn’t great, but keep in mind that even though the relationship is quite strong, it explains less than half of the variation in the data, which means that it’s quite possible we will have a lot more, or less. Looking back at the plot, you can see that for all the years where we had two inches of snow on November 8th, we had between five and fifteen inches of snow in that same year on December 25th. I’m certainly hoping we’re closer to fifteen.

Winter started off very early this year with the first snow falling on October 4th and 5th, setting a two inch base several weeks earlier than normal. Since then, we’ve had only two days with more than a trace of snow.

This seems to be a common pattern in Fairbanks. After the first snowfall and the establishment of a thin snowpack on the ground, we all get excited for winter and expect the early snow to continue to build, filling the holes in the trails and starting the skiing, mushing and winter fat biking season. Then, nothing.

# Analysis

I decided to take a quick look at the pattern of snow depth at the Fairbanks Airport station to see how uncommon it is to only have two inches of snow this late in the winter (November 8th at this writing). The plot below shows all of the snow depth data between November and April for the airport station, displayed as box and whisker plots.

Here’s the SQL:

```
SELECT extract(year from dte) AS year,
extract(month from dte) AS month,
to_char(dte, 'MM-DD') AS mmdd,
round(snwd_mm/25.4, 1) AS inches
FROM ghcnd_pivot
WHERE station_name = 'FAIRBANKS INTL AP'
AND snwd_mm IS NOT NULL
AND (extract(month from dte) BETWEEN 11 AND 12
OR extract(month from dte) BETWEEN 1 AND 4);
```

If you’re interested in the code that produces the plot, it’s at the bottom of the post. If the plot doesn’t show up in your browser or you want a copy for printing, here’s a link to the PDF version.

# Box and whisker plots

For those unfamiliar with these, they’re a good way to evaluate the range of data grouped by some categorical variable (date, in our case) along with details about the expected values and possible extremes. The upper and lower limit of each box show the ranges where 25—75% of the data fall, meaning that half of all observed values are within this box for each date. For example, on today’s date, November 8th, half of all snow depth values for the period in question fell between four and eight inches. Our current snow depth of two inches falls below this range, so we can say that only having two inches of snow on the ground happens in less than 25% of the time.

The horizontal line near the middle of the box is the median of all observations for that date. Median is shown instead of average / mean because extreme values can skew the mean, so a median will often be more representative of the most likely value. For today’s date, the median snow depth is five inches. That’s what we’d expect to see on the ground now.

The vertical lines extending above and below the boxes show the points that are within 1.5 times the range of the boxes. These lines represent the values from the data outside the most likely, but not very unusual. If you scan across the November to December portion of the plot, you can see that the lower whisker touches zero for most of the period, but starting on December 26th, it rises above zero and doesn’t return until the spring. That means that there have been years where there was no snow on the ground on Christmas. Ouch.

The dots beyond the whiskers are outliers; observations so far from what is normal that they’re exceptional and not likely to be repeated. On this plot, most of these outliers are probably from one or two exceptional years where we got a ton of snow. Some of those outliers are pretty incredible; consider having two and a half feet of snow on the ground at the end of April, for example.

# Conclusion

The conclusion I’d draw from comparing our current snow depth of two inches against the boxplots is that it is somewhat unusual to have this little snow on the ground, but that it’s not exceptional. It wouldn’t be unusual to have no snow on the ground.

Looking forward, we would normally expect to have a foot of snow on the ground
by mid-December, and I’m certainly hoping that happens this year. But despite
the probabilities shown on this plot it can’t say how likely that is when we
*know* that there’s only two inches on the ground now. One downside to boxplots
in an analysis like this is that the independent variable (date) is categorical,
and the plot doesn’t have anything to say about how the values on one day relate
to the values on the next day or any date in the future. One might expect, for
example, that a low snow depth on November 8th means it’s more likely we’ll also
have a low snow depth on December 25th, but this data can’t offer evidence on
that question. It only shows us what each day’s pattern of snow depth is
expected to be on it’s own.

Bayesian analysis, “given a snow depth of two inches on November 8th, what is the likelihood of normal snow depth on December 25th”, might be a good approach for further investigation. Or a more traditional regression analysis examining the relationship between snow depth on one date against snow depth on another.

# Appendix: R Code

```
library(RPostgreSQL)
library(ggplot2)
library(scales)
library(gtable)
# Build plot "table"
make_gt <- function(nd, jf, ma) {
gt1 <- ggplot_gtable(ggplot_build(nd))
gt2 <- ggplot_gtable(ggplot_build(jf))
gt3 <- ggplot_gtable(ggplot_build(ma))
max_width <- unit.pmax(gt1$widths[2:3], gt2$widths[2:3], gt3$widths[2:3])
gt1$widths[2:3] <- max_width
gt2$widths[2:3] <- max_width
gt3$widths[2:3] <- max_width
gt <- gtable(widths = unit(c(11), "in"), heights = unit(c(3, 3, 3), "in"))
gt <- gtable_add_grob(gt, gt1, 1, 1)
gt <- gtable_add_grob(gt, gt2, 2, 1)
gt <- gtable_add_grob(gt, gt3, 3, 1)
gt
}
drv <- dbDriver("PostgreSQL")
con <- dbConnect(drv, dbname="DBNAME")
results <- dbGetQuery(con,
"SELECT extract(year from dte) AS year,
extract(month from dte) AS month,
to_char(dte, 'MM-DD') AS mmdd,
round(snwd_mm/25.4, 1) AS inches
FROM ghcnd_pivot
WHERE station_name = 'FAIRBANKS INTL AP'
AND snwd_mm IS NOT NULL
AND (extract(month from dte) BETWEEN 11 AND 12
OR extract(month from dte) BETWEEN 1 AND 4);")
results$mmdd <- as.factor(results$mmdd)
# NOV DEC
nd <- ggplot(data=subset(results, month == 11 | month == 12), aes(x=mmdd, y=inches)) +
geom_boxplot() +
theme_bw() +
theme(axis.title.x = element_blank()) +
theme(plot.margin = unit(c(1, 1, 0, 0.5), 'lines')) +
# scale_x_discrete(name="Date (mm-dd)") +
scale_y_discrete(name="Snow depth (inches)", breaks=pretty_breaks(n=10)) +
theme(axis.text.x = element_text(angle = 45, hjust = 1)) +
ggtitle('Snow depth by date, Fairbanks Airport, 1917-2013')
# JAN FEB
jf <- ggplot(data=subset(results, month == 1 | month == 2), aes(x=mmdd, y=inches)) +
geom_boxplot() +
theme_bw() +
theme(axis.title.x = element_blank()) +
theme(plot.margin = unit(c(0, 1, 0, 0.5), 'lines')) +
# scale_x_discrete(name="Date (mm-dd)") +
scale_y_discrete(name="Snow depth (inches)", breaks=pretty_breaks(n=10)) +
theme(axis.text.x = element_text(angle = 45, hjust = 1)) # +
# ggtitle('Snowdepth by date, Fairbanks Airport, 1917-2013')
# MAR APR
ma <- ggplot(data=subset(results, month == 3 | month == 4), aes(x=mmdd, y=inches)) +
geom_boxplot() +
theme_bw() +
theme(plot.margin = unit(c(0, 1, 1, 0.5), 'lines')) +
scale_x_discrete(name="Date (mm-dd)") +
scale_y_discrete(name="Snow depth (inches)", breaks=pretty_breaks(n=10)) +
theme(axis.text.x = element_text(angle = 45, hjust = 1)) # +
# ggtitle('Snowdepth by date, Fairbanks Airport, 1917-2013')
gt <- make_gt(nd, jf, ma)
svg("snowdepth_boxplots.svg", width=11, height=9)
grid.newpage()
grid.draw(gt)
dev.off()
```