Chapter 14

Download as pdf or txt
Download as pdf or txt
You are on page 1of 9

Solutions to Selected Computer Lab Problems and Exercises

in Chapter 14 of Statistics and Data Analysis for Financial


Engineering, 2nd ed. by David Ruppert and David S.
Matteson
c 2016 David Ruppert and David S. Matteson.

Problem 1. The plots and output are below. The time series plot of Tbill does not seem
mean-reverting and the ACF plot has a slow decay also suggesting that the
series is nonstationary.
The time series plot of Tbill.diff seems mean reverting and the ACF plot
decays to 0 reasonably fast, suggesting a stationary series.
For Tbill, the ADF test accepts nonstationarity and the KPSS test rejects
stationarity, so the tests agree with the plots that the series is nonstationary.
For Tbill.diff, the ADF test rejects nonstationarity and the KPSS test ac-
cepts stationarity, so the tests agree with the plots that the series is stationary.
Tbill.diff shows two different types of heteroscedasticity. First, there is
volatility clustering, seen as random bursts of high volatility. Second, there
is more volatility when the mean of the t-bill rate is higher in the late 1970’s
and early 1980’s. The volatility clustering can be accommodated by a GARCH
model. The increased volatility where the mean is higher could be removed by
a transformation, perhaps the log.
12

2
Tbill.diff

0
Tbill

−6 −4 −2
4
0

1960 1980 2000 1960 1980 2000

Time Time

Series Tbill Series Tbill.diff


1.0
0.8

0.6
ACF

ACF
0.4

0.2
0.0

−0.2

0 1 2 3 4 5 0 1 2 3 4 5

Lag Lag

1
> adf.test(Tbill)

Augmented Dickey-Fuller Test

data: Tbill
Dickey-Fuller = -2.5622, Lag order = 6, p-value =
0.3395
alternative hypothesis: stationary

> kpss.test(Tbill)

KPSS Test for Level Stationarity

data: Tbill
KPSS Level = 1.3192, Truncation lag parameter = 3,
p-value = 0.01

Warning message:
In kpss.test(Tbill) : p-value smaller than printed p-value
> adf.test(Tbill.diff)

Augmented Dickey-Fuller Test

data: Tbill.diff
Dickey-Fuller = -6.3425, Lag order = 6, p-value =
0.01
alternative hypothesis: stationary

Warning message:
In adf.test(Tbill.diff) : p-value smaller than printed p-value
> kpss.test(Tbill.diff)

KPSS Test for Level Stationarity

data: Tbill.diff
KPSS Level = 0.15565, Truncation lag parameter = 3,
p-value = 0.1

Warning message:
In kpss.test(Tbill.diff) : p-value greater than printed p-value

Problem 2. (a) The model is yt − mu = ar1 ∗ (yt−1 − mu) + at where at = σt t , and σt2 =
omega + alpha1 ∗ a2t−1 + beta1 ∗ σt−1
2
. Parameters in a Roman font are in the R
output. Also, 1 , 2 , . . . is an iid white noise process.
(b) The estimates are listed below under “Optimal Parameters.” For example,
the estimate of mu is 0.0186.

> library(xts)
> library(rugarch)
> arma.garch.norm = ugarchspec(mean.model=list(armaOrder=c(1,0)),
+ variance.model=list(garchOrder=c(1,1)))
> Tbill.arma.garch.norm = ugarchfit(data=Tbill.diff, spec=arma.garch.norm)
> show(Tbill.arma.garch.norm)

*---------------------------------*
* GARCH Model Fit *
*---------------------------------*

Conditional Variance Dynamics

2
-----------------------------------
GARCH Model : sGARCH(1,1)
Mean Model : ARFIMA(1,0,0)
Distribution : norm

Optimal Parameters
------------------------------------
Estimate Std. Error t value Pr(>|t|)
mu 0.018556 0.032524 0.57054 0.568312
ar1 0.139618 0.069092 2.02075 0.043306
omega 0.016961 0.010715 1.58296 0.113430
alpha1 0.383655 0.065991 5.81378 0.000000
beta1 0.615345 0.041021 15.00090 0.000000

Robust Standard Errors:


Estimate Std. Error t value Pr(>|t|)
mu 0.018556 0.039885 0.46525 0.641752
ar1 0.139618 0.117234 1.19093 0.233681
omega 0.016961 0.030675 0.55293 0.580308
alpha1 0.383655 0.128735 2.98020 0.002881
beta1 0.615345 0.077928 7.89629 0.000000

LogLikelihood : -223.8331

Information Criteria
------------------------------------

Akaike 1.9475
Bayes 2.0211
Shibata 1.9466
Hannan-Quinn 1.9772

Weighted Ljung-Box Test on Standardized Residuals


------------------------------------
statistic p-value
Lag[1] 1.177 0.2780
Lag[2*(p+q)+(p+q)-1][2] 1.203 0.6142
Lag[4*(p+q)+(p+q)-1][5] 4.749 0.1294
d.o.f=1
H0 : No serial correlation

Weighted Ljung-Box Test on Standardized Squared Residuals


------------------------------------
statistic p-value
Lag[1] 0.04968 0.8236
Lag[2*(p+q)+(p+q)-1][5] 2.12695 0.5887
Lag[4*(p+q)+(p+q)-1][9] 3.20649 0.7244
d.o.f=2

Weighted ARCH LM Tests

3
------------------------------------
Statistic Shape Scale P-Value
ARCH Lag[3] 2.114e-05 0.500 2.000 0.9963
ARCH Lag[5] 7.739e-01 1.440 1.667 0.8010
ARCH Lag[7] 1.014e+00 2.315 1.543 0.9113

Nyblom stability test


------------------------------------
Joint Statistic: 1.8834
Individual Statistics:
mu 0.3373
ar1 0.3613
omega 0.3290
alpha1 0.7774
beta1 0.4961

Asymptotic Critical Values (10% 5% 1%)


Joint Statistic: 1.28 1.47 1.88
Individual Statistic: 0.35 0.47 0.75

Sign Bias Test


------------------------------------
t-value prob sig
Sign Bias 0.7230 0.4704
Negative Sign Bias 0.6201 0.5358
Positive Sign Bias 1.2483 0.2132
Joint Effect 1.9561 0.5816

Adjusted Pearson Goodness-of-Fit Test:


------------------------------------
group statistic p-value(g-1)
1 20 34.70 0.015166
2 30 42.66 0.048932
3 40 58.96 0.021051
4 50 78.40 0.004817

Elapsed time : 0.1280069

Problem 3. (a) acf(res) is the ACF of the unstandardized residuals. The unstandardized
residuals exhibit some autocorrelation suggesting that the AR(1) model for
the conditional mean might be misspecified, but the Ljung-Box test of the
standardized residuals has reasonably large p-values so it seems that the AR(1)
model for the conditional mean is adequate.
(b) acf(res^2) is the ACF of the squared unstandardized residuals. We see
substantial autocorrelation, which indicates conditional heteroscedasticity and

4
the need for a GARCH model. Since we are fitting a GARCH model, this
autocorrelation is not a concern.
(c) acf(res_std^2) is the ACF of the squared standardized residuals. The
standardized residuals are the residuals divided by the estimates based on the
GARCH(1, 1) model of the conditional standard deviations. We see little au-
tocorrelation, which indicates that the GARCH(1,1) model for the conditional
standard deviation is adequate. The autocorrelation seen in (b) is accommo-
dated by the GARCH(1,1) model.
(d) The time series plot of the standardized residuals seems to have heavy tails,
but a time series plot is not ideal for checking tail weight. A QQ-plot could be
used to investigate further.
The standardized residuals at the end of the series are unusually small. The
time series plot of the t-bill series shows unusually low volatility at the end of the
series. It might be that the conditional standard deviations are overestimated
there.

res = ts(residuals(Tbill.arma.garch.norm, standardize=FALSE),


start = 1955, freq = 4)
res.std = ts(residuals(Tbill.arma.garch.norm, standardize=TRUE),
start = 1955, freq = 4)
pdf("Tbill02.pdf",width=8,height=6)
par(mfrow=c(2,3))
plot(res)
acf(res)
acf(res^2)
plot(res.std)
acf(res.std)
acf(res.std^2)
graphics.off()

The plot below was created by the code above which was taken from the book.

5
Series 1 Series 1

1.0

1.0
4

0.8

0.8
2

0.6

0.6
Series 1

ACF

ACF
0.4

0.4
−2

0.2

0.2
−4

0.0
−6

−0.2
1960 1980 2000 0 1 2 3 4 5 0 1 2 3 4 5

Time Lag Lag

Series 1 Series 1

1.0

1.0
0.8

0.8
2

0.6

0.6
Series 1

ACF

ACF
0.4

0.4
0.2
−2

0.2
−0.2 0.0

0.0
−4

1960 1980 2000 0 1 2 3 4 5 0 1 2 3 4 5

Time Lag Lag

Problem 4. Below are the output and plots using the log transformed series. There are
no major differences except for hte conditional standard deviations; these are
discussed below.

> diff.log.Tbill = diff(log(Tbill))


> Tbill.arma.garch.norm.log = ugarchfit(data=diff.log.Tbill, spec=arma.garch.norm)
> show(Tbill.arma.garch.norm.log)

*---------------------------------*
* GARCH Model Fit *
*---------------------------------*

Conditional Variance Dynamics


-----------------------------------
GARCH Model : sGARCH(1,1)
Mean Model : ARFIMA(1,0,0)
Distribution : norm

Optimal Parameters
------------------------------------
Estimate Std. Error t value Pr(>|t|)
mu 0.015687 0.009638 1.6277 0.10360
ar1 0.100402 0.074611 1.3457 0.17841
omega 0.004274 0.001434 2.9813 0.00287
alpha1 0.497553 0.093795 5.3047 0.00000
beta1 0.501447 0.073451 6.8270 0.00000

Robust Standard Errors:


Estimate Std. Error t value Pr(>|t|)
mu 0.015687 0.013789 1.13765 0.255268
ar1 0.100402 0.114556 0.87644 0.380789
omega 0.004274 0.002619 1.63191 0.102699
alpha1 0.497553 0.176017 2.82673 0.004703
beta1 0.501447 0.136196 3.68182 0.000232

LogLikelihood : 52.01162

Information Criteria
------------------------------------

Akaike -0.40010
Bayes -0.32649
Shibata -0.40098

6
Hannan-Quinn -0.37042

Weighted Ljung-Box Test on Standardized Residuals


------------------------------------
statistic p-value
Lag[1] 1.252 0.2632
Lag[2*(p+q)+(p+q)-1][2] 1.271 0.5722
Lag[4*(p+q)+(p+q)-1][5] 3.624 0.2917
d.o.f=1
H0 : No serial correlation

Weighted Ljung-Box Test on Standardized Squared Residuals


------------------------------------
statistic p-value
Lag[1] 0.1454 0.7030
Lag[2*(p+q)+(p+q)-1][5] 4.7295 0.1761
Lag[4*(p+q)+(p+q)-1][9] 6.3238 0.2627
d.o.f=2

Weighted ARCH LM Tests


------------------------------------
Statistic Shape Scale P-Value
ARCH Lag[3] 3.579 0.500 2.000 0.05853
ARCH Lag[5] 4.822 1.440 1.667 0.11297
ARCH Lag[7] 5.105 2.315 1.543 0.21415

Nyblom stability test


------------------------------------
Joint Statistic: 1.0816
Individual Statistics:
mu 0.21652
ar1 0.06882
omega 0.18334
alpha1 0.07821
beta1 0.17806

Asymptotic Critical Values (10% 5% 1%)


Joint Statistic: 1.28 1.47 1.88
Individual Statistic: 0.35 0.47 0.75

Sign Bias Test


------------------------------------
t-value prob sig
Sign Bias 1.0277 0.3052
Negative Sign Bias 0.3931 0.6946
Positive Sign Bias 0.5849 0.5592
Joint Effect 3.3695 0.3381

Adjusted Pearson Goodness-of-Fit Test:


------------------------------------
group statistic p-value(g-1)
1 20 36.74 0.008539
2 30 51.60 0.006045
3 40 61.00 0.013666
4 50 66.49 0.048729

Elapsed time : 0.1250069

res.log = ts(residuals(Tbill.arma.garch.norm.log, standardize=FALSE),


start = 1955, freq = 4)
res.std.log = ts(residuals(Tbill.arma.garch.norm, standardize=TRUE),
start = 1955, freq = 4)
pdf("Tbill03.pdf",width=8,height=6)
par(mfrow=c(2,3))
plot(res.log)

7
acf(res.log)
acf(res.log^2)
plot(res.std.log)
acf(res.std.log)
acf(res.std.log^2)
graphics.off()

The following plot was produced by the code above


Series 1 Series 1

1.0

1.0
1.0

0.8

0.8
0.6

0.6
0.0
Series 1

ACF

ACF
0.4

0.4
−1.0

0.2

0.2
0.0

0.0
−2.0

1960 1980 2000 0 1 2 3 4 5 0 1 2 3 4 5

Time Lag Lag

Series 1 Series 1
1.0

1.0
0.8

0.8
2

0.6

0.6
Series 1

ACF

ACF
0.4

0.4
0.2
−2

0.2
−0.2 0.0

0.0
−4

1960 1980 2000 0 1 2 3 4 5 0 1 2 3 4 5

Time Lag Lag

The plot below shows the two conditional standard deviations series. The high
volatility around 1980 in the untransformed series shows up as large condtional
standard deviations around that date. Since the log transformation stabilizes
the variance in this example, the logged transformed series does not high volatil-
ity around 1980 and its conditional standard deviation are not usually large
around that time.
Thus, we see that the high volatility around 1980 can be accommodated in two
ways.

1. Use the log transformation to “stabilize the variance.”


2. Model the conditional variance with a GARCH model.

pdf("TbillGarchPlotlog.pdf",width=8,height=5)
par(mfrow=c(1,2))
plot(Tbill.arma.garch.norm,which=3)
plot(Tbill.arma.garch.norm.log,which=3)
graphics.off()

The following plot was produced by the code above.

8
Conditional SD (vs |returns|) Conditional SD (vs |returns|)

2.0
6
5

1.5
4
Volatility

Volatility

1.0
3
2

GARCH model : sGARCH

GARCH model : sGARCH


0.5
1

0.0
0

1960 1980 2000 1960 1980 2000

Time Time

Exercise 5. (a) 2/(1 − 0.67)


(b) ρY (h) = 0.67|h|
(c) ρa (h) = 0 if h = 0 and = 1 otherwise.
(d) ρa2 (h) = (1/2)|h| .
p
Exercise 6. (a) 0.06 + (0.35)(0.1) + 0.22 1 + (0.5)(0.62 )
(b) 1 + (0.5)(0.62 )
(c) Yes. If we condition on at−1 then at−1 and σt are constant. If we also
condition on Xt , then the only random quantity on the right-hand side of (14.30)
is t which is normal. Then, since Yt is a linear function of t , it is also normal.
(d) No. On the right-hand side of (14.30) neither σt nor at are normal. Also, X1
might be nonnormal as well. When computing marginal distribution of Yt we
do not condition upon these nonnormal variables, so the marginal distribution
of Yt is not normal.

You might also like