You are on page 1of 21

Homework #1

Stoil Pramatarov

Problem #1

i) .gen lngdp = log(gnp96)

.tsline lngdp
9.2
9
8.8
lngdp

8.6
8.4
8.2

1970q1 1980q1 1990q1 2000q1


Date

We can see that this is a non-stationary stochastic process with a clear positive linear trend and

we must transform it to stationary. The reason for non-stationarity could be a deterministic trend

or a unit root.
. corrgram lngdp

-1 0 1 -1 0 1
LAG AC PAC Q Prob>Q [Autocorrelation] [Partial Autocor]

1 0.9771 1.0011 138.47 0.0000


2 0.9537 -0.3040 271.3 0.0000
3 0.9303 -0.1437 398.61 0.0000
4 0.9073 0.0474 520.58 0.0000
5 0.8841 -0.0245 637.24 0.0000
6 0.8609 0.0796 748.67 0.0000
7 0.8373 0.0396 854.86 0.0000
8 0.8137 0.0785 955.89 0.0000
9 0.7902 0.1917 1051.9 0.0000
10 0.7670 -0.0819 1143 0.0000
11 0.7438 -0.0215 1229.4 0.0000
12 0.7209 0.0258 1311.1 0.0000
13 0.6980 0.1846 1388.3 0.0000
14 0.6751 0.0847 1461.2 0.0000
15 0.6528 0.1241 1529.8 0.0000
16 0.6306 0.0898 1594.3 0.0000
17 0.6094 -0.1059 1655 0.0000
18 0.5881 0.0374 1712.1 0.0000
19 0.5672 -0.0344 1765.6 0.0000
20 0.5462 -0.0349 1815.6 0.0000
21 0.5258 0.0508 1862.3 0.0000
22 0.5065 0.0185 1906 0.0000
23 0.4875 0.0278 1946.8 0.0000
24 0.4694 0.0693 1985 0.0000
25 0.4519 -0.0006 2020.7 0.0000
26 0.4350 0.0575 2054.1 0.0000
27 0.4181 0.1545 2085.1 0.0000
28 0.4014 0.0328 2114 0.0000
29 0.3844 0.0431 2140.8 0.0000
30 0.3671 0.0164 2165.4 0.0000
31 0.3492 0.1646 2187.8 0.0000
32 0.3311 -0.1354 2208.2 0.0000
33 0.3122 -0.0227 2226.5 0.0000
34 0.2937 0.1298 2242.8 0.0000
35 0.2759 -0.0548 2257.4 0.0000
36 0.2589 0.1961 2270.3 0.0000
37 0.2425 -0.0550 2281.8 0.0000
38 0.2262 0.2019 2291.8 0.0000
39 0.2097 0.1056 2300.6 0.0000
40 0.1939 0.0616 2308.1 0.0000

.
.ac lngdp
1.00
0.50
0.00
-0.50
-1.00

0 10 20 30 40
Lag
Bartlett's formula for MA(q) 95% confidence bands

.pac lngdp
1.00
0.50
0.00
-0.50

0 10 20 30 40
Lag
95% Confidence bands [se = 1/sqrt(n)]
From the first 20 lags we see that the model is at least AR (1) from the corrgraph, but maybe

even AR (2 or 3). Also, we have at least MA (1) or maybe MA (2) form the PACF graph.

ii) .gen trend = _n+1

. reg lngdp trend

Source SS df MS Number of obs = 142


F( 1, 140) =16065.46
Model 10.7699023 1 10.7699023 Prob > F = 0.0000
Residual .09385267 140 .000670376 R-squared = 0.9914
Adj R-squared = 0.9913
Total 10.863755 141 .077047908 Root MSE = .02589

lngdp Coef. Std. Err. t P>|t| [95% Conf. Interval]

trend .0067185 .000053 126.75 0.000 .0066137 .0068233


_cons 8.184216 .0044147 1853.87 0.000 8.175488 8.192944

. predict lngdp_dt, res

. ac lngdp_dt
1.00
0.50
0.00
-0.50

0 10 20 30 40
Lag
Bartlett's formula for MA(q) 95% confidence bands
1.00
0.50
0.00
-0.50

0 10 20 30 40
Lag
95% Confidence bands [se = 1/sqrt(n)]

From the ACF graph we can see that AR(3) is in fact possible. And PACF indicates that MA(5)

is also possible. The ideal model must have no serial correlation and should have as much

significant coefficients as possible.

.arma lngdp_dt, ar(1/3) ma(1/5)

ARIMA regression

Sample: 1967q1 - 2002q2 Number of obs = 142


Wald chi2(8) = 18544.71
Log likelihood = 498.4377 Prob > chi2 = 0.0000

OPG
lngdp_dt Coef. Std. Err. z P>|z| [95% Conf. Interval]

lngdp_dt
_cons -.0024852 .0023017 -1.08 0.280 -.0069964 .002026

ARMA
ar
L1. .9113501 .1668284 5.46 0.000 .5843725 1.238328
L2. .9729093 .2783564 3.50 0.000 .4273408 1.518478
L3. -.9042099 .1328807 -6.80 0.000 -1.164651 -.6437685

ma
L1. .2572648 2038.151 0.00 1.000 -3994.446 3994.961
L2. -.7920694 2581.025 -0.00 1.000 -5059.509 5057.925
L3. -.2213785 948.3596 -0.00 1.000 -1858.972 1858.529
L4. -.2079293 501.6224 -0.00 1.000 -983.3699 982.954
L5. -.0358886 74.32315 -0.00 1.000 -145.7066 145.6348

/sigma .0070985 7.351845 0.00 0.500 0 14.41645

Note: The test of the variance against zero is one sided, and the two-sided
confidence interval is truncated at zero.
. estat ic

Model Obs ll(null) ll(model) df AIC BIC

. 142 . 498.4377 10 -976.8753 -947.3171

From testing and “.estat ic” we can see that

.arima lngdp_dt, ar(1/2) ma(1) is the a good model. The lower the AIC and BIC, the better.

ARIMA regression

Sample: 1967q1 - 2002q2 Number of obs = 142


Wald chi2(3) = 5042.76
Log likelihood = 497.2368 Prob > chi2 = 0.0000

OPG
lngdp_dt Coef. Std. Err. z P>|z| [95% Conf. Interval]

lngdp_dt
_cons .000694 .0073461 0.09 0.925 -.0137041 .0150921

ARMA
ar
L1. 1.712373 .1244745 13.76 0.000 1.468407 1.956338
L2. -.7562214 .1172441 -6.45 0.000 -.9860155 -.5264272

ma
L1. -.5167065 .174625 -2.96 0.003 -.8589653 -.1744478

/sigma .0072252 .0003489 20.71 0.000 .0065413 .007909

Note: The test of the variance against zero is one sided, and the two-sided
confidence interval is truncated at zero.

. estat ic

Model Obs ll(null) ll(model) df AIC BIC

. 142 . 497.2368 5 -984.4737 -969.6946

Note: N=Obs used in calculating BIC; see [R] BIC note


. gen dlngdp = d.lngdp
(1 missing value generated)
iii)
0.30
0.20
0.10
0.00
-0.10
-0.20

0 10 20 30 40
Lag
Bartlett's formula for MA(q) 95% confidence bands

The graph above is the ACF and the graph below is PACF.
0.30
0.20
0.10
0.00
-0.10
-0.20

0 10 20 30 40
Lag
95% Confidence bands [se = 1/sqrt(n)]

ACF indicates AR(1) and PACF indicates at least MA(1) but it can be up to MA(5)
ARIMA regression

Sample: 1967q2 - 2002q2 Number of obs = 141


Wald chi2(2) = 26.13
Log likelihood = 489.6174 Prob > chi2 = 0.0000

OPG
dlngdp Coef. Std. Err. z P>|z| [95% Conf. Interval]

dlngdp
_cons .0069254 .0011322 6.12 0.000 .0047063 .0091445

ARMA
ar
L1. .5777239 .2093146 2.76 0.006 .1674748 .9879729

ma
L1. -.2994382 .2514368 -1.19 0.234 -.7922452 .1933689

/sigma .0075074 .000356 21.09 0.000 .0068096 .0082052

Note: The test of the variance against zero is one sided, and the two-sided
confidence interval is truncated at zero.

. estat ic

Model Obs ll(null) ll(model) df AIC BIC

. 141 . 489.6174 4 -971.2348 -959.4398

iv) Checking “estat ic” of lngdp_dt for ARMA(p,q) whith p-=0,1,2,3 and q=0,1,2,3 and

looking for the lowest values of AIC and BIC we see that the model would be ARMA

(2,1)
ARIMA regression

Sample: 1967q1 - 2002q2 Number of obs = 142


Wald chi2(3) = 5042.76
Log likelihood = 497.2368 Prob > chi2 = 0.0000

OPG
lngdp_dt Coef. Std. Err. z P>|z| [95% Conf. Interval]

lngdp_dt
_cons .000694 .0073461 0.09 0.925 -.0137041 .0150921

ARMA
ar
L1. 1.712373 .1244745 13.76 0.000 1.468407 1.956338
L2. -.7562214 .1172441 -6.45 0.000 -.9860155 -.5264272

ma
L1. -.5167065 .174625 -2.96 0.003 -.8589653 -.1744478

/sigma .0072252 .0003489 20.71 0.000 .0065413 .007909

Note: The test of the variance against zero is one sided, and the two-sided
confidence interval is truncated at zero.

. estat ic

Model Obs ll(null) ll(model) df AIC BIC

. 142 . 497.2368 5 -984.4737 -969.6946

Note: N=Obs used in calculating BIC; see [R] BIC note

Performing the same check for dgdp ( We create “.gen dgpd = d.gnp96”)

we see that the model has only significant variables (as well as the previous) and lowest AIC and

BIC.

That is ARMA (1,1) of dgpd = ARIMA (1,1,1) of gnp96.


ARIMA regression

Sample: 1967q2 - 2002q2 Number of obs = 141


Wald chi2(2) = 73.97
Log likelihood = -733.9584 Prob > chi2 = 0.0000

OPG
dgdp Coef. Std. Err. z P>|z| [95% Conf. Interval]

dgdp
_cons 42.72132 7.764164 5.50 0.000 27.50384 57.9388

ARMA
ar
L1. .7060583 .1299944 5.43 0.000 .451274 .9608426

ma
L1. -.3902875 .1839289 -2.12 0.034 -.7507815 -.0297935

/sigma 44.06794 2.378168 18.53 0.000 39.40682 48.72906

Note: The test of the variance against zero is one sided, and the two-sided
confidence interval is truncated at zero.

. estat ic

Model Obs ll(null) ll(model) df AIC BIC

. 141 . -733.9584 4 1475.917 1487.712

Note: N=Obs used in calculating BIC; see [R] BIC note

We choose the former model as the best one since it has the highest Wald chi2(2) value.

v) Portmanteau test:

. predict res1, res

. wntestq res1

Portmanteau test for white noise

Portmanteau (Q) statistic = 29.2272


Prob > chi2(40) = 0.8956

Ho: No serial correlation

Ha: There exists serial correlation


Since p-value (0.89) is higher that alpha we do not reject Ho.

There is no serial correlation.

Problem #2

i)

. varsoc close

Selection-order criteria
Sample: 12jan2001 - 21dec2001, but with gaps
Number of obs = 42

lag LL LR df p FPE AIC HQIC SBIC

0 -246.185 7576.82 11.7707 11.7859 11.8121


1 -165.067 162.24* 1 0.000 166.962* 7.95557* 7.9859* 8.03832*
2 -164.645 .84402 1 0.358 171.65 7.98309 8.02859 8.10721
3 -164.107 1.0754 1 0.300 175.53 8.00511 8.06577 8.1706
4 -163.884 .44568 1 0.504 182.249 8.04212 8.11794 8.24898

Endogenous: close
Exogenous: _cons

Based on the AIC criterion we should choose lags(1)

. dfuller close, trend regress lags(1)

Augmented Dickey-Fuller test for unit root Number of obs = 140

Interpolated Dickey-Fuller
Test 1% Critical 5% Critical 10% Critical
Statistic Value Value Value

Z(t) -1.562 -4.027 -3.445 -3.145

MacKinnon approximate p-value for Z(t) = 0.8069

D.close Coef. Std. Err. t P>|t| [95% Conf. Interval]

close
L1. -.0345337 .0221076 -1.56 0.121 -.0782528 .0091854
LD. .046481 .0807481 0.58 0.566 -.1132033 .2061654
_trend -.0080875 .018719 -0.43 0.666 -.0451055 .0289305
_cons 41.85266 29.0328 1.44 0.152 -15.56147 99.26678
Ho: non-stationary

Ha: stationary

p-value (0.80) is higher than alpha, so we do not reject Ho, meaning that the time series is non-

stationary.

ii)

. gen lclose = log(close)

. gen dlclose = d.lclose


(56 missing values generated)

ACF:
0.20
0.10
0.00
-0.10
-0.20

0 10 20 30 40
Lag
Bartlett's formula for MA(q) 95% confidence bands
PACF:
0.20
0.10
0.00
-0.10
-0.20

0 10 20 30 40
Lag
95% Confidence bands [se = 1/sqrt(n)]

Both graphs suggest ARMA (0,0) or maybe MA(1), but it is unlikely. I think there is a problem

with the data because I have 51 missing values when graphing the ACF and PACF. The problem

started when I generated the d.lclose variable. Best model would be ARMA (0,0) since MA(1)

has insignificant variable.


iii) Portmanteau test:

. predict res, r
(56 missing values generated)

. wntestq res
(note: time series has 51 gaps)

Portmanteau test for white noise

Portmanteau (Q) statistic = 14.3222


Prob > chi2(40) = 0.9999

Ho: no serial correlation

Ha: serial correlation

Do no reject since p-value (0.99) is higher than alpha = no serial correlation.

Since there is no serial correlation, the chosen model is a good choice for the best model.
Problem #5

i)

. varsoc lusdgbp r_usdgbp

Selection-order criteria
Sample: 1990m5 - 2014m12 Number of obs = 296

lag LL LR df p FPE AIC HQIC SBIC

0 836.065 .000012 -5.63557 -5.62559 -5.61064


1 1858.19 2044.3 4 0.000 1.3e-08 -12.5148 -12.4849 -12.44
2 1878.98 41.577 4 0.000 1.1e-08 -12.6283 -12.5783* -12.5036*
3 1880.38 2.7902 4 0.594 1.1e-08 -12.6107 -12.5408 -12.4361
4 1888.35 15.945* 4 0.003 1.1e-08* -12.6375* -12.5476 -12.4131

Endogenous: lusdgbp r_usdgbp


Exogenous: _cons

AIC suggests lags(4):

. dfuller lusdgbp, trend regress lags(4)

Augmented Dickey-Fuller test for unit root Number of obs = 295

Interpolated Dickey-Fuller
Test 1% Critical 5% Critical 10% Critical
Statistic Value Value Value

Z(t) -3.142 -3.988 -3.428 -3.130

MacKinnon approximate p-value for Z(t) = 0.0966

D.lusdgbp Coef. Std. Err. t P>|t| [95% Conf. Interval]

lusdgbp
L1. -.0453838 .014444 -3.14 0.002 -.0738129 -.0169547
LD. .3813059 .0583912 6.53 0.000 .2663782 .4962335
L2D. -.1202452 .0622548 -1.93 0.054 -.2427773 .0022869
L3D. .1462402 .0619959 2.36 0.019 .0242176 .2682627
L4D. .003736 .0592175 0.06 0.950 -.112818 .1202901
_trend 8.19e-08 .0000146 0.01 0.996 -.0000287 .0000289
_cons -.022776 .0077368 -2.94 0.004 -.0380038 -.0075482
Ho: non-stationary

Ha: stationary

P-value (0.0966) is less than alpha (10%), so we reject Ho, meaning that the nominal ER is

stationary.

. dfuller r_usdgbp, trend regress lags(4)

Augmented Dickey-Fuller test for unit root Number of obs = 295

Interpolated Dickey-Fuller
Test 1% Critical 5% Critical 10% Critical
Statistic Value Value Value

Z(t) -3.501 -3.988 -3.428 -3.130

MacKinnon approximate p-value for Z(t) = 0.0393

D.r_usdgbp Coef. Std. Err. t P>|t| [95% Conf. Interval]

r_usdgbp
L1. -.0551341 .0157482 -3.50 0.001 -.0861302 -.0241379
LD. .3904644 .0580931 6.72 0.000 .2761236 .5048053
L2D. -.1300249 .0621897 -2.09 0.037 -.2524288 -.0076209
L3D. .1614893 .0617784 2.61 0.009 .0398948 .2830838
L4D. .0136806 .0592202 0.23 0.817 -.1028788 .1302399
_trend -.0000156 .0000155 -1.01 0.314 -.0000461 .0000149
_cons -.0238507 .0072517 -3.29 0.001 -.0381238 -.0095775

Here the P-value is 0.03 and again we reject Ho and we see that the real ER is also stationary.

Both are time invariant.


ii)

. vecrank lusdgbp r_usdgbp, trend(const) lags(4)

Johansen tests for cointegration


Trend: constant Number of obs = 296
Sample: 1990m5 - 2014m12 Lags = 4

5%
maximum trace critical
rank parms LL eigenvalue statistic value
0 14 1881.5139 . 13.6698* 15.41
1 17 1887.8902 0.04217 0.9172 3.76
2 18 1888.3488 0.00309

We can see that there is no cointegration (rank 0).


. reg lusdgbp r_usdgbp

Source SS df MS Number of obs = 300


F( 1, 298) = 1316.09
Model 2.00388984 1 2.00388984 Prob > F = 0.0000
Residual .453738674 298 .001522613 R-squared = 0.8154
Adj R-squared = 0.8148
Total 2.45762851 299 .008219493 Root MSE = .03902

lusdgbp Coef. Std. Err. t P>|t| [95% Conf. Interval]

r_usdgbp .9244167 .0254815 36.28 0.000 .8742702 .9745633


_cons -.0616141 .0122639 -5.02 0.000 -.0857488 -.0374793

. predict res, r

. dfuller res, trend regress lags(4)

Augmented Dickey-Fuller test for unit root Number of obs = 295

Interpolated Dickey-Fuller
Test 1% Critical 5% Critical 10% Critical
Statistic Value Value Value

Z(t) -0.653 -3.988 -3.428 -3.130

MacKinnon approximate p-value for Z(t) = 0.9761

D.res Coef. Std. Err. t P>|t| [95% Conf. Interval]

res
L1. -.0063282 .0096935 -0.65 0.514 -.0254073 .0127509
LD. .005477 .059226 0.09 0.926 -.1110937 .1220477
L2D. .0411249 .0570928 0.72 0.472 -.0712472 .1534969
L3D. -.147526 .0570991 -2.58 0.010 -.2599104 -.0351416
L4D. .025751 .0576745 0.45 0.656 -.087766 .1392681
_trend -5.09e-07 4.43e-06 -0.11 0.909 -9.23e-06 8.21e-06
_cons .000099 .0007285 0.14 0.892 -.0013349 .0015328

Engle’s test also shows no cointegration.

Ho: There exists a unit root

Ha: No unit root

P-value (0.97) is higher than alpha so we do no reject Ho, meaning there is a unit root = no

cointegration.
Then we create:

. gen dlusdgbp = d.lusdgbp

. gen dr_usdgbp = d.r_usdgbp

And limit the period:

. var dr_usdgbp dlusdgbp if t<tm(2008m4), lags (1)

Vector autoregression

Sample: 1990m3 - 2008m3 No. of obs = 217


Log likelihood = 1387.839 AIC = -12.73584
FPE = 1.01e-08 HQIC = -12.69809
Det(Sigma_ml) = 9.55e-09 SBIC = -12.64239

Equation Parms RMSE R-sq chi2 P>chi2

dr_usdgbp 3 .020303 0.0850 20.16592 0.0000


dlusdgbp 3 .019915 0.0768 18.05972 0.0001

Coef. Std. Err. z P>|z| [95% Conf. Interval]

dr_usdgbp
dr_usdgbp
L1. -.1324402 .2760863 -0.48 0.631 -.6735594 .4086789

dlusdgbp
L1. .4273131 .2825091 1.51 0.130 -.1263946 .9810208

_cons -.0005495 .0013719 -0.40 0.689 -.0032383 .0021393

dlusdgbp
dr_usdgbp
L1. -.1010777 .2708183 -0.37 0.709 -.6318718 .4297165

dlusdgbp
L1. .3754296 .2771186 1.35 0.175 -.167713 .9185722

_cons -.0001976 .0013457 -0.15 0.883 -.0028351 .00244

.
iii)

Serial Independence:

. varlmar

Lagrange-multiplier test

lag chi2 df Prob > chi2

1 2.2341 4 0.69279
2 3.5085 4 0.47658

H0: no autocorrelation at lag order

Ho: Serially independent

Ha: Serially correlated

Do not reject Ho, so the residuals are serially independent.

Normality:

. varnorm

Jarque-Bera test

Equation chi2 df Prob > chi2

dr_usdgbp 22.849 2 0.00001


dlusdgbp 508.193 2 0.00000
ALL 531.042 4 0.00000

Ho: errors are normally distributed

Ha: errors are not normally distributed

Reject Ho, so they are not normally distributed.


iv)

. fcast compute m1_, step(8)

. fcast graph m1_dr_usdgbp m1_dlusdgbp, observed

Forecast for dr_usdgbp Forecast for dlusdgbp


.05

.05
0

0
-.05

-.05

2008m1 2008m4 2008m7 2008m10 2008m1 2008m4 2008m7 2008m10

95% CI forecast
observed

Not a good one

v) Something does not work here

. graph twoway m1_dr_usdgbp r_usdgbp t if m1_r_usdgbp<. , legend(cols(1))


m1_dr_usdgbp is not a twoway plot type
r(198);

. graph twoway m1_dlusdgbp dlusdgbp t if m1_dlusdgbp <. , legend(cols(1))


m1_dlusdgbp is not a twoway plot type
r(198);

You might also like