<commit_before>---
layout: post
title: 'Seasonal Trends in NYC Traffic: STL Part I'
---


<!-- Loading and formatting data -->


<!-- ggplot of data -->

Everyone knows that traffic is much worse during the week than Sundays. But how much so? And how much does traffic change from month to month? Does traffic decrease in the summer because people take vacation, or do those vacationers clog the roadways? Given all of these fluctuations in traffic, how do we quantify long term trends?

![center](/figures/STL-Part-I/unnamed-chunk-3-1.png)

In data science, these questions fall are referred to as _seasonality_. A wonderful technique to address these questions is Seasonal and Trend decomposition using LOESS (STL). This the first of a three part series on STL. In this post, we'll look at a test case of traffic from the <NAME>. Kennedy Bridge in Manhattan. Part II delves into the weeds of how this works, and Part III discusses how STL can be used for imputing data over missing values, a key advantage over other means of decomposition.

### The Data

The dataset we have is of total daily tolls across the JFK bridge. The data were scrapped from the [MTA][dataLocation]. All of the data aggregation and analysis including this post in .Rmd form is available on [GitHub][source]. The cleaned data is a time series of daily data from March 2012 through September 2016.


{% highlight r %}
head(jfkManhattan)
{% endhighlight %}



{% highlight text %}
## Source: local data frame [6 x 2]
##
##         Date  Total<commit_msg>Moved plot back to top<commit_after>---
layout: post
title: 'Seasonal Trends in NYC Traffic: STL Part I'
---


<!-- Loading and formatting data -->


<!-- ggplot of data -->

![center](/figures/STL-Part-I/unnamed-chunk-3-1.png)

Everyone knows that traffic is much worse during the week than Sundays. But how much so? And how much does traffic change from month to month? Does traffic decrease in the summer because people take vacation, or do those vacationers clog the roadways? Given all of these fluctuations in traffic, how do we quantify long term trends?

In data science, these questions fall are referred to as _seasonality_. A wonderful technique to address these questions is Seasonal and Trend decomposition using LOESS (STL). This the first of a three part series on STL. In this post, we'll look at a test case of traffic from the John F. Kennedy Bridge in Manhattan. Part II delves into the weeds of how this works, and Part III discusses how STL can be used for imputing data over missing values, a key advantage over other means of decomposition.

### The Data

The dataset we have is of total daily tolls across the JFK bridge. The data were scrapped from the [MTA][dataLocation]. All of the data aggregation and analysis including this post in .Rmd form is available on [GitHub][source]. The cleaned data is a time series of daily data from March 2012 through September 2016.


{% highlight r %}
head(jfkManhattan)
{% endhighlight %}



{% highlight text %}
## Source: local data frame [6 x 2]
##
##         Date  Total
{'fraction_non_alphanumeric': 0.06651450929246822, 'fraction_numerical': 0.0078252363873492, 'mean_word_length': 3.9644012944983817, 'pattern_counts': {'":': 0, '<': 8, '<?xml version=': 0, '>': 8, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '2110030', 'n_tokens_mistral': 844, 'n_tokens_neox': 765, 'n_words': 472}