Skip to content

Instantly share code, notes, and snippets.

@wilsonfreitas
Created June 17, 2018 12:40
Show Gist options
  • Save wilsonfreitas/8498302a98f301b80b5161be3b4fe9ac to your computer and use it in GitHub Desktop.
Save wilsonfreitas/8498302a98f301b80b5161be3b4fe9ac to your computer and use it in GitHub Desktop.
library(tseries)
library(magrittr)
library(ggplot2)
data(EuStockMarkets)
dax <- diff(log(EuStockMarkets))[,"DAX"]
dax.garch <- garch(dax)
dax.garch
tidy(dax.garch)
glance(dax.garch)
augment(dax.garch, dax) %>% head()
augment(dax.garch, dax) %>%
ggplot(aes(x = .time, y = data)) +
geom_line() +
geom_line(aes(y = .fitted*2.32), colour = "red")
smp1 = window(dax, end = c(1997, frequency(dax)))
smp2 = window(dax, start = c(1998, 1))
dax.garch <- garch(smp1)
augment(dax.garch, newdata = smp2) %>%
ggplot(aes(x = .time, y = newdata)) +
geom_line() +
geom_line(aes(y = .fitted*2.32), colour = "red")
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment