Project 1: Individual Report
(Statistical Forecasting
STAT8041 - Winter 2024
- Section 2)
Salma Shaheen
Student ID | 8913789
Abstract
This project analyzes the "Airline Baggage Complaints Time Series Dataset" to explore
trends and patterns in airline passenger complaints related to baggage handling. The
dataset, obtained from Kaggle, spans a period from 2004 to 2005, containing information on
monthly complaints. Through visualizations such as time plots and autocorrelation function
(ACF) plots, we identify potential trends and seasonal patterns in the data. Utilizing
decomposition techniques, we aim to extract underlying trends and seasonality, aiding in the
selection and application of forecasting models. Two main forecasting models, Exponential
Smoothing and ARIMA, are employed to forecast future complaint volumes, with an
evaluation of their accuracy using Mean Squared Error (MSE) and other metrics. The
findings and insights from this analysis offer valuable information for airlines to improve
baggage handling services and customer satisfaction.
1
Table of Contents
1. Data -----------------------------------------------------------------------------------3
2. Visualization -------------------------------------------------------------------------4
3. Decomposition -----------------------------------------------------------------------7
4. Forecasting and Analysis -----------------------------------------------------------9
5. Appendix ----------------------------------------------------------------------------17
2
Data
The dataset I have chosen for analysis is the "Airline Baggage Complaints Time Series
Dataset" from Kaggle ([Link]
complaints-time-series-dataset). This dataset contains information about baggage-related
metrics for American Eagle airlines, spanning from January 2004 to April 2005. The
variables include the airline name, date, month, year, number of bags, scheduled flights,
cancelled flights, and enplaned passengers.
Before delving into the analysis and forecasting, it's crucial to understand the structure and
content of the dataset. The dataset comprises 8 columns and 252 rows, offering a detailed
view of baggage-related statistics for American Eagle over the specified time. The variables
in the data set include:
Baggage - The total number of passenger complaints for theft of baggage contents, or for
lost, damaged, or misrouted luggage for the airline that month.
Scheduled - The total number of flights scheduled by that airline that month.
Cancelled - The total number of flights cancelled by that airline that month.
Enplaned - The total number of passengers who boarded a plane with the airline that
month.
Our analysis focusing on the "Baggage" variable, we are particularly interested in
understanding and forecasting the trends and patterns related to passenger complaints
regarding theft, loss, damage, or misrouting of luggage for different Airlines over the
specified time period. This variable provides critical insights into the airline's baggage
handling performance, customer satisfaction, and operational efficiency.
By analyzing the "Baggage" variable, we aim to:
Identify any seasonal patterns or trends in passenger complaints related to baggage.
Assess the impact of external factors (such as holidays, weather events, or
operational changes) on baggage-related complaints.
Forecast future baggage-related complaints to help Airline optimize its baggage
handling processes and improve customer experience.
Understanding the fluctuations and patterns in the "Baggage" variable can lead to
proactive measures to reduce complaints, enhance baggage handling procedures,
and ultimately improve overall customer satisfaction for Airlines.
Data Cleaning and Preparation
Upon downloading the dataset from Kaggle, I imported it into R for analysis. The initial step
involved checking for missing values, outliers, and inconsistencies. Fortunately, this
dataset appeared to be relatively clean with no missing values or glaring anomalies.
3
Motivation for Choosing the Dataset
The dataset's relevance to real-world applications is significant. I selected this dataset due
to its relevance and potential insights into airline baggage operations. Baggage handling is a
critical aspect of airline operations, directly impacting customer satisfaction and operational
efficiency. By analyzing this data, I aim to gain valuable insights into baggage trends,
identify potential areas of improvement, and possibly forecast future baggage volumes.
Visualization:
In the analysis, time series plots were generated for passenger complaints for three different
airlines: 'American Eagle', 'Delta Air Lines', and 'Southwest Airlines'. These plots illustrate
the number of complaints over time for each airline, revealing distinct patterns and trends.
Time Series Plots for Baggage Complaints:
The plots are:
4
Observations:
American Eagle Airlines:
The plot for American Eagle Airlines shows fluctuations in the number of complaints
over the years.
There seems to be a seasonal pattern, with peaks and dips in different months.
Generally, the number of complaints appears to increase from 2004 to 2007, then
decrease and stabilize from 2008 onwards.
Hawaiian Airlines:
The plot for Hawaiian Airlines also exhibits fluctuations, but with less variability
compared to American Eagle. There might be some seasonal patterns, but they are
less pronounced.
Complaints show a relatively stable trend from 2004 to 2008, with a slight increase in
later years.
United Airlines:
5
United Airlines' plot indicates a more stable trend with fewer fluctuations compared to
the other airlines.
There are some noticeable peaks, especially in the earlier years, but overall, the
number of complaints remains relatively consistent.
There seems to be an increase in complaints around 2006-2007, followed by a
decrease and then stabilization.
Overall, It seems that American and United have more fluctuating baggage
complaint metric.
ACF Plots for Baggage Complaints:
6
Observations:
American Eagle Airlines ACF:
The ACF plot for American Eagle Airlines shows significant autocorrelation at lag 1 and lag 12.
This indicates a yearly pattern, as the peaks occur at the 1-month and 12-month lags.
The autocorrelation gradually decreases after lag 12, suggesting a seasonal pattern.
Hawaiian Airlines ACF:
The ACF plot for Hawaiian Airlines displays autocorrelation at lag 1 and lag 12, like American
Eagle.
However, the autocorrelation values are lower compared to American Eagle, indicating less
pronounced seasonality.
United Airlines ACF:
United Airlines' ACF plot shows significant autocorrelation at lag 1 and lag 12, like the other
airlines.
The autocorrelation values are relatively lower compared to American Eagle but like Hawaiian
Airlines.
Decomposition
Breaking down time series data into its parts - trend, seasonality, and residual - is a
way to separate the data into different pieces for better understanding. It's like taking
apart a puzzle to see each piece clearly.
Trend: This part shows the general direction in which the data is moving over a long
period. It helps us see if the data is increasing, decreasing, or staying steady over
time.
Seasonality: This part shows any repeating patterns or cycles that happen within
shorter time frames, like months or seasons. For example, sales might go up during
holidays every year.
7
Residual: This is what's left after removing the trend and seasonality. It includes
random fluctuations or noise that are not explained by the trend or seasonality.
By understanding these parts, we can make more accurate predictions about the
future and spot any unusual things happening in the data. It's like looking at the big
picture (trend), the repeating patterns (seasonality), and the random bumps (residual)
to get a clearer view of what's going on.
8
In these plots, the trend component shows an increase in the number of complaints to,
followed by a gradual decrease. The strength of the trend is quite significant, as it
shows a clear upward and then downward movement over the years. American and
United have almost the same Baggage complain trend.
The seasonal plots reveal recurring fluctuations in Baggage Complaints, indicating a
consistent seasonal effect. These patterns appear to maintain a stable strength over the
observed period, with regular peaks and troughs throughout.
In this plot, the residual component exhibits fluctuations of varying sizes over time,
indicating some volatility. The remainder component does not display any distinct
patterns, as expected, since it represents the unpredictable or random part of the
data.
Forecasting and Analysis
For this analysis, we employed two fundamental models: Exponential Smoothing and
ARIMA, to forecast future trends in the baggage complaints data. Both models were
applied to the Baggage Complaints dataset for American Eagle Airlines, Hawaiian
Airlines, and United Airlines. The forecasts were then compared based on their
accuracy using established metrics in time series analysis.
Exponential Smoothing Forecast
Exponential Smoothing is a simple yet effective method for forecasting time series
data. The model was fitted to the Baggage Complaints data for each airline, and
forecasts were generated. The resulting forecasts show a smooth trend, capturing
the overall direction of the complaints over time. This method is particularly useful for
capturing trends and seasonality in the data.
The plot for American Airline is:
9
The residual plot is:
The residual plot indicates that the residuals are mostly random around zero,
suggesting that the model captures the patterns in the data effectively.
For Hawaiian Airline, the plots are as:
10
The residual plot indicates that the residuals are mostly random around zero,
suggesting that the model captures the patterns in the data effectively.
For United Airline:
11
The residual plot indicates that the residuals are mostly random around zero,
suggesting that the model captures the patterns in the data effectively.
Arima Forecast:
ARIMA (AutoRegressive Integrated Moving Average) is a time series forecasting
method that combines autoregressive, differencing, and moving average
components. It's used to predict future values based on past data patterns, making
time series data stationary for analysis. The model is defined by three parameters: p
(AR), d (I), and q (MA), representing the order of each component.
The plots for American Eagle are:
12
For the Hawaiian are:
13
For United Airline, the plots are:
14
Analysis
Accuracy for American eagle flights Baggage Complaints are:
Exponential Moodel:
ARIMA Model:
Comparing these metrics, we are looking for lower values of RMSE, MAE, MPE, MAPE,
and MASE, as well as a value of ACF1 closer to 0, indicating better model
performance. In this case, both models have very similar metrics, with the ARIMA
model slightly outperforming the Exponential Smoothing model in terms of ME,
RMSE, MAE, MPE, MAPE, and MASE. However, the difference is very small.
Therefore, based on these metrics, we can conclude that the ARIMA model performs
slightly better than the Exponential Smoothing model for this American Flights.
Accuracy for Hawaiian flights Baggage Complaints are:
Exponential Forecast:
ARIMA Forecast:
15
In this case, both models have nearly identical metrics across all measures.
However, the ARIMA model has a slightly lower ME and RMSE, while the
Exponential Smoothing model has slightly lower MAE, MPE, and MAPE. The MASE
and ACF1 values are very close for both models.
Therefore, based on these metrics, we can conclude that both models perform
similarly for Hawaiian. The choice between them could depend on other factors such
as ease of interpretation, computational efficiency, or specific requirements of the
forecasting task.
Accuracy for United flights Baggage Complaints are:
Exponential Forecast:
ARIMA Forecast:
Both models have similar metrics across most measures. The Mean Error (ME) for
exponential is negative and quite different from ARIMA very close to 0 ME. However,
the other metrics like RMSE, MAE, MPE, MAPE, and MASE are almost identical.
Overall, ARIMA has marginally better performance in terms of RMSE and MAE, while
Exponential has a slightly better MPE. The differences are very small, so the choice
between these models could depend on other factors such as interpretability,
computational efficiency, or specific requirements of the forecasting task.
Conclusion
To conclude our analysis,
16
Seasonal patterns are evident in all three airlines' Baggage Complaints, with peaks
observed at specific times of the year.
The ARIMA model generally performed slightly better in forecasting Baggage
Complaints for American Eagle and United Airlines, while both models showed
similar performance for Hawaiian Airlines.
Baggage Complaints are critical indicators of customer satisfaction and operational
efficiency, highlighting the importance of monitoring and optimizing baggage handling
processes.
Recommendations for Airlines include implementing real-time tracking systems,
enhancing staff training for customer service during baggage claim, and proactive
communication during flight cancellations to manage expectations.
The analysis provides valuable insights into the baggage-related challenges faced by
these airlines, offering a foundation for proactive measures to improve baggage
handling procedures, enhance customer satisfaction, and optimize operational
efficiency. Further exploration into customer feedback surveys and competitor
benchmarks could provide additional context for continuous improvement in baggage
handling processes.
Appendix
library(readxl)
library(fpp3)
library(tidyverse)
library(ggplot2)
library(forecast)
For Ameican Airlines:
baggagecomplaints <- baggagecomplaints_1_
baggagecomplaints
#####American Eagles
Abaggage_Data <- baggagecomplaints %>%
mutate(Date = [Link](paste0("01/", Date), format = "%d/%m/%Y"))%>%
filter(str_detect(Airline, "American Eagle"))
###Visualization:
#TIME SERIES PLOT
Abaggage_Data %>%
ggplot(aes(x = Date, y = Baggage)) +
geom_line(color = "blue") +
labs(title = "Time Series Plot - Passenger Complaints for American Eagle Airlines",
17
x = "Date",
y = "No. of complaints")+
theme_minimal()
Abaggage_Data %>%
ggplot(aes(x = Date, y = Baggage_share)) +
geom_line(color = "lightblue") +
labs(title = "Time Series Plot - Boarded Passenger Complaints for American Eagle
Airlines",
x = "Date",
y = "Share of Complaints among Passengers") +
theme_minimal()
Abaggage_Data %>%
ggplot(aes(x = Date, y = Cancel_share)) +
geom_line(color = "darkblue") +
labs(title = "Time Series Plot - Cancel Flights for American Eagle Airlines",
x = "Date",
y = "Share of Cancel Flights") +
theme_minimal()
#ACF PLOT
Acf(Abaggage_Data$Baggage, main = "ACF Plot - Baggage Complaints for American")
Acf(baggage_Data$Baggage_share, main = "ACF Plot - Share of complaints in Boarded
Fligts")
Acf(baggage_Data$Baggage, main = "ACF Plot - Share of cancel Flights")
#DECOMPOSITION
Abaggage_dcmp <- ts(Abaggage_Data$Baggage, start = c(2005, 4), frequency = 12)
decomposition_Abaggage <- decompose(Abaggage_dcmp)
autoplot(decomposition_Abaggage, ) +
labs(title = "Decomposition of Baggage Complaints of American",
y = "No of Complaints")
#EXPONENTIAL SMOOTHENING FORECAST
#Baggage
Abaggage_train <- Abaggage_Data %>%filter(year(Date)==2005)
Abaggage_test <- Abaggage_Data %>% filter (year(Date)== 2006)
exp_modelA <- forecast::ets(Abaggage_train$Baggage)
exp_forecastA <- forecast::forecast(exp_modelA, h = 12)
autoplot(exp_forecastA) +
18
labs(title = "Exponential Smoothing Forecast Baggage Complaints for American",
y = "No. of Complaints",
x = "Time")
exp_residualsA <- exp_forecastA$residuals
plot(exp_residualsA, type = "l", main = "Residual Plot - Exponential Smoothing",
xlab = "Time", ylab = "Residuals")
exp_accuracyA <- accuracy(exp_forecastA)
exp_accuracyA
#ARIMA MODEL
arima_modelA <- forecast::[Link](Abaggage_train$Baggage)
arima_forecastA <- forecast::forecast(arima_modelA, h = 12)
autoplot(arima_forecastA) +
labs(title = "ARIMA Forecast for Baggage Complaints American",
y = "No. of Complaints",
x = "Time")
arima_residualsA <- resid(arima_modelA)
plot(arima_residualsA, type = "l", main = "Residual-ARIMA Forecast for Baggage
Complaints",
xlab = "Time", ylab = "Residuals")
exp_accuracyA <- accuracy(arima_forecastA)
exp_accuracyA
For Hawaiian Airline:
library(readxl)
library(fpp3)
library(tidyverse)
library(ggplot2)
library(forecast)
baggagecomplaints <- baggagecomplaints_1_
baggagecomplaints
#####Hawaiian
Hbaggage_Data <- baggagecomplaints %>%
mutate(Date = [Link](paste0("01/", Date), format = "%d/%m/%Y"))%>%
filter(str_detect(Airline, "Hawaiian"))
###Visualization:
#TIME SERIES PLOT
Hbaggage_Data %>%
ggplot(aes(x = Date, y = Baggage)) +
geom_line(color = "green") +
labs(title = "Time Series Plot - Passenger Complaints for Hawaiian Eagle Airlines",
19
x = "Date",
y = "No. of complaints")+
theme_minimal()
Abaggage_Data %>%
ggplot(aes(x = Date, y = Baggage_share)) +
geom_line(color = "lightblue") +
labs(title = "Time Series Plot - Boarded Passenger Complaints for American Eagle
Airlines",
x = "Date",
y = "Share of Complaints among Passengers") +
theme_minimal()
baggage_Data %>%
ggplot(aes(x = Date, y = Cancel_share)) +
geom_line(color = "darkblue") +
labs(title = "Time Series Plot - Cancel Flights for American Eagle Airlines",
x = "Date",
y = "Share of Cancel Flights") +
theme_minimal()
###ACF plot
#ACF PLOT
Acf(Hbaggage_Data$Baggage, main = "ACF Plot - Baggage Complaints Hawaiian")
#####Decomposition
Hbaggage_dcmp <- ts(Hbaggage_Data$Baggage, start = c(2005, 4), frequency = 12)
decomposition_Hbaggage <- decompose(Hbaggage_dcmp)
autoplot(decomposition_Hbaggage, ) +
labs(title = "Decomposition of Baggage Complaints of Hawaiian",
y = "No of Complaints")
#EXPONENTIAL SMOOTHENING FORECAST
#Baggage
Hbaggage_train <- Hbaggage_Data %>%filter(year(Date)==2005)
Hbaggage_test <- Hbaggage_Data %>% filter (year(Date)== 2006)
exp_modelH <- forecast::ets(Hbaggage_train$Baggage)
exp_forecastH <- forecast::forecast(exp_modelH, h = 12)
autoplot(exp_forecastH) +
labs(title = "Exponential Smoothing Forecast Baggage Complaints for Hawaiian",
y = "No. of Complaints",
x = "Time")
20
exp_residualsH <- exp_forecastH$residuals
plot(exp_residualsH, type = "l", main = "Residual Plot - Exponential Smoothing",
xlab = "Time", ylab = "Residuals")
exp_accuracyH <- accuracy(exp_forecastH)
exp_accuracyH
#ARIMA MODEL
arima_modelH <- forecast::[Link](Hbaggage_train$Baggage)
arima_forecastH <- forecast::forecast(arima_modelH, h = 12)
autoplot(arima_forecastH) +
labs(title = "ARIMA Forecast for Baggage Complaints Hawaiian",
y = "No. of Complaints",
x = "Time")
arima_residualsH <- resid(arima_modelH)
plot(arima_residualsH, type = "l", main = "Residual-ARIMA Forecast for Baggage
Complaints",
xlab = "Time", ylab = "Residuals")
exp_accuracyH <- accuracy(arima_forecastH)
exp_accuracyH
21