# load data
garch_data <- read.csv(".../test_garch.csv", sep = ";")
garch_data_close <- garch_data["Close"]
# logarithmize
garch_data_close_ln <- log(garch_data_close)
# ln(Pt) - ln(Pt-1)
y2008ln1 <- rbind(0,garch_data_close_ln)
y2008ln2 <- rbind(garch_data_close_ln,0)
y2008tmp <- y2008ln2 - y2008ln1
y2008lnres <- y2008tmp[-nrow(y2008tmp),]
y2008lnres <- y2008lnres[-1]
# GARCH p=1, q=1
garch_result <- garchFit(formula = ~garch(1,1), data = y2008lnres)
#Show result
attributes(garch_result)
GARCH MODEL in R, Sample Code for GARCH(1,1)
最新推荐文章于 2023-06-19 18:18:20 发布