Point Forecast Lo 80 Hi 80 Lo 95 Hi 95
Feb 2025 2.620887 2.442494 2.799280 2.348058 2.893716
Mar 2025 3.122636 2.870350 3.374923 2.736798 3.508475
Apr 2025 3.083133 2.774147 3.392119 2.610579 3.555686
May 2025 3.278511 2.921725 3.635298 2.732853 3.824169
Jun 2025 3.489138 3.090238 3.888037 2.879074 4.099202
Jul 2025 3.748015 3.311043 4.184987 3.079723 4.416306
Aug 2025 3.569764 3.097780 4.041748 2.847927 4.291602
Sep 2025 3.123263 2.618691 3.627835 2.351587 3.894940
Oct 2025 3.137388 2.602209 3.672568 2.318902 3.955875
Nov 2025 3.032636 2.468508 3.596765 2.169876 3.895397
Dec 2025 3.191644 2.599981 3.783307 2.286773 4.096515
Jan 2026 2.581774 1.963802 3.199746 1.636667 3.526881
ME RMSE MAE MPE MAPE MASE
Training set -0.009642139 0.1149414 0.08026623 -0.4727818 2.901428 0.3007634
ACF1
Training set -0.08774973
Source Code
---title: "Alaska Airlines"author: "Penelope Pooler Eisenbies"date: last-modifiedlightbox: truetoc: truetoc-depth: 3toc-location: lefttoc-title: "Table of Contents"toc-expand: 1format: html: code-line-numbers: true code-fold: true code-tools: trueexecute: echo: fenced---```{r}#| label: setup#| include: false# suppress scientific notationoptions(scipen=100)# install helper package that loads and installs other packages, if neededif (!require("pacman")) install.packages("pacman", repos ="http://lib.stat.cmu.edu/R/CRAN/")# install and load required packages# pacman should be first package in parentheses and then list otherspacman::p_load(pacman,tidyverse, magrittr, knitr, gridExtra, forecast, tidyquant, lubridate, ggthemes, RColorBrewer, dygraphs, xts)# verify packages#p_loaded()```## Import and Examine Data```{r}#| label: import data# data source: https://www.transtats.bts.gov/Data_Elements.aspx?Data=1alaska <-read_csv("data/alaska_airlines_4_30_2025.csv",show_col_types = F, skip=1)|>filter(Month !="TOTAL") |>mutate(date_som =ym(paste(Year, Month)),Date =ceiling_date(date_som, "month")-1,Total = (TOTAL/1000000) |>round(2)) |>select(Date, Total) |>glimpse(width=60)alaska_pp <- alaska |># post_pandemic data filter(Date >="2021-06-01") |>glimpse(width=60)```### Interactive Time Series Plot```{r}#| label: create dygraph# create interactive plotalaska_xts <-xts(x=alaska[,2], order.by=alaska$Date)(alaska_dg <-dygraph(alaska_xts[,1], main="Alaska Airlines - Total Passengers") |>dySeries("Total", label="Total (Mill.)", color="blue") |>dyAxis("y", label ="", drawGrid =FALSE) |>dyAxis("x", label ="", drawGrid =FALSE) |>dyShading(from="2020-3-12", to="2021-6-14", color ="lightgrey") |>dyRangeSelector())```## Full and Truncated Data Plots### Plot of Full Time SeriesSeasonal pattern was disrupted by the pandemic when air travel was considered dangerous.```{r}#| label: Full Time Series#| warning: false#| message: false(full_plot <- alaska |>ggplot() +geom_line(aes(x=Date, y=Total), linewidth=1, color="blue") +theme_classic() +scale_x_date(date_breaks ="2 years", date_labels ="%Y", limits=c(ymd("2001-12-31"), ymd("2025-01-31"))) +scale_y_continuous(breaks=seq(0,4,.5), limits=c(0,4)) +labs(title="Alaska Airlines: October 2002 - January 2025",subtitle="Total Passengers (Domestic and International)",x="Date", y="Millions of Passengers",caption="Data Source: https://www.bts.gov/" ) +theme(plot.title =element_text(size =15),plot.caption =element_text(size =10),axis.title.x =element_text(size =15),axis.title.y =element_text(size =15),axis.text.x =element_text(size =10),axis.text.y =element_text(size =15)))ggsave("img/alaska_full_plot_2025_04_30.png", width=6, height=4, unit="in")```### Plot of Truncated Time SeriesOnce vaccines became readily available, air travel began to resume it's traditional pattern:- Peaks occur at the end of July- Low points occur at the end of Jnauary- Pattern is not straightforward to discern because post-pandemic data are fairly limited.- Data for February and March of 2024 are not available yet.```{r}#| label: Truncated Time Series#| warning: false#| message: false(short_plot <- alaska_pp |>ggplot() +geom_line(aes(x=Date, y=Total), linewidth=1, color="blue") +theme_classic() +scale_x_date(date_breaks ="2 months", date_labels ="%b", limits=c(ymd("2021-05-31"), ymd("2025-1-31")))+scale_y_continuous(limits=c(1.5, 4)) +labs(title="Alaska Airlines: June 2021 - January 2025",subtitle="Total Passengers (Domestic and International)",x="Date", y="Millions of Passengers",caption="Data Source: https://www.bts.gov/" ) +theme(plot.title =element_text(size =15),plot.caption =element_text(size =10),axis.title.x =element_text(size =15),axis.title.y =element_text(size =15),axis.text.x =element_text(size =10),axis.text.y =element_text(size =15)))#ggsave("img/alaska_trnc_plot_2024_04_21.png", width=6, height=4, unit="in")```## Forecast Modeling### Create Time Series (`ts`)```{r}#| label: create time seriesalaska_ts <-ts(alaska_pp$Total, freq=12, start=c(2021,6)) # create time seriesalaska_ts # display time series```### Model 1```{r}#| label: Model 1alaska_model1 <- alaska_ts |>auto.arima(ic="aic", seasonal=F)alaska_forecast1 <- alaska_model1 |>forecast(h=12)(alaska_fcp1 <-autoplot(alaska_forecast1) +labs(y ="Number of Passenger (Mill.)") +theme_classic())alaska_forecast1checkresiduals(alaska_forecast1, test=F)(acr1 <-accuracy(alaska_forecast1)) ```### Model 2```{r}#| label: Model 2alaska_model2 <- alaska_ts |>auto.arima(ic="aic", seasonal=T) alaska_forecast2 <- alaska_model2 |>forecast(h=12)(alaska_fcp2 <-autoplot(alaska_forecast2) +labs(y ="Number of Passenger (Mill.)") +theme_classic())alaska_forecast2checkresiduals(alaska_forecast2, test=F)(acr2 <-accuracy(alaska_forecast2)) ```