Spirit 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

spirit <- read_csv("data/spirit_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> 0.30, 0.33, 0.36, 0.34, 0.31, 0.36, 0.35, 0.…
Show the code
spirit_pp <- spirit |>          # 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> 2.92, 3.39, 2.43, 2.47, 2.72, 2.92, 3.00, 2.…

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
spirit_ts <- ts(spirit_pp$Total, freq=12, start=c(2021,6)) # create time series

spirit_ts # display time series
      Jan  Feb  Mar  Apr  May  Jun  Jul  Aug  Sep  Oct  Nov  Dec
2021                          2.92 3.39 2.43 2.47 2.72 2.92 3.00
2022 2.55 2.58 3.37 3.00 3.37 3.33 3.50 3.38 3.08 3.43 3.38 3.44
2023 3.41 3.26 3.92 3.71 3.81 3.64 3.79 3.69 3.29 3.84 3.81 3.86
2024 3.33                                                       

Model 1

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

spirit_forecast1 <- spirit_model1 |> forecast(h=12)

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

Show the code
spirit_forecast1
         Point Forecast    Lo 80    Hi 80    Lo 95    Hi 95
Feb 2024       3.481283 3.116950 3.845616 2.924084 4.038482
Mar 2024       3.847076 3.452806 4.241346 3.244092 4.450060
Apr 2024       3.700524 3.288744 4.112304 3.070761 4.330287
May 2024       3.581390 3.149308 4.013472 2.920578 4.242203
Jun 2024       3.391083 2.908536 3.873631 2.653090 4.129076
Jul 2024       3.679531 3.101981 4.257081 2.796245 4.562817
Aug 2024       3.777295 3.186909 4.367680 2.874378 4.680211
Sep 2024       3.576580 2.965826 4.187333 2.642513 4.510647
Oct 2024       3.511578 2.868117 4.155040 2.527489 4.495667
Nov 2024       3.541708 2.849222 4.234193 2.482643 4.600772
Dec 2024       3.738095 3.008390 4.467799 2.622108 4.854081
Jan 2025       3.659739 2.919221 4.400257 2.527215 4.792263
Show the code
checkresiduals(spirit_forecast1, test=F)

Show the code
(acr1 <- accuracy(spirit_forecast1)) 
                   ME      RMSE      MAE       MPE     MAPE     MASE
Training set 0.037663 0.2562558 0.198798 0.6831742 6.154862 0.423425
                    ACF1
Training set 0.006136755

Model 2

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

spirit_forecast2 <- spirit_model2 |> forecast(h=12)

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

Show the code
spirit_forecast2
         Point Forecast    Lo 80    Hi 80    Lo 95    Hi 95
Feb 2024        3.50522 3.184490 3.825950 3.014706 3.995734
Mar 2024        4.16522 3.829138 4.501302 3.651227 4.679213
Apr 2024        3.95522 3.604457 4.305983 3.418775 4.491666
May 2024        4.05522 3.690367 4.420074 3.497225 4.613215
Jun 2024        3.88522 3.506800 4.263640 3.306477 4.463963
Jul 2024        4.03522 3.643704 4.426736 3.436448 4.633993
Aug 2024        3.93522 3.531032 4.339409 3.317067 4.553373
Sep 2024        3.53522 3.118745 3.951696 2.898276 4.172164
Oct 2024        4.08522 3.656810 4.513630 3.430023 4.740417
Nov 2024        4.05522 3.615199 4.495241 3.382266 4.728175
Dec 2024        4.10522 3.653886 4.556554 3.414965 4.795475
Jan 2025        3.57522 3.112851 4.037590 2.868087 4.282353
Show the code
checkresiduals(spirit_forecast2, test=F)

Show the code
(acr2 <- accuracy(spirit_forecast2)) 
                      ME      RMSE       MAE        MPE     MAPE     MASE
Training set -0.01674151 0.1877002 0.1133833 -0.4391385 3.251134 0.241498
                    ACF1
Training set -0.02364004