程序代写 ECON7350: Applied Econometrics for Macroeconomics and Finance

ECON7350: Applied Econometrics for Macroeconomics and Finance
Tutorial 2: Forecasting Univariate Processes – I
At the end of this tutorial you should be able to:
• derive theoretical properties of ARMA processes;

Copyright By PowCoder代写 加微信 powcoder

• compute the theoretical ACF and PACF for a given ARMA processes;
• use R to compute and plot the sample ACF and PACF for time series data.
Problems with Solutions
1. Derive the expected value, variance, covariance, autocorrelation function (ACF), and partial autocorrelation function (PACF) for the following data
generating processes (DGPs):
(a) AR(1): yt = a0 + a1yt−1 + εt, 0 ≤ |a1| < 1; • Expected value: yt =a0 +a1yt−1 +εt; 0≤|a1|<1 E(yt) = μ = a0 + a1E(yt−1) + E(εt) μ= a0 ; sinceE(yt−1)=μ Var(yt) = γ0 = a21Var(yt−1) + Var(εt) + 2cov(a1yt−1, εt) γ0 = 1 − a2 ; since Var(yt−1) = γ0, cov(yt−1, εt) = 0 • Variance: • Covariance: – Set a0 = 0 without loss of generality – γ1 (k=1) – γ2 (k=2) – γk (k>2)
• Autocorrelation: – ρ1 (k = 1)
– ρ2 (k = 2)
– ρk (k > 2)
• Partial autocorrelation:
– φ11 – φ22
cov(yt, yt−k) = γk = E(ytyt−k)
= E((a1yt−1 + εt)yt−k)
γ1 = E((a1yt−1 + εt)yt−1) σ2
=a11−a2 =a1γ0 1
γ2 = E((a1yt−1 + εt)yt−2)
2σ2 2 =a11−a2 =a1γ0
γk = E((a1yt−1 + εt)yt−k)
kσ2 k =a11−a2 =a1γ0
ρ1 = γ1 = a1 γ0
ρ 2 = γ 2 = a 21 γ0
ρ k = γ k = a k1 γ0
φ11 =ρ1 =a1
φ22 = (ρ2 − ρ21)/(1 − ρ21) = (a21 − a21)/(1 − a21) =0

ρ3 − 􏰝3−1 φ2,j ρ3−j j=1
φ33= 1−􏰝3−1φ3−1,jρj j=1
a31 − φ21ρ2 − φ22ρ1 = 1−􏰝3−1φ3−1,jρj
a 31 − a 1 a 21 + 0
= 1 − 􏰝3−1 φ3−1,j ρj j=1
φ21 = φ1,1 − φ22φ1,1 = φ1,1
(b) MA(1): yt = b0 + b1εt−1 + εt;
• Expected value:
• Variance:
E(yt) = b0 + b1E(εt−1) + E(εt) =μ
Var(yt) = γ0 = b21Var(εt−1) + Var(εt) + 2cov(εt, εt−1) γ0 =σ2(1+b21)
• Covariance:
– Set μ = 0 without loss of generality
cov(yt, yt−k) = γk = E(ytyt−k)
= E((b1εt−1 + εt)yt−k)
cov(yt,yt−k) > 0 for k = 1, cov(yt,yt−k) = 0 for k > 1 – γ1 (k=1)

– γ2 (k=2)
– γk (k>2)
• Autocorrelation: – ρ1 (k = 1)
– ρk (k > 1)
• Partial autocorrelation:
– φ11 – φ22
γ1 = E((b1εt−1 + εt)yt−1)
= E(b1εt−1(b1εt−2 + εt−1) + εtyt−1) = b1σ2
= b1 ×γ0; sinceσ2 =γ0/(1+b21) 1 + b 21
γ2 = E((b1εt−1 + εt)yt−2)
= 0; since yt−2 is not a function of εt or εt−1
γk = E((b1εt−1 + εt)yt−k) =0
γ 0 1 + b 21
ρk = γk = 0 γ0
φ22 = (ρ2 − ρ21)/(1 − ρ21) = (0 − ρ21)/(1 − ρ21) = −ρ21/(1 − ρ21)
ρ −􏰝3−1φ ρ
3 j=1 2,j 3−j
φ33= 1−􏰝3−1φ ρ j=1 2,j j
ρ3 − φ21ρ2 − φ22ρ1 = 1−􏰝3−1φ ρ
ρ31/(1 − ρ21)
=1−􏰝3−1φ ρ ; sinceρ2 =ρ3 =0
j=1 2,j j 4

ARMA(1,1): yt =a0 +a1yt−1 +b1εt−1 +εt,0≤|a1|<1. • Expected value: • Variance: E(yt) = a0 + a1E(yt−1) + b1E(εt−1) + E(εt) μ= a0 ; sinceE(yt)=E(yt−1)=μ Var(yt) = γ0 = Var(a0) + a21Var(yt−1) + b21Var(εt−1) + Var(εt) + 2cov(a1yt−1, b1εt−1) + 2cov(a1yt−1, εt) + 2cov(b1εt−1, εt) γ0=1+b21+2a1b1σ2, sincecov(a1yt−1,b1εt−1)=a1b1E(ε2t−1) 1 − a 21 – To show cov(a1yt−1, b1εt−1) = a1b1E(ε2t−1) you can proceed as follows cov(a1yt−1, b1εt−1) = = E([a1(a1yt−2 + b1εt−2 + εt−1)](b1εt−1)) is the only non-zero expected value. • Covariance: – Set μ = 0 without loss of generality cov(yt, yt−k) = γk = E(ytyt−k) – γ1 (k=1) – γk (k≥2) • Autocorrelation: = E((a1yt−1 + b1εt−1 + εt)yt−k) γ1 = (1 + a1b1)(a1 + b1)σ2 1 − a 21 γk = a1γk−1 E[(a1yt−1)(b1εt−1)] = E(a1 εt−1 b1 εt−1 ) – ρ1 (k = 1) – ρk (k ≥ 2) ρ1 = (1 + a1b1)(a1 + b1) 1 + b 21 + 2 a 1 b 1 ρk = a1ρk−1 – Autoregressive pattern dominates for k > 1. • Partial autocorrelation:
– φ11 – φ22
φ22 = (ρ2 − ρ21)/(1 − ρ21) = (a1ρ1 − ρ21)/(1 − ρ21)
ρ3 − 􏰝3−1 φ2,j ρ3−j j=1
1 − 􏰝3−1 φ2,jρj j=1
a21ρ1 − φ21a1ρ1 − φ22ρ1 1 − 􏰝3−1 φ2,jρj
φ21 = φ11 − φ22φ11
= ρ1[1 − (a1ρ1-ρ21)/(1-ρ21)]
– Moving average pattern dominates for k > 1.
2. Compute the true ACF values for the following DGPs:
DGP1: yt = 0.75yt−1 + εt;
ρ0 = 1, ρ1 = 0.75, . . . , ρk = 0.75k . The ACF will decay geometrically.
DGP2: yt = −0.75yt−1 + εt;

Solution ρ0 = 1, ρ1 = −0.75, . . . , ρk = (−1)k0.75k. The ACF will decay in a dampened oscillatory path.
• DGP3: yt = 0.95yt−1 + εt;
Solution ρ0 = 1, ρ1 = 0.95, . . . , ρk = 0.95k . The ACF will decay geometrically but at a much slower rate than DGP1.
• DGP4: yt = 0.5yt−1 + 0.25yt−2 + εt;
Solution For the AR(2) model yt = a0 + a1yt−1 + a2yt−2 + εt, ρ0 = 1, ρ1 = a1/(1 − a2), …, ρk = a1ρk−1 + a2ρk−2. Thus, ρ0 = 1, ρ1 = 2/3, ρ2 = 7/12, …, ρk = a1ρk−1 + a2ρk−2 for k ≥ 2.
DGP5: yt = 0.25yt−1 − 0.5yt−2 + εt;
ρ0 =1,ρ1 =1/6,ρ2 =−11/24,…,ρk =a1ρk−1+a2ρk−2 fork≥2.
DGP6: yt = 0.75εt−1 + εt;
For the MA(q) model yt = b0 +b1εt−1 +···+bqεt−q +εt, the ACF cuts offatk=q—i.e.,ρk =0forallk>q. Thus,ρ0 =1,ρ1 =b1/(1+b21)=12/25, ρk =0fork≥2.
• DGP7: yt = 0.75εt−1 − 0.5εt−2 + εt;

Solution ρ0=1andρk=0fork≥3.ρ1=b1(1+b2)/(1+b21+b2)=6/29and ρ2 = b2/(1 + b21 + b2) = −8/29.
• DGP8: yt = 0.75yt−1 + 0.5εt−1 + εt.
Solution For the ARMA(1, 1) model yt = a0 + a1yt−1 + b1εt−1 + εt, ρ0 = 1, ρ1 = (1+a1b1)(a1 +b1)/(1+b21 +2a1b1), ρk = a1ρk−1 for all k ≥ 2. Thus, ρ0 = 1,ρ1 = 0.859, ρ2 = 0.645, …
3. The data file arma.csv contains (simulated) data for each of the DGPs in Question 2. Import the data into R. Compute, plot, and describe the behaviour of the ACF and PACF for each DGP. Discuss the effects of parameter signs. Hint: use the acf and pacf commands, respectively.
Solution Load the data using the read.delim command with the sep = “,” option as it is comma delimited.
mydata <- read.delim("arma.csv", header = TRUE, sep = ",") The ACF and PACF plots can be generated for all eight GDPs quickly using the for loop. Note that we index each column in mydata as 1 + i because the first column contains the time variable t. The option main is passed to plot—we assign it the name of a given column, which corresponds to the GDP in the loop that the sample ACF/PACF are being computed for. for (i in 1:8) { acf(mydata[1 + i], main = colnames(mydata[1 + i])) pacf(mydata[1 + i], main = colnames(mydata[1 + i])) 0 5 10 15 20 25 0 5 10 15 20 25 Partial ACF ACF 0.0 0.2 0.4 0.6 0.0 0.2 0.4 0.6 0.8 1.0 0 5 10 15 20 25 0 5 10 15 20 25 Partial ACF ACF −0.6 −0.4 −0.2 0.0 −0.5 0.0 0.5 1.0 0 5 10 15 20 25 0 5 10 15 20 25 Partial ACF ACF 0.0 0.2 0.4 0.6 0.8 0.0 0.2 0.4 0.6 0.8 1.0 0 5 10 15 20 25 0 5 10 15 20 25 Partial ACF ACF 0.0 0.2 0.4 0.6 0.0 0.2 0.4 0.6 0.8 1.0 0 5 10 15 20 25 0 5 10 15 20 25 Partial ACF ACF −0.5 −0.3 −0.1 0.1 −0.5 0.0 0 5 10 15 20 25 0 5 10 15 20 25 Partial ACF ACF −0.2 0.0 0.2 0.4 0.0 0.2 0.4 0.6 0.8 1.0 0 5 10 15 20 25 0 5 10 15 20 25 Partial ACF ACF −0.4 −0.2 0.0 0.1 0.2 −0.2 0.2 0.6 1.0 0 5 10 15 20 25 0 5 10 15 20 25 Partial ACF ACF −0.2 0.2 0.4 0.6 0.8 0.0 0.2 0.4 0.6 0.8 1.0 Interpretation: • PACF: One non-zero peak. ACF: Decays geometrically from k = 2 onwards as the AR(1) component dominates. ACF: Decays geometrically as parameter is positive. • PACF: One non-zero peak. ACF: Decays in a dampened oscillatory path as parameter is negative. • PACF: One non-zero peak. ACF: Decays geometrically but slower than DGP1. • PACF: Two non-zero peaks. ACF: Decays geometrically as parameter is positive. ACF: Decays in an oscillatory path as one parameter is negative (and large in absolute value). • PACF: Two non-zero peaks. • PACF: Decays in an oscillatory path. ACF: One non-zero peak. • PACF: Decays in an oscillatory path. ACF: Two non-zero peak. • PACF: Decays in an oscillatory path from k = 2 as the MA(1) component dominates. 程序代写 CS代考 加微信: powcoder QQ: 1823890830 Email: powcoder@163.com