You are on page 1of 1

Time Series Cheat Sheet

Plot Time Series Filters Partial Auto-correlation function: pacf() Forecasting


pacf(data, na.action=na.pass)
1. tsplot(x=time, y=data) Linear Filter: filter()
OR: acf(data, type=‘partial’, na.action=na.pass)
filter(data, filter=filter_coefficients, sides=2, Forecasting future observations
given a fitted ARMA model
method="convolution", circular=F)

predict(): Predict future observations given a


fitted ARMA model
2. plot(ts(data, start=start_time, frequency=gap))
predict(arima_model, number_to_predict)

Plot Predicted values and Confidence Interval:


Differencing Filter: diff() fit<-predict(arima_model, number_to_predict)
diff(data, lag=4, differences=1) ts.plot(data,
3. ts.plot(ts(data, start=start_time, frequency=gap)) Parameter Estimation xlim=c(1, length(data)+number_to_predict),

Fit an ARMA time series model to the data ylim=c(0, max(fit$pred+1.96*fit$se)))


lines(length(data)+1:length(data)+
number_to_predict, fit$pred)
ar(): To estimate parameters of an AR model
ar(x=data, aic=T, order.max = NULL,

Simulation c("yule-walker", "burg", "ols", "mle", "yw"))

Autoregression of Order p
Auto-correlation
X t = ϕ1X t−1 + ϕ2 X t−2 + … + ϕp X t−p + Wt
Use ACF and PACF to detect model
Moving Average of Order q
X t = Zt + θ1Zt−1 + θ2 Zt−2 + … + θq Zt−p arima(): To estimate parameters of an AM or
(Complete) Auto-correlation function: acf() OR: autoplot(forecast(arima_model, level=c(95),
ARMA model, and build model
ARMA (p, q) h=number_to_predict))
acf(data, type=‘correlation’, na.action=na.pass) arima(data, order=c(p, 0, q),method=c(‘ML’))
X t = ϕ1X t−1 + ϕ2 X t−2 + … + ϕp X t−p+
Zt + θ1Zt−1 + θ2 Zt−2 + … + θq Zt−p

Simulation of ARMA (p, q)

arima.sim(model=list(ar=c(ϕ1, . . . , ϕp ), AICc(): Compare models using AICC


ma=c(θ1, . . . , θq )), n=n) AICc(fittedModel)

RStudio® is a trademark of RStudio, Inc. • CC BY SA Yunjun Xia, Shuyu Huang • yx2569@columbia.edu, sh3967@columbia.edu • Updated: 2019-10

You might also like