American Airlines

Author

Penelope Pooler Eisenbies

Published

May 2, 2024

Import and Examine Data

Show the code
# data source: https://www.transtats.bts.gov/Data_Elements.aspx?Data=1

american <- read_csv("data/american_passengers_5_2_2024.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)
Rows: 256
Columns: 2
$ Date  <date> 2002-10-31, 2002-11-30, 2002-12-31, 2003-01…
$ Total <dbl> 7.75, 7.09, 7.90, 7.01, 6.36, 7.63, 7.10, 7.…
Show the code
american_pp <- american |>          # post_pandemic data 
  filter(Date >= "2021-06-01") |>
  glimpse(width=60)
Rows: 32
Columns: 2
$ Date  <date> 2021-06-30, 2021-07-31, 2021-08-31, 2021-09…
$ Total <dbl> 11.92, 12.87, 11.20, 10.00, 11.53, 11.79, 12…

Interactive Time Series Plot

Full and Truncated Data Plots

Plot of Full Time Series

Seasonal pattern was disrupted by the pandemic when air travel was considered dangerous.

Plot of Truncated Time Series

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

Forecast Modeling

Create Time Series (ts)

Show the code
american_ts <- ts(american_pp$Total, freq=12, start=c(2021,6)) # create time series

american_ts # display time series
       Jan   Feb   Mar   Apr   May   Jun   Jul   Aug   Sep   Oct   Nov   Dec
2021                               11.92 12.87 11.20 10.00 11.53 11.79 12.16
2022  9.30  9.52 12.71 12.39 13.21 13.66 14.14 13.45 12.50 13.72 12.83 13.38
2023 12.16 11.80 14.12 13.60 14.21 14.88 15.19 14.39 12.87 14.13 13.43 13.59
2024 13.04                                                                  

Model 1

Show the code
american_model1 <- american_ts |> auto.arima(ic="aic", seasonal=T)

american_forecast1 <- american_model1 |> forecast(h=12)

(american_fcp1 <- autoplot(american_forecast1) + 
    labs(y = "Number of Passenger (Mill.)") + 
    theme_classic())

Show the code
american_forecast1
         Point Forecast    Lo 80    Hi 80     Lo 95    Hi 95
Feb 2024          12.68 11.86862 13.49138 11.439100 13.92090
Mar 2024          15.00 13.85253 16.14747 13.245103 16.75490
Apr 2024          14.48 13.07465 15.88535 12.330699 16.62930
May 2024          15.09 13.46724 16.71276 12.608200 17.57180
Jun 2024          15.76 13.94570 17.57430 12.985264 18.53474
Jul 2024          16.07 14.08253 18.05747 13.030429 19.10957
Aug 2024          15.27 13.12329 17.41671 11.986888 18.55311
Sep 2024          13.75 11.45507 16.04493 10.240205 17.25979
Oct 2024          15.01 12.57586 17.44414 11.287301 18.73270
Nov 2024          14.31 11.74419 16.87581 10.385930 18.23407
Dec 2024          14.47 11.77895 17.16105 10.354401 18.58560
Jan 2025          13.92 11.10929 16.73071  9.621397 18.21860
Show the code
checkresiduals(american_forecast1, test=F)

Show the code
(acr1 <- accuracy(american_forecast1)) 
                      ME      RMSE       MAE        MPE     MAPE      MASE
Training set -0.02755282 0.4878546 0.2893771 -0.1710291 2.207941 0.2171685
                    ACF1
Training set -0.06049009

Model 2

Show the code
american_model2 <- american_ts |> auto.arima(ic="aic", seasonal=F) 

american_forecast2 <- american_model2 |> forecast(h=12)

(american_fcp2 <- autoplot(american_forecast2) + 
    labs(y = "Number of Passenger (Mill.)") + 
    theme_classic())

Show the code
american_forecast2
         Point Forecast     Lo 80    Hi 80     Lo 95    Hi 95
Feb 2024          13.04 11.499482 14.58052 10.683981 15.39602
Mar 2024          13.04 10.861378 15.21862  9.708086 16.37191
Apr 2024          13.04 10.371744 15.70826  8.959255 17.12074
May 2024          13.04  9.958964 16.12104  8.327962 17.75204
Jun 2024          13.04  9.595297 16.48470  7.771781 18.30822
Jul 2024          13.04  9.266517 16.81348  7.268955 18.81104
Aug 2024          13.04  8.964172 17.11583  6.806559 19.27344
Sep 2024          13.04  8.682757 17.39724  6.376171 19.70383
Oct 2024          13.04  8.418446 17.66155  5.971942 20.10806
Nov 2024          13.04  8.168454 17.91155  5.589613 20.49039
Dec 2024          13.04  7.930679 18.14932  5.225968 20.85403
Jan 2025          13.04  7.703489 18.37651  4.878510 21.20149
Show the code
checkresiduals(american_forecast2, test=F)

Show the code
(acr2 <- accuracy(american_forecast2)) 
                    ME     RMSE       MAE        MPE     MAPE      MASE
Training set 0.0353725 1.183141 0.9259975 -0.2172256 7.509038 0.6949325
                   ACF1
Training set -0.2026777