程序代写 ARIMA Models

ARIMA Models

2021
©Fidelio Statistical Services ARIMA Models 1 / 21

Nonstationarity
©Fidelio Statistical Services ARIMA Models 2 / 21

Nonstationarity
To fit ARMA models we need stationary series, but many series are not
Generally a trend can be seen
Even if no trend there are major shifts in level
While actual measurements are a problem, what about first differences?
For ease of notation I introduce a new operator, the difference operator, ∇
∇Xt =Xt −Xt−1
Notation similar to backshift operator in that ∇k Xt = Xt − Xt−k
©Fidelio Statistical Services ARIMA Models 3 / 21

Nonstationarity
©Fidelio Statistical Services ARIMA Models 4 / 21

PACF and ACF required
©Fidelio Statistical Services ARIMA Models 5 / 21

PACF and ACF required
©Fidelio Statistical Services ARIMA Models 6 / 21

ACF of differenced series
©Fidelio Statistical Services ARIMA Models 7 / 21

PACF and ACF required
©Fidelio Statistical Services ARIMA Models 8 / 21

ARIMA Processes
Time series of differences of the original time series may be an ARMA model
If ∇d{Xt} = {Yt} and {Yt} is an ARMA(p,q) process, then {Xt} is an ARIMA(p,d,q) process.
ARIMA stands for AutoRegressive Integrated Moving Average The d-term is the order of integration
∇dXt is applying ∇ to {Xt} repeatedly, d times;
∇2Xt =∇[∇Xt]
= ∇[Xt − Xt−1]
= (Xt − Xt−1) − (Xt−1 − Xt−2) = Xt − 2Xt−1 + Xt−2
©Fidelio Statistical Services ARIMA Models 9 / 21

Differencing to get Stationarity in Series With Trend
Almost always d ≤ 2, and usually d ≤ 1
d = 0 is what you should start from as you start by looking at original data
Fractional differencing is studied (ARFIMA), but too complicated for this course
Differencing may not solve all your problems in getting a good model fit (forecast)
So how do we go about it?
©Fidelio Statistical Services ARIMA Models 10 / 21

Retail Trade Quarterly
©Fidelio Statistical Services ARIMA Models 11 / 21

ACF of Raw Retail Trade Quarterly
©Fidelio Statistical Services ARIMA Models 12 / 21

∇{Xt }
©Fidelio Statistical Services ARIMA Models 13 / 21

ACF of ∇{Xt}
©Fidelio Statistical Services ARIMA Models 14 / 21

∇4{Xt}
©Fidelio Statistical Services ARIMA Models 15 / 21

ACF of ∇4{Xt}
©Fidelio Statistical Services ARIMA Models 16 / 21

SARIMA Models
A D difference, spaced say s apart
s is number of measurements over a year
s = 4 if quarterly, s = 12 if monthly, s = 52 if weekly
d is the detrending and D is the deseasonalising
By doing this difference we are aiming for a stationary process (shifts spaced s and 1 apart) as that allows us to fit an ARMA model
SARIMA stands for Seasonal AutoRegressive Integrated Moving Average
Even if we have s = 52
we are modelling the first and the seasonal difference, so there are
two ARMA components, SARIMA model order (p, d, q) × (P, D, Q)s
All the stuff on using ACF and PACF to find p and q, also applies to P and Q, though first on d differenced series and the other on s differenced series
©Fidelio Statistical Services ARIMA Models 17 / 21

SARIMA Models – the maths
If ∇Ds {Xt} = {Yt} then
φ(B)Φ(Bs)Yt = θ(B)Θ(Bs)Wt
∇Ds is the Dth order difference every s units apart Bs = Bs is the shift back s units,
φ(B)Φ(Bs),θ(B) and Θ(Bs) are polynomials in B of order p, P, q and Q respectively.
When dealing with SARIMA models – as I do frequently – you find the concise notation is what you report. But you need to be able to expand it so you know what is happening to your data (or what you should do to your data before get R to estimate the parameters.
©Fidelio Statistical Services ARIMA Models 18 / 21

SARIMA Models – the formulae
ConsideraSARIMA(1,1,2)×(1,1,1)4 model
Concise representation – and {Xt} are the time series measurements we are using
Yt = ∇4∇1Xt
= ∇4(Xt − Xt−1
= [Xt − Xt−4] − [Xt−2 − Xt−5] =Xt −Xt−2 −Xt−4 +Xt−5
and {Yt} is modelled as
φ(B)Φ(B4)Yt = θ(B)Θ(B4)Wt
with
φ(B) = (1 − φ1B)
Φ(Bs) = (1 − Φ1B4) θ(B) = (1 + θ1B + θ2B2) Θ(Bs) = (1 + Θ1B4
©Fidelio Statistical Services ARIMA Models 19 / 21

SARIMA Models – the practice
If you have seasonal variations then you will need (P,D,Q)s term in ARIMA model
However D=1 quite often as usually seasonality is stable Usually (0, 1, 1)s is best to use
Seasonal variation is not generally affected by events, though COVID-19 is doing this
Seasonality is generally a stable term -– hence the need to take it out as nuisance parameter by seasonal adjustment. Stability usually implies the effect is usually close to average, hence use MA(Q)
©Fidelio Statistical Services ARIMA Models 20 / 21

Steps to ARIMA Modelling
1 Plot series and look at it. What is it like?
2 Transform series?
3 Use all the series?
4 acf of series as is, and differenced series? This may be iterative as may need seasonal as well. This decides I= and Is =?
5 acf and pacf to decide p, q, P, D as required
Recommend simulate models you think it is to ensure acf and pacf look right
6 Fit possible models
You may have a couple of feasible models, so choosing between them.
7 Diagnostics checks. Residual check
8 Forecast
9 Write up with how certain you are
©Fidelio Statistical Services ARIMA Models 21 / 21