<p><div><div><div><div data-show-faces="false" data-height="21" data-width="100" data-layout="button_count" data-send="true" data-href="https://www.r-bloggers.com/easy-time-series-prediction-with-r-a-tutorial-with-air-traffic-data-from-lux-airport/"></div></div><div></div></div><div></div></div>
<div>
(This article was first published on <strong><a href="http://www.brodrigues.co/blog/2018-11-14-luxairport/"> Econometrics and Free Software</a></strong>, and kindly contributed to <a rel="nofollow" href="https://www.r-bloggers.com/">R-bloggers)</a> </div>
<div>
<p><a rel="nofollow" href="https://www.youtube.com/watch?v=GIQn8pab8Vc" target="_blank"><br>
<img title="Luxembourg's largest aircraft landing" src="https://i2.wp.com/www.brodrigues.co/blog/2018-11-14-luxairport/img/lx_aie.jpg?w=456" data-recalc-dims="1"></a></p>
</div>
<p>In this blog post, I will show you how you can quickly and easily forecast a univariate time series.<br>
I am going to use data from the EU Open Data Portal on air passenger transport. You can find the<br>
data <a rel="nofollow" href="https://data.europa.eu/euodp/en/data/dataset/2EwfWXj5d94BUOzfoABKSQ" target="_blank">here</a>. I downloaded<br>
the data in the TSV format for Luxembourg Airport, but you could repeat the analysis for any airport.</p>
<p>Once you have the data, load some of the package we are going to need:</p>
<pre><code>library(tidyverse)
library(lubridate)
library(forecast)
library(tsibble)
library(brotools)</code></pre>
<p>and define the following function:</p>
<pre><code>ihs &lt;- function(x){
    log(x + sqrt(x**2 + 1))
}</code></pre>
<p>This function, the inverse hyperbolic sine, is useful to transform data in a manner that is very<br>
close to logging it, but that allows for 0’s. The data from Eurostat is not complete for some reason,<br>
so there are some 0 sometimes. To avoid having to log 0, which in R yields <code>-Inf</code>, I use this<br>
transformation.</p>
<p>Now, let’s load the data:</p>
<pre><code>avia &lt;- read_tsv(&quot;avia_par_lu.tsv&quot;)</code></pre>
<pre><code>## Parsed with column specification:
## cols(
##   .default = col_character()
## )</code></pre>
<pre><code>## See spec(...) for full column specifications.</code></pre>
<p>Let’s take a look at the data:</p>
<pre><code>head(avia)</code></pre>
<pre><code>## # A tibble: 6 x 238
##   `unit,tra_meas,… `2018Q1` `2018M03` `2018M02` `2018M01` `2017Q4` `2017Q3`
##   </code></pre>