#************************************************************ 
# GARCH Type Models Spurious R 
# DEM/GBP Exchange Rate Returns
# A daily time series of percentage returns of 
# Deutsche mark/British pound (DEM/GBP) exchange rates 
# from 1984-01-03 through 1991-12-31.
# Used AER
# install.packages("tseries")
# install.packages("fGarch")
# install.packages("AER")
#------------------------------------------------------------

library("tseries")
library("fGarch")
library("AER")

data("MarkPound")

mp <- garch(MarkPound, grad = "numerical", trace = FALSE)
summary(mp)

mp_gf <- garchFit(~garch(1,1), data = MarkPound, trace = FALSE)
summary(mp_gf)

mp_gf1 <- garchFit(~arma(0,1) + aparch(1,1), data = ts(100* sp500dge), trace = FALSE)
summary(mp_gf1)

# Taylor-Schwert ARCH (compare Ding, Granger, Engle, eq. (16))
tsarch <- garchFit(~ arma(0,1) + garch(1,1), delta = 1,
                         data = ts(100 * sp500dge), trace = FALSE)
summary(tsarch)
# Threshold ARCH (TARCH)
tarch <- garchFit(~ arma(0,1) + garch(1,1), delta = 1,
                         leverage = TRUE, data = ts(100 * sp500dge), trace = FALSE)
summary(tarch)
# GJR-GARCH
gjrarch <- garchFit(~ arma(0,1) + garch(1,1), delta = 2,
                         leverage = TRUE, data = ts(100 * sp500dge), trace = FALSE)
summary(gjrarch)

# GARCH(1,1) with Student-t (shape parameter estimated)
garch_std <- garchFit(~ garch(1,1), cond.dist = "sstd",
                        data = ts(100 * sp500dge), trace = FALSE)
# GARCH(1,1) with Student-t3 (shape parameter fixed at 3)
garch_std3 <- garchFit(~ garch(1,1),
                       cond.dist = "sstd", shape = 3, include.shape = FALSE,
                       data = ts(100 * sp500dge), trace = FALSE)
# GARCH(1,1) with Laplace (a GED with shape fixed at 1)
garch_ged <- garchFit(~ garch(1,1),
                       cond.dist = "sged", shape = 1, include.shape = FALSE,
                       data = ts(100 * sp500dge), trace = FALSE)
