Passenger Data
ISYE 6402 Midterm 1
Background
For this midterm exam, you will analyze monthly domestic passenger data for two of largest airports servicing the
New York City metro area: LaGuardia Airport (LGA) and John F. Kennedy International Airport (JFK). The data
records the number of passengers embarking on domestic flights out of each airport each month from January
2003 to December 2019.
library(zoo)
library(lubridate)
library(mgcv)
library(TSA)
library(dynlm)
Instructions on reading the data
To read the data in R , save the file in your working directory (make sure you have changed the directory if
different from the R working directory) and read the data using the R function read.csv()
passengers<-read.csv("Midterm 1 Data.csv")
Part 1: Trend and Seasonality Modeling
1a. Plot the Time Series and the ACF plots for both airports. Comment on the stationarity of both time series based
on these plots. Which (if any) assumptions of stationarity are violated for the two time series?
1/17
,lga_ts <- ts(passengers$LGA, start = 2003, freq = 12)
jfk_ts <- ts(passengers$JFK, start = 2003, freq = 12)
par(mfrow=c(2,2))
ts.plot(lga_ts, main = "LaGuardia Passengers")
ts.plot(jfk_ts, main = "JFK Passengers")
acf(lga_ts, lag.max = 16 * 4, xlab = "Lag", ylab = "ACF", main = "LGA ACF Analysis")
acf(jfk_ts, lag.max = 16 * 4, xlab = "Lag", ylab = "ACF", main = "JFK ACF Analysis")
2/17
, Response: Question 1a Constant mean is violated for both data sets. Also, the ACF plots show that the
autocorrelation is significant with some seasonality. There seems to be a slightly upward trend for both data sets
as well.
1b. Fit a moving average trend and a splines smoothing trend on both time series. Overlay the fitted values
derived from each trend estimation model on the corresponding data and calculate the MAPE for each model.
Comment on the effectiveness of each model to estimate the trend for both series.
#LGA
# convert X axis to 0-1 scale
points_lga <- 1:length(lga_ts)
points_lga <- (points_lga - min(points_lga)) / max(points_lga)
# 1. Fit a moving average model
mav_model_lga <- ksmooth(points_lga, lga_ts, kernel = "box")
mav_fit_lga <- ts(mav_model_lga$y, start = 2003, frequency = 12)
# 2. Fit a splines smoothing model
gam_model_lga <- gam(lga_ts ~ s(points_lga))
gam_fit_lga <- ts(fitted(gam_model_lga), start = 2003, frequency = 12)
#plot
ts.plot(lga_ts, xlab = "", ylab = "LGA", main = "LGA Trend Estimation Comparison")
3/17