Hi all,

I post it on both r-help and r-finance since I don't know where is most
appropriate for this topic. Sorry if it bothers you.

I did garch fitting on S&P500 monthly returns with garchFit from fSeries. I
got same coefficients from all cond.dist except normal. I thought that is
probabaly usual for the data. But when I play with it, I got another
question.

I plot skew normal with skew = 1 and a standard normal, they overlap
eachother, so I think they are the same. Skew = 1 means no skewness (I can
not find the paper defining the distribution).

library(fSeries)
curve(dsnorm(x, 0, 1, 1), -2, 2, add = F, col = 'red') #skew normal with
skew 1
curve(dnorm(x, 0, 1), -2, 2, add = T, col = 'blue') #normal

Then I try them as innovations,

#normal innovation
garch_norm <- garchFit(series = logr, include.mean = F)

#skew normal innovation

#this line do not include skew, so it got same result as normal
garch_snorm <- garchFit(series = logr, cond.dist = 'dsnorm', include.mean =
F, include.skew = F)

#this line includes skew, but use default skew = 1, and it got results
different from normal, which I don't understand

garch_snorm <- garchFit(series = logr, cond.dist = 'dsnorm', include.mean =
F, include.skew = T)

Have I done something wrong? I am attaching the code, thank you.

Tian

#GARCH analysis of monthly return
rm(list=ls(all=TRUE))
sp500 <- read.csv('s&p_m90.csv', header=TRUE)
sp500 <- sp500[,2] #only adjusted close
n <- length(sp500)

logr <- log(sp500[1:n-1] / sp500[2:n])
acf(logr)
ar5 <- arima(logr, order = c(5, 0, 0), include.mean = T)
logr<- ar5$res
acf(logr)

#fit GARCH distribution
hist(logr, freq = F, ylim = c(0, 12), breaks = 'FD')

norm_fit <- normFit(logr)
curve(dnorm(x, norm_fit$est[1], norm_fit$est[2]), -.15, .15, add = TRUE,
col=2)

t_fit <- stdFit(logr)
curve(dstd(x, t_fit$est[1], t_fit$est[2], t_fit$est[3]), -.15, .15, add =
TRUE, col=6)

snorm_fit <- snormFit(logr)
curve(dsnorm(x, snorm_fit$est[1], snorm_fit$est[2], snorm_fit$est[3]), -.25,
.15, add = TRUE, col=4)

st_fit <- sstdFit(logr)
curve(dsstd(x, st_fit$est[1], st_fit$est[2], st_fit$est[3], st_fit$est[4]),
-.25, .15, add = TRUE, col=3)

library(fSeries)

#normal innovation
garch_norm <- garchFit(series = logr, include.mean = F)

#t inovation
garch_t <- garchFit(series = logr, cond.dist = 'dstd', include.mean = F,
include.shape = T)
garch_t1 <- garchFit(series = logr, cond.dist = 'dstd', include.mean = F,
shape = t_fit$est[3], include.shape = T)

#skew normal innovation
garch_snorm <- garchFit(series = logr, cond.dist = 'dsnorm', include.mean =
F, include.skew = T)
garch_snorm1 <- garchFit(series = logr, cond.dist = 'dsnorm', include.mean =
F, skew = snorm_fit$est[3], include.skew = T)

#skew t innovation
garch_st <- garchFit(series = logr, cond.dist = 'dsstd', include.mean = F,
include.skew = T, include.shape = T)
garch_st1 <- garchFit(series = logr, cond.dist = 'dsstd', include.mean = F,
skew = st_fit$est[4], shape = st_fit$est[3], include.skew = T, include.shape= T)

vix <- read.csv('D:/Documents and Settings/Mu Tian/Desktop/8780/8780
project/vix_m.csv', header=TRUE)
vix <- (vix[,2]/100) / (12^.5)

plot_sd <- function(x, ylim = null, col = null, ...) {
        xcsd = [EMAIL PROTECTED]
        plot(xcsd, type = "l", col = col, ylab = "x",
            main = "Conditional SD", ylim = ylim)
        abline(h = 0, col = "grey", lty = 3)
        grid()
}

plot_sd(garch_norm, ylim = c(0.02, 0.13), col = 2)
xcsd = [EMAIL PROTECTED]
lines(xcsd, col = 3)
lines(1:n, vix)

#predict
predict(garch_norm)
predict(garch_t)

#demonstration of skew distributions
#skew normal
curve(dsnorm(x, 0, 1, .1), -2, 2, add = F, col = 'green')
curve(dsnorm(x, 0, 1, snorm_fit$est[3]), type = 'l', col = 'blue', add = T)
curve(dsnorm(x, 0, 1, 1), -2, 2, add = T, col = 'red') #normal

#skew t
curve(dsstd(x, 0, 1, 4, 1), -2, 2, add = F, col = 'red')
curve(dsstd(x, 0, 1, st_fit$est[3], st_fit$est[4]), type = 'l', col =
'blue', add = T)
curve(dsstd(x, 0, 1, 100, .5), -2, 2, add = T, col = 'green')

#t
curve(dstd(x, 0, 1, 4), -2, 2, add = T, col = 'red')
curve(dstd(x, 0, 1, t_fit$est[3]), type = 'l', col = 'blue', add = T)
curve(dstd(x, 0, 1, 100), -2, 2, add = T, col = 'green')

curve(dsnorm(x, 0, 1, 1), -2, 2, add = F, col = 'red') #normal
curve(dnorm(x, 0, 1), -2, 2, add = T, col = 'blue') #normal
curve(dsnorm(x, 0, 1, .1), -2, 2, add = T, col = 'green') #normal

        [[alternative HTML version deleted]]

______________________________________________
R-help@stat.math.ethz.ch mailing list
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
and provide commented, minimal, self-contained, reproducible code.

Reply via email to