使用滚动窗口创建预测
我正在尝试使用滚动窗口预测来计算已实现的波动率预测。我的目标是使用前 500 个观测值来预测第 501 个观测值,然后使用观测值 2 到 501 将窗口向前移动一步来预测第 502 个观测值。我希望重复此操作,直到获得完整的伪样本外预测。
我的 df 包含 23 个变量的 2411 个观测值,这是一个小例子:
Date | EUR/GBP_RV t+1 | EUR/GBP_RV | EUR/GBP_RV_5 | EUR/GBP_RV_22 |
---|---|---|---|---|
2012-02-13 | 0.004019947 | 0.004467109 | 0.004995980 | 0.005150602 |
2012-02-14 | 0.004077322 | 0.004019947 | 0.004704742 | 0.005099209 |
2012-02-15 | 0.004666244 | 0.004077322 | 0.004564522 | 0.005020790 |
2012-02-16 | 0.004582351 | 0.004666244 | 0.004532930 | 0.005011078 |
2012-02-17 | 0.003951071 | 0.004582351 | 0.004362595 | 0.004999634 |
2012-02-21 | 0.005549329 | 0.004824547 | 0.004467109 | 0.004954358 |
df 的头部可以用
structure(list(Date = structure(c(15383, 15384, 15385, 15386,
15387, 15391), class = "Date"), `EUR/GBP_RV t+1,t+22` = c(0.00437808494654599,
0.00439764887779732, 0.00441997330738947, 0.00437799055732722,
0.00435021150904479, 0.00434881306458859), `EUR/GBP_RGV t+1,t+22` = c(0.00310674728131117,
0.00311502965608506, 0.00313756204195853, 0.00312923997431178,
0.00310846773074243, 0.00309755540903969), `EUR/GBP_RBV t+1,t+22` = c(0.00304961980133602,
0.00306866297401415, 0.00307794319983677, 0.00302801249035602,
0.00300946121851254, 0.00302272755554915), `EUR/GBP_RV t+1,t+5` = c(0.00425938711995146,
0.00442030721926592, 0.00471470868108043, 0.00487869292442023,
0.00476849421943949, 0.0046067439660438), `EUR/GBP_RGV t+1,t+5` = c(0.00287718093809447,
0.00311308998902836, 0.00344398536439729, 0.00376911066284235,
0.00377425759242542, 0.00353909902900148), `EUR/GBP_RBV t+1,t+5` = c(0.00313771439501486,
0.00310626895475871, 0.0031789431316576, 0.00305962424370556,
0.00288671182187571, 0.00291630955829613), `EUR/GBP_RV t+1` = c(0.00401994700051122,
0.00407732180013827, 0.00466624428620966, 0.00458235106134663,
0.00395107145155152, 0.00554932910921084), `EUR/GBP_RGV t+1` = c(0.00280067842079775,
0.00275522601341373, 0.00296142025653418, 0.00320716195737542,
0.00266141804235125, 0.00440970289025837), `EUR/GBP_RBV t+1` = c(0.00288377777753365,
0.00300554199386584, 0.00360608177982326, 0.00327292734850446,
0.0029202430753471, 0.00336891287836027), `EUR/GBP_RV` = c(0.00446710941914797,
0.00401994700051122, 0.00407732180013827, 0.00466624428620966,
0.00458235106134663, 0.00482454749708351), `EUR/GBP_RV_5` = c(0.00499598016427624,
0.00470474196716823, 0.00456452150727461, 0.00453292965488229,
0.00436259471347075, 0.00442030721926592), `EUR/GBP_RV_22` = c(0.00515060219897263,
0.00509920878086075, 0.00502079002092667, 0.00501107755050095,
0.00499963428727425, 0.00495435807685843), `EUR/GBP_RBV` = c(0.00324667045338159,
0.00288377777753365, 0.00300554199386584, 0.00360608177982326,
0.00327292734850446, 0.00272655057625291), `EUR/GBP_RBV_5` = c(0.0034985439252634,
0.00318731350301598, 0.00319529774619179, 0.0032799330165155,
0.00320299987062176, 0.00310626895475871), `EUR/GBP_RBV_22` = c(0.0036581887941976,
0.00362298829344015, 0.00355498498935768, 0.0035465419934449,
0.00355752455210586, 0.00351669973034298), `EUR/GBP_RGV` = c(0.00306825643155514,
0.00280067842079775, 0.00275522601341373, 0.00296142025653418,
0.00320716195737542, 0.00398022367546721), `EUR/GBP_RGV_5` = c(0.00353290218424469,
0.00345194162523714, 0.00325362896209417, 0.00312087362386985,
0.00295854861593525, 0.00311308998902836), `EUR/GBP_RGV_22` = c(0.00359974659692405,
0.00356342531619103, 0.00352224165959556, 0.00351722666683608,
0.00349184335907274, 0.00346394410318992), `EUR/GBP_TotalCount` = structure(c(-0.179518680545716,
-0.0757259172924681, 0.333514120677483, 0.759064450015801, -0.419724789788948,
-0.360414639358521), .Dim = c(6L, 1L)), `EUR/GBP_BloombergCount` = structure(c(-0.701694550941621,
-0.669811381311996, -0.574161872423118, -0.644304845608295, -0.784590791978649,
-0.631551577756444), .Dim = c(6L, 1L)), `EUR/GBP_SocialMediaCount` = structure(c(-1.68861759789696,
-1.66829994393287, -1.5910928588693, -1.59515638966212, -1.6967446594826,
-1.63172816679749), .Dim = c(6L, 1L)), `EUR/GBP_NewsCount` = structure(c(0.76560533722738,
0.879161625683434, 1.33717198912285, 1.90306082659552, 0.487392430510049,
0.487392430510049), .Dim = c(6L, 1L))), na.action = structure(c(`6` = 6L,
`38` = 38L, `74` = 74L, `101` = 101L, `140` = 140L, `165` = 165L,
`189` = 189L, `197` = 197L, `236` = 236L, `256` = 256L, `323` = 323L,
`351` = 351L, `393` = 393L, `423` = 423L, `442` = 442L, `455` = 455L,
`490` = 490L, `510` = 510L, `551` = 551L, `576` = 576L, `605` = 605L,
`646` = 646L, `676` = 676L, `696` = 696L, `708` = 708L, `742` = 742L,
`762` = 762L, `793` = 793L, `829` = 829L, `858` = 858L, `904` = 904L,
`929` = 929L, `950` = 950L, `961` = 961L, `996` = 996L, `1016` = 1016L,
`1089` = 1089L, `1114` = 1114L, `1159` = 1159L, `1184` = 1184L,
`1207` = 1207L, `1216` = 1216L, `1238` = 1238L, `1243` = 1243L,
`1253` = 1253L, `1278` = 1278L, `1315` = 1315L, `1346` = 1346L,
`1372` = 1372L, `1416` = 1416L, `1441` = 1441L, `1473` = 1473L,
`1532` = 1532L, `1599` = 1599L, `1626` = 1626L, `1669` = 1669L,
`1694` = 1694L, `1718` = 1718L, `1726` = 1726L, `1766` = 1766L,
`1786` = 1786L, `1827` = 1827L, `1853` = 1853L, `1881` = 1881L,
`1922` = 1922L, `1952` = 1952L, `1971` = 1971L, `1984` = 1984L,
`2019` = 2019L, `2039` = 2039L, `2075` = 2075L, `2106` = 2106L,
`2135` = 2135L, `2181` = 2181L, `2206` = 2206L, `2227` = 2227L,
`2238` = 2238L, `2273` = 2273L, `2293` = 2293L, `2325` = 2325L,
`2366` = 2366L, `2391` = 2391L, `2436` = 2436L, `2461` = 2461L,
`2483` = 2483L, `2493` = 2493L), class = "omit"), row.names = c(1L,
2L, 3L, 4L, 5L, 7L), class = "data.frame")
我已经为每个预测范围(t+1、t+5 和 t+22)构建了 9 个回归模型来重现,并且我正在使用预测函数来我的预测。我已将其编码在 R 循环中,其中我还尝试将每个预测分配给一个矩阵。我的代码如下:
last_window = nrow(EURGBP_final) - window_size
number_of_forecasts = dim( EURGBP_final)[1] - window_size
EURGBP_forecast.1 <- matrix( NA, nrow=number_of_forecasts, ncol=9 )
EURGBP_forecast.5 <- matrix( NA, nrow=number_of_forecasts, ncol=9 )
EURGBP_forecast.22 <- matrix( NA, nrow=number_of_forecasts, ncol=9 )
EURGBP_actuals.1 <- matrix( NA, nrow=number_of_forecasts, ncol=9 )
EURGBP_actuals.5 <- matrix( NA, nrow=number_of_forecasts, ncol=9 )
EURGBP_actuals.22 <- matrix( NA, nrow=number_of_forecasts, ncol=9 )
forecasts = for (i in (1:last_window)){
## data splitting ###
data.estimate <- EURGBP_final[i:(w_size + i - 1), ] # = change to X[1:(w_size + i - 1), ] for expanding window
data.forecast <- EURGBP_final[w_size + i, ]
# --------------------------------------
# Forecast horizon 1
# --------------------------------------
EURGBP_HAR_RV_train <- lm(data.estimate$`EUR/GBP_RV t+1`~data.estimate$`EUR/GBP_RV`+data.estimate$`EUR/GBP_RV_5`+data.estimate$`EUR/GBP_RV_22`)
EURGBP_HAR_RV_NT_train <- lm(data.estimate$`EUR/GBP_RV t+1`~data.estimate$`EUR/GBP_RV`+data.estimate$`EUR/GBP_RV_5`+data.estimate$`EUR/GBP_RV_22`+data.estimate$`EUR/GBP_TotalCount`)
EURGBP_HAR_RVB_train <- lm(data.estimate$`EUR/GBP_RBV t+1`~data.estimate$`EUR/GBP_RBV`+data.estimate$`EUR/GBP_RBV_5`+data.estimate$`EUR/GBP_RBV_22`)
EURGBP_HAR_RVB_NT_train <- lm(data.estimate$`EUR/GBP_RBV t+1`~data.estimate$`EUR/GBP_RBV`+data.estimate$`EUR/GBP_RBV_5`+data.estimate$`EUR/GBP_RBV_22`+data.estimate$`EUR/GBP_TotalCount`)
EURGBP_HAR_RVG_train <- lm(data.estimate$`EUR/GBP_RGV t+1`~data.estimate$`EUR/GBP_RGV`+data.estimate$`EUR/GBP_RGV_5`+data.estimate$`EUR/GBP_RGV_22`)
EURGBP_HAR_RVG_NT_train <- lm(data.estimate$`EUR/GBP_RGV t+1`~data.estimate$`EUR/GBP_RGV`+data.estimate$`EUR/GBP_RGV_5`+data.estimate$`EUR/GBP_RGV_22`+data.estimate$`EUR/GBP_TotalCount`)
EURGBP_HAR_RV_Bloomberg_train <- lm(data.estimate$`EUR/GBP_RV t+1`~data.estimate$`EUR/GBP_RV`+data.estimate$`EUR/GBP_RV_5`+data.estimate$`EUR/GBP_RV_22`+data.estimate$`EUR/GBP_BloombergCount`)
EURGBP_HAR_RV_SocialMedia_train <- lm(data.estimate$`EUR/GBP_RV t+1`~data.estimate$`EUR/GBP_RV`+data.estimate$`EUR/GBP_RV_5`+data.estimate$`EUR/GBP_RV_22`+data.estimate$`EUR/GBP_SocialMediaCount`)
EURGBP_HAR_RV_News_train <- lm(data.estimate$`EUR/GBP_RV t+1`~data.estimate$`EUR/GBP_RV`+data.estimate$`EUR/GBP_RV_5`+data.estimate$`EUR/GBP_RV_22`+data.estimate$`EUR/GBP_NewsCount`)
EURGBP_forecast.1[, 1 ] <- predict( EURGBP_HAR_RV_train, newdata=data.forecast )
EURGBP_forecast.1[, 2 ] <- predict( EURGBP_HAR_RV_NT_train, newdata=data.forecast )
EURGBP_forecast.1[, 3 ] <- predict( EURGBP_HAR_RVB_train, newdata=data.forecast )
EURGBP_forecast.1[, 4 ] <- predict( EURGBP_HAR_RVB_NT_train, newdata=data.forecast )
EURGBP_forecast.1[, 5 ] <- predict( EURGBP_HAR_RVG_train, newdata=data.forecast )
EURGBP_forecast.1[, 6 ] <- predict( EURGBP_HAR_RVG_NT_train, newdata=data.forecast )
EURGBP_forecast.1[, 7 ] <- predict( EURGBP_HAR_RV_Bloomberg_train, newdata=data.forecast )
EURGBP_forecast.1[, 8 ] <- predict( EURGBP_HAR_RV_SocialMedia_train, newdata=data.forecast )
EURGBP_forecast.1[, 9 ] <- predict( EURGBP_HAR_RV_News_train, newdata=data.forecast )
EURGBP_actuals.1[ , 1] <- data.forecast$`EUR/GBP_RV t+1`
# --------------------------------------
# Forecast horizon 5
# --------------------------------------
EURGBP_HAR_RVt5_train <- lm(data.estimate$`EUR/GBP_RV t+1,t+5`~data.estimate$`EUR/GBP_RV`+data.estimate$`EUR/GBP_RV_5`+data.estimate$`EUR/GBP_RV_22`)
EURGBP_HAR_RVt5_NT_train <- lm(data.estimate$`EUR/GBP_RV t+1,t+5`~data.estimate$`EUR/GBP_RV`+data.estimate$`EUR/GBP_RV_5`+data.estimate$`EUR/GBP_RV_22`+data.estimate$`EUR/GBP_TotalCount`)
EURGBP_HAR_RVBt5_train <- lm(data.estimate$`EUR/GBP_RBV t+1,t+5`~data.estimate$`EUR/GBP_RBV`+data.estimate$`EUR/GBP_RBV_5`+data.estimate$`EUR/GBP_RBV_22`)
EURGBP_HAR_RVBt5_NT_train <- lm(data.estimate$`EUR/GBP_RBV t+1,t+5`~data.estimate$`EUR/GBP_RBV`+data.estimate$`EUR/GBP_RBV_5`+data.estimate$`EUR/GBP_RBV_22`+data.estimate$`EUR/GBP_TotalCount`)
EURGBP_HAR_RVGt5_train <- lm(data.estimate$`EUR/GBP_RGV t+1,t+5`~data.estimate$`EUR/GBP_RGV`+data.estimate$`EUR/GBP_RGV_5`+data.estimate$`EUR/GBP_RGV_22`)
EURGBP_HAR_RVGt5_NT_train <- lm(data.estimate$`EUR/GBP_RGV t+1,t+5`~data.estimate$`EUR/GBP_RGV`+data.estimate$`EUR/GBP_RGV_5`+data.estimate$`EUR/GBP_RGV_22`+data.estimate$`EUR/GBP_TotalCount`)
EURGBP_HAR_RVt5_Bloomberg_train <- lm(data.estimate$`EUR/GBP_RV t+1,t+5`~data.estimate$`EUR/GBP_RV`+data.estimate$`EUR/GBP_RV_5`+data.estimate$`EUR/GBP_RV_22`+data.estimate$`EUR/GBP_BloombergCount`)
EURGBP_HAR_RVt5_SocialMedia_train <- lm(data.estimate$`EUR/GBP_RV t+1,t+5`~data.estimate$`EUR/GBP_RV`+data.estimate$`EUR/GBP_RV_5`+data.estimate$`EUR/GBP_RV_22`+data.estimate$`EUR/GBP_SocialMediaCount`)
EURGBP_HAR_RVt5_News_train <- lm(data.estimate$`EUR/GBP_RV t+1,t+5`~data.estimate$`EUR/GBP_RV`+data.estimate$`EUR/GBP_RV_5`+data.estimate$`EUR/GBP_RV_22`+data.estimate$`EUR/GBP_NewsCount`)
EURGBP_forecast.5[, 1 ] <- predict( EURGBP_HAR_RVt5_train, newdata=data.forecast )
EURGBP_forecast.5[, 2 ] <- predict( EURGBP_HAR_RVt5_NT_train, newdata=data.forecast )
EURGBP_forecast.5[, 3 ] <- predict( EURGBP_HAR_RVBt5_train, newdata=data.forecast )
EURGBP_forecast.5[, 4 ] <- predict( EURGBP_HAR_RVBt5_NT_train, newdata=data.forecast )
EURGBP_forecast.5[, 5 ] <- predict( EURGBP_HAR_RVGt5_train, newdata=data.forecast )
EURGBP_forecast.5[, 6 ] <- predict( EURGBP_HAR_RVGt5_NT_train, newdata=data.forecast )
EURGBP_forecast.5[, 7 ] <- predict( EURGBP_HAR_RVt5_Bloomberg_train, newdata=data.forecast )
EURGBP_forecast.5[, 8 ] <- predict( EURGBP_HAR_RVt5_SocialMedia_train, newdata=data.forecast )
EURGBP_forecast.5[, 9 ] <- predict( EURGBP_HAR_RVt5_News_train, newdata=data.forecast )
EURGBP_actuals.5[, 1] <- data.forecast$`EUR/GBP_RV t+1,t+5`
# --------------------------------------
# Forecast horizon 22
# --------------------------------------
EURGBP_HAR_RVt22_train <- lm(data.estimate$`EUR/GBP_RV t+1,t+22`~data.estimate$`EUR/GBP_RV`+data.estimate$`EUR/GBP_RV_5`+data.estimate$`EUR/GBP_RV_22`)
EURGBP_HAR_RVt22_NT_train <- lm(data.estimate$`EUR/GBP_RV t+1,t+22`~data.estimate$`EUR/GBP_RV`+data.estimate$`EUR/GBP_RV_5`+data.estimate$`EUR/GBP_RV_22`+data.estimate$`EUR/GBP_TotalCount`)
EURGBP_HAR_RVBt22_train <- lm(data.estimate$`EUR/GBP_RBV t+1,t+22`~data.estimate$`EUR/GBP_RBV`+data.estimate$`EUR/GBP_RBV_5`+data.estimate$`EUR/GBP_RBV_22`)
EURGBP_HAR_RVBt22_NT_train <- lm(data.estimate$`EUR/GBP_RBV t+1,t+22`~data.estimate$`EUR/GBP_RBV`+data.estimate$`EUR/GBP_RBV_5`+data.estimate$`EUR/GBP_RBV_22`+data.estimate$`EUR/GBP_TotalCount`)
EURGBP_HAR_RVGt22_train <- lm(data.estimate$`EUR/GBP_RGV t+1,t+22`~data.estimate$`EUR/GBP_RGV`+data.estimate$`EUR/GBP_RGV_5`+data.estimate$`EUR/GBP_RGV_22`)
EURGBP_HAR_RVGt22_NT_train <- lm(data.estimate$`EUR/GBP_RGV t+1,t+22`~data.estimate$`EUR/GBP_RGV`+data.estimate$`EUR/GBP_RGV_5`+data.estimate$`EUR/GBP_RGV_22`+data.estimate$`EUR/GBP_TotalCount`)
EURGBP_HAR_RVt22_Bloomberg_train <- lm(data.estimate$`EUR/GBP_RV t+1,t+22`~data.estimate$`EUR/GBP_RV`+data.estimate$`EUR/GBP_RV_5`+data.estimate$`EUR/GBP_RV_22`+data.estimate$`EUR/GBP_BloombergCount`)
EURGBP_HAR_RVt22_SocialMedia_train <- lm(data.estimate$`EUR/GBP_RV t+1,t+22`~data.estimate$`EUR/GBP_RV`+data.estimate$`EUR/GBP_RV_5`+data.estimate$`EUR/GBP_RV_22`+data.estimate$`EUR/GBP_SocialMediaCount`)
EURGBP_HAR_RVt22_News_train <- lm(data.estimate$`EUR/GBP_RV t+1,t+22`~data.estimate$`EUR/GBP_RV`+data.estimate$`EUR/GBP_RV_5`+data.estimate$`EUR/GBP_RV_22`+data.estimate$`EUR/GBP_NewsCount`)
EURGBP_forecast.22[, 1 ] <- predict( EURGBP_HAR_RVt22_train, newdata=data.forecast )
EURGBP_forecast.22[, 2 ] <- predict( EURGBP_HAR_RVt22_NT_train, newdata=data.forecast )
EURGBP_forecast.22[, 3 ] <- predict( EURGBP_HAR_RVBt22_train, newdata=data.forecast )
EURGBP_forecast.22[, 4 ] <- predict( EURGBP_HAR_RVBt22_NT_train, newdata=data.forecast )
EURGBP_forecast.22[, 5 ] <- predict( EURGBP_HAR_RVGt22_train, newdata=data.forecast )
EURGBP_forecast.22[, 6 ] <- predict( EURGBP_HAR_RVGt22_NT_train, newdata=data.forecast )
EURGBP_forecast.22[, 7 ] <- predict( EURGBP_HAR_RVt22_Bloomberg_train, newdata=data.forecast )
EURGBP_forecast.22[, 8 ] <- predict( EURGBP_HAR_RVt22_SocialMedia_train, newdata=data.forecast )
EURGBP_forecast.22[, 9 ] <- predict( EURGBP_HAR_RVt22_News_train, newdata=data.forecast )
EURGBP_actuals.22[, 1] <- data.forecast$`EUR/GBP_RV t+1,t+22`
}
这将返回以下错误:
EURGBP_forecast.1[, 1] <- 预测(EURGBP_HAR_RV_train, newdata = data.forecast) 中的错误: 要替换的项目数量不是替换长度的倍数
另外:警告消息: “newdata”有 1 行,但找到的变量有 500 行
我不知道我的错误是什么,我将不胜感激任何类型的帮助。
如果我需要提供更多信息,请告诉我。
I am trying to calculate realized volatility forecasts using a rolling window forecast. My aim is to use the first 500 observations to forecast the 501st observations, then shift the window forward one step using observations 2 to 501 to predict the 502nd observation. I want this to repeat until I have a complete pseudo out-of-sample forecast.
My df contains 2411 observations of 23 variables, here is small example:
Date | EUR/GBP_RV t+1 | EUR/GBP_RV | EUR/GBP_RV_5 | EUR/GBP_RV_22 |
---|---|---|---|---|
2012-02-13 | 0.004019947 | 0.004467109 | 0.004995980 | 0.005150602 |
2012-02-14 | 0.004077322 | 0.004019947 | 0.004704742 | 0.005099209 |
2012-02-15 | 0.004666244 | 0.004077322 | 0.004564522 | 0.005020790 |
2012-02-16 | 0.004582351 | 0.004666244 | 0.004532930 | 0.005011078 |
2012-02-17 | 0.003951071 | 0.004582351 | 0.004362595 | 0.004999634 |
2012-02-21 | 0.005549329 | 0.004824547 | 0.004467109 | 0.004954358 |
The head of the df can be reproduced with
structure(list(Date = structure(c(15383, 15384, 15385, 15386,
15387, 15391), class = "Date"), `EUR/GBP_RV t+1,t+22` = c(0.00437808494654599,
0.00439764887779732, 0.00441997330738947, 0.00437799055732722,
0.00435021150904479, 0.00434881306458859), `EUR/GBP_RGV t+1,t+22` = c(0.00310674728131117,
0.00311502965608506, 0.00313756204195853, 0.00312923997431178,
0.00310846773074243, 0.00309755540903969), `EUR/GBP_RBV t+1,t+22` = c(0.00304961980133602,
0.00306866297401415, 0.00307794319983677, 0.00302801249035602,
0.00300946121851254, 0.00302272755554915), `EUR/GBP_RV t+1,t+5` = c(0.00425938711995146,
0.00442030721926592, 0.00471470868108043, 0.00487869292442023,
0.00476849421943949, 0.0046067439660438), `EUR/GBP_RGV t+1,t+5` = c(0.00287718093809447,
0.00311308998902836, 0.00344398536439729, 0.00376911066284235,
0.00377425759242542, 0.00353909902900148), `EUR/GBP_RBV t+1,t+5` = c(0.00313771439501486,
0.00310626895475871, 0.0031789431316576, 0.00305962424370556,
0.00288671182187571, 0.00291630955829613), `EUR/GBP_RV t+1` = c(0.00401994700051122,
0.00407732180013827, 0.00466624428620966, 0.00458235106134663,
0.00395107145155152, 0.00554932910921084), `EUR/GBP_RGV t+1` = c(0.00280067842079775,
0.00275522601341373, 0.00296142025653418, 0.00320716195737542,
0.00266141804235125, 0.00440970289025837), `EUR/GBP_RBV t+1` = c(0.00288377777753365,
0.00300554199386584, 0.00360608177982326, 0.00327292734850446,
0.0029202430753471, 0.00336891287836027), `EUR/GBP_RV` = c(0.00446710941914797,
0.00401994700051122, 0.00407732180013827, 0.00466624428620966,
0.00458235106134663, 0.00482454749708351), `EUR/GBP_RV_5` = c(0.00499598016427624,
0.00470474196716823, 0.00456452150727461, 0.00453292965488229,
0.00436259471347075, 0.00442030721926592), `EUR/GBP_RV_22` = c(0.00515060219897263,
0.00509920878086075, 0.00502079002092667, 0.00501107755050095,
0.00499963428727425, 0.00495435807685843), `EUR/GBP_RBV` = c(0.00324667045338159,
0.00288377777753365, 0.00300554199386584, 0.00360608177982326,
0.00327292734850446, 0.00272655057625291), `EUR/GBP_RBV_5` = c(0.0034985439252634,
0.00318731350301598, 0.00319529774619179, 0.0032799330165155,
0.00320299987062176, 0.00310626895475871), `EUR/GBP_RBV_22` = c(0.0036581887941976,
0.00362298829344015, 0.00355498498935768, 0.0035465419934449,
0.00355752455210586, 0.00351669973034298), `EUR/GBP_RGV` = c(0.00306825643155514,
0.00280067842079775, 0.00275522601341373, 0.00296142025653418,
0.00320716195737542, 0.00398022367546721), `EUR/GBP_RGV_5` = c(0.00353290218424469,
0.00345194162523714, 0.00325362896209417, 0.00312087362386985,
0.00295854861593525, 0.00311308998902836), `EUR/GBP_RGV_22` = c(0.00359974659692405,
0.00356342531619103, 0.00352224165959556, 0.00351722666683608,
0.00349184335907274, 0.00346394410318992), `EUR/GBP_TotalCount` = structure(c(-0.179518680545716,
-0.0757259172924681, 0.333514120677483, 0.759064450015801, -0.419724789788948,
-0.360414639358521), .Dim = c(6L, 1L)), `EUR/GBP_BloombergCount` = structure(c(-0.701694550941621,
-0.669811381311996, -0.574161872423118, -0.644304845608295, -0.784590791978649,
-0.631551577756444), .Dim = c(6L, 1L)), `EUR/GBP_SocialMediaCount` = structure(c(-1.68861759789696,
-1.66829994393287, -1.5910928588693, -1.59515638966212, -1.6967446594826,
-1.63172816679749), .Dim = c(6L, 1L)), `EUR/GBP_NewsCount` = structure(c(0.76560533722738,
0.879161625683434, 1.33717198912285, 1.90306082659552, 0.487392430510049,
0.487392430510049), .Dim = c(6L, 1L))), na.action = structure(c(`6` = 6L,
`38` = 38L, `74` = 74L, `101` = 101L, `140` = 140L, `165` = 165L,
`189` = 189L, `197` = 197L, `236` = 236L, `256` = 256L, `323` = 323L,
`351` = 351L, `393` = 393L, `423` = 423L, `442` = 442L, `455` = 455L,
`490` = 490L, `510` = 510L, `551` = 551L, `576` = 576L, `605` = 605L,
`646` = 646L, `676` = 676L, `696` = 696L, `708` = 708L, `742` = 742L,
`762` = 762L, `793` = 793L, `829` = 829L, `858` = 858L, `904` = 904L,
`929` = 929L, `950` = 950L, `961` = 961L, `996` = 996L, `1016` = 1016L,
`1089` = 1089L, `1114` = 1114L, `1159` = 1159L, `1184` = 1184L,
`1207` = 1207L, `1216` = 1216L, `1238` = 1238L, `1243` = 1243L,
`1253` = 1253L, `1278` = 1278L, `1315` = 1315L, `1346` = 1346L,
`1372` = 1372L, `1416` = 1416L, `1441` = 1441L, `1473` = 1473L,
`1532` = 1532L, `1599` = 1599L, `1626` = 1626L, `1669` = 1669L,
`1694` = 1694L, `1718` = 1718L, `1726` = 1726L, `1766` = 1766L,
`1786` = 1786L, `1827` = 1827L, `1853` = 1853L, `1881` = 1881L,
`1922` = 1922L, `1952` = 1952L, `1971` = 1971L, `1984` = 1984L,
`2019` = 2019L, `2039` = 2039L, `2075` = 2075L, `2106` = 2106L,
`2135` = 2135L, `2181` = 2181L, `2206` = 2206L, `2227` = 2227L,
`2238` = 2238L, `2273` = 2273L, `2293` = 2293L, `2325` = 2325L,
`2366` = 2366L, `2391` = 2391L, `2436` = 2436L, `2461` = 2461L,
`2483` = 2483L, `2493` = 2493L), class = "omit"), row.names = c(1L,
2L, 3L, 4L, 5L, 7L), class = "data.frame")
I have built 9 regression models per forecast horizon (t+1, t+5 and t+22) and I am using the predict function to make my forecasts. I have coded this in an R loop, where I also try to assign each forecast to a matrix. My code is the following:
last_window = nrow(EURGBP_final) - window_size
number_of_forecasts = dim( EURGBP_final)[1] - window_size
EURGBP_forecast.1 <- matrix( NA, nrow=number_of_forecasts, ncol=9 )
EURGBP_forecast.5 <- matrix( NA, nrow=number_of_forecasts, ncol=9 )
EURGBP_forecast.22 <- matrix( NA, nrow=number_of_forecasts, ncol=9 )
EURGBP_actuals.1 <- matrix( NA, nrow=number_of_forecasts, ncol=9 )
EURGBP_actuals.5 <- matrix( NA, nrow=number_of_forecasts, ncol=9 )
EURGBP_actuals.22 <- matrix( NA, nrow=number_of_forecasts, ncol=9 )
forecasts = for (i in (1:last_window)){
## data splitting ###
data.estimate <- EURGBP_final[i:(w_size + i - 1), ] # = change to X[1:(w_size + i - 1), ] for expanding window
data.forecast <- EURGBP_final[w_size + i, ]
# --------------------------------------
# Forecast horizon 1
# --------------------------------------
EURGBP_HAR_RV_train <- lm(data.estimateI am trying to calculate realized volatility forecasts using a rolling window forecast. My aim is to use the first 500 observations to forecast the 501st observations, then shift the window forward one step using observations 2 to 501 to predict the 502nd observation. I want this to repeat until I have a complete pseudo out-of-sample forecast.
My df contains 2411 observations of 23 variables, here is small example:
Date
EUR/GBP_RV t+1
EUR/GBP_RV
EUR/GBP_RV_5
EUR/GBP_RV_22
2012-02-13
0.004019947
0.004467109
0.004995980
0.005150602
2012-02-14
0.004077322
0.004019947
0.004704742
0.005099209
2012-02-15
0.004666244
0.004077322
0.004564522
0.005020790
2012-02-16
0.004582351
0.004666244
0.004532930
0.005011078
2012-02-17
0.003951071
0.004582351
0.004362595
0.004999634
2012-02-21
0.005549329
0.004824547
0.004467109
0.004954358
The head of the df can be reproduced with
structure(list(Date = structure(c(15383, 15384, 15385, 15386,
15387, 15391), class = "Date"), `EUR/GBP_RV t+1,t+22` = c(0.00437808494654599,
0.00439764887779732, 0.00441997330738947, 0.00437799055732722,
0.00435021150904479, 0.00434881306458859), `EUR/GBP_RGV t+1,t+22` = c(0.00310674728131117,
0.00311502965608506, 0.00313756204195853, 0.00312923997431178,
0.00310846773074243, 0.00309755540903969), `EUR/GBP_RBV t+1,t+22` = c(0.00304961980133602,
0.00306866297401415, 0.00307794319983677, 0.00302801249035602,
0.00300946121851254, 0.00302272755554915), `EUR/GBP_RV t+1,t+5` = c(0.00425938711995146,
0.00442030721926592, 0.00471470868108043, 0.00487869292442023,
0.00476849421943949, 0.0046067439660438), `EUR/GBP_RGV t+1,t+5` = c(0.00287718093809447,
0.00311308998902836, 0.00344398536439729, 0.00376911066284235,
0.00377425759242542, 0.00353909902900148), `EUR/GBP_RBV t+1,t+5` = c(0.00313771439501486,
0.00310626895475871, 0.0031789431316576, 0.00305962424370556,
0.00288671182187571, 0.00291630955829613), `EUR/GBP_RV t+1` = c(0.00401994700051122,
0.00407732180013827, 0.00466624428620966, 0.00458235106134663,
0.00395107145155152, 0.00554932910921084), `EUR/GBP_RGV t+1` = c(0.00280067842079775,
0.00275522601341373, 0.00296142025653418, 0.00320716195737542,
0.00266141804235125, 0.00440970289025837), `EUR/GBP_RBV t+1` = c(0.00288377777753365,
0.00300554199386584, 0.00360608177982326, 0.00327292734850446,
0.0029202430753471, 0.00336891287836027), `EUR/GBP_RV` = c(0.00446710941914797,
0.00401994700051122, 0.00407732180013827, 0.00466624428620966,
0.00458235106134663, 0.00482454749708351), `EUR/GBP_RV_5` = c(0.00499598016427624,
0.00470474196716823, 0.00456452150727461, 0.00453292965488229,
0.00436259471347075, 0.00442030721926592), `EUR/GBP_RV_22` = c(0.00515060219897263,
0.00509920878086075, 0.00502079002092667, 0.00501107755050095,
0.00499963428727425, 0.00495435807685843), `EUR/GBP_RBV` = c(0.00324667045338159,
0.00288377777753365, 0.00300554199386584, 0.00360608177982326,
0.00327292734850446, 0.00272655057625291), `EUR/GBP_RBV_5` = c(0.0034985439252634,
0.00318731350301598, 0.00319529774619179, 0.0032799330165155,
0.00320299987062176, 0.00310626895475871), `EUR/GBP_RBV_22` = c(0.0036581887941976,
0.00362298829344015, 0.00355498498935768, 0.0035465419934449,
0.00355752455210586, 0.00351669973034298), `EUR/GBP_RGV` = c(0.00306825643155514,
0.00280067842079775, 0.00275522601341373, 0.00296142025653418,
0.00320716195737542, 0.00398022367546721), `EUR/GBP_RGV_5` = c(0.00353290218424469,
0.00345194162523714, 0.00325362896209417, 0.00312087362386985,
0.00295854861593525, 0.00311308998902836), `EUR/GBP_RGV_22` = c(0.00359974659692405,
0.00356342531619103, 0.00352224165959556, 0.00351722666683608,
0.00349184335907274, 0.00346394410318992), `EUR/GBP_TotalCount` = structure(c(-0.179518680545716,
-0.0757259172924681, 0.333514120677483, 0.759064450015801, -0.419724789788948,
-0.360414639358521), .Dim = c(6L, 1L)), `EUR/GBP_BloombergCount` = structure(c(-0.701694550941621,
-0.669811381311996, -0.574161872423118, -0.644304845608295, -0.784590791978649,
-0.631551577756444), .Dim = c(6L, 1L)), `EUR/GBP_SocialMediaCount` = structure(c(-1.68861759789696,
-1.66829994393287, -1.5910928588693, -1.59515638966212, -1.6967446594826,
-1.63172816679749), .Dim = c(6L, 1L)), `EUR/GBP_NewsCount` = structure(c(0.76560533722738,
0.879161625683434, 1.33717198912285, 1.90306082659552, 0.487392430510049,
0.487392430510049), .Dim = c(6L, 1L))), na.action = structure(c(`6` = 6L,
`38` = 38L, `74` = 74L, `101` = 101L, `140` = 140L, `165` = 165L,
`189` = 189L, `197` = 197L, `236` = 236L, `256` = 256L, `323` = 323L,
`351` = 351L, `393` = 393L, `423` = 423L, `442` = 442L, `455` = 455L,
`490` = 490L, `510` = 510L, `551` = 551L, `576` = 576L, `605` = 605L,
`646` = 646L, `676` = 676L, `696` = 696L, `708` = 708L, `742` = 742L,
`762` = 762L, `793` = 793L, `829` = 829L, `858` = 858L, `904` = 904L,
`929` = 929L, `950` = 950L, `961` = 961L, `996` = 996L, `1016` = 1016L,
`1089` = 1089L, `1114` = 1114L, `1159` = 1159L, `1184` = 1184L,
`1207` = 1207L, `1216` = 1216L, `1238` = 1238L, `1243` = 1243L,
`1253` = 1253L, `1278` = 1278L, `1315` = 1315L, `1346` = 1346L,
`1372` = 1372L, `1416` = 1416L, `1441` = 1441L, `1473` = 1473L,
`1532` = 1532L, `1599` = 1599L, `1626` = 1626L, `1669` = 1669L,
`1694` = 1694L, `1718` = 1718L, `1726` = 1726L, `1766` = 1766L,
`1786` = 1786L, `1827` = 1827L, `1853` = 1853L, `1881` = 1881L,
`1922` = 1922L, `1952` = 1952L, `1971` = 1971L, `1984` = 1984L,
`2019` = 2019L, `2039` = 2039L, `2075` = 2075L, `2106` = 2106L,
`2135` = 2135L, `2181` = 2181L, `2206` = 2206L, `2227` = 2227L,
`2238` = 2238L, `2273` = 2273L, `2293` = 2293L, `2325` = 2325L,
`2366` = 2366L, `2391` = 2391L, `2436` = 2436L, `2461` = 2461L,
`2483` = 2483L, `2493` = 2493L), class = "omit"), row.names = c(1L,
2L, 3L, 4L, 5L, 7L), class = "data.frame")
I have built 9 regression models per forecast horizon (t+1, t+5 and t+22) and I am using the predict function to make my forecasts. I have coded this in an R loop, where I also try to assign each forecast to a matrix. My code is the following:
EUR/GBP_RV t+1`~data.estimateI am trying to calculate realized volatility forecasts using a rolling window forecast. My aim is to use the first 500 observations to forecast the 501st observations, then shift the window forward one step using observations 2 to 501 to predict the 502nd observation. I want this to repeat until I have a complete pseudo out-of-sample forecast.
My df contains 2411 observations of 23 variables, here is small example:
Date
EUR/GBP_RV t+1
EUR/GBP_RV
EUR/GBP_RV_5
EUR/GBP_RV_22
2012-02-13
0.004019947
0.004467109
0.004995980
0.005150602
2012-02-14
0.004077322
0.004019947
0.004704742
0.005099209
2012-02-15
0.004666244
0.004077322
0.004564522
0.005020790
2012-02-16
0.004582351
0.004666244
0.004532930
0.005011078
2012-02-17
0.003951071
0.004582351
0.004362595
0.004999634
2012-02-21
0.005549329
0.004824547
0.004467109
0.004954358
The head of the df can be reproduced with
structure(list(Date = structure(c(15383, 15384, 15385, 15386,
15387, 15391), class = "Date"), `EUR/GBP_RV t+1,t+22` = c(0.00437808494654599,
0.00439764887779732, 0.00441997330738947, 0.00437799055732722,
0.00435021150904479, 0.00434881306458859), `EUR/GBP_RGV t+1,t+22` = c(0.00310674728131117,
0.00311502965608506, 0.00313756204195853, 0.00312923997431178,
0.00310846773074243, 0.00309755540903969), `EUR/GBP_RBV t+1,t+22` = c(0.00304961980133602,
0.00306866297401415, 0.00307794319983677, 0.00302801249035602,
0.00300946121851254, 0.00302272755554915), `EUR/GBP_RV t+1,t+5` = c(0.00425938711995146,
0.00442030721926592, 0.00471470868108043, 0.00487869292442023,
0.00476849421943949, 0.0046067439660438), `EUR/GBP_RGV t+1,t+5` = c(0.00287718093809447,
0.00311308998902836, 0.00344398536439729, 0.00376911066284235,
0.00377425759242542, 0.00353909902900148), `EUR/GBP_RBV t+1,t+5` = c(0.00313771439501486,
0.00310626895475871, 0.0031789431316576, 0.00305962424370556,
0.00288671182187571, 0.00291630955829613), `EUR/GBP_RV t+1` = c(0.00401994700051122,
0.00407732180013827, 0.00466624428620966, 0.00458235106134663,
0.00395107145155152, 0.00554932910921084), `EUR/GBP_RGV t+1` = c(0.00280067842079775,
0.00275522601341373, 0.00296142025653418, 0.00320716195737542,
0.00266141804235125, 0.00440970289025837), `EUR/GBP_RBV t+1` = c(0.00288377777753365,
0.00300554199386584, 0.00360608177982326, 0.00327292734850446,
0.0029202430753471, 0.00336891287836027), `EUR/GBP_RV` = c(0.00446710941914797,
0.00401994700051122, 0.00407732180013827, 0.00466624428620966,
0.00458235106134663, 0.00482454749708351), `EUR/GBP_RV_5` = c(0.00499598016427624,
0.00470474196716823, 0.00456452150727461, 0.00453292965488229,
0.00436259471347075, 0.00442030721926592), `EUR/GBP_RV_22` = c(0.00515060219897263,
0.00509920878086075, 0.00502079002092667, 0.00501107755050095,
0.00499963428727425, 0.00495435807685843), `EUR/GBP_RBV` = c(0.00324667045338159,
0.00288377777753365, 0.00300554199386584, 0.00360608177982326,
0.00327292734850446, 0.00272655057625291), `EUR/GBP_RBV_5` = c(0.0034985439252634,
0.00318731350301598, 0.00319529774619179, 0.0032799330165155,
0.00320299987062176, 0.00310626895475871), `EUR/GBP_RBV_22` = c(0.0036581887941976,
0.00362298829344015, 0.00355498498935768, 0.0035465419934449,
0.00355752455210586, 0.00351669973034298), `EUR/GBP_RGV` = c(0.00306825643155514,
0.00280067842079775, 0.00275522601341373, 0.00296142025653418,
0.00320716195737542, 0.00398022367546721), `EUR/GBP_RGV_5` = c(0.00353290218424469,
0.00345194162523714, 0.00325362896209417, 0.00312087362386985,
0.00295854861593525, 0.00311308998902836), `EUR/GBP_RGV_22` = c(0.00359974659692405,
0.00356342531619103, 0.00352224165959556, 0.00351722666683608,
0.00349184335907274, 0.00346394410318992), `EUR/GBP_TotalCount` = structure(c(-0.179518680545716,
-0.0757259172924681, 0.333514120677483, 0.759064450015801, -0.419724789788948,
-0.360414639358521), .Dim = c(6L, 1L)), `EUR/GBP_BloombergCount` = structure(c(-0.701694550941621,
-0.669811381311996, -0.574161872423118, -0.644304845608295, -0.784590791978649,
-0.631551577756444), .Dim = c(6L, 1L)), `EUR/GBP_SocialMediaCount` = structure(c(-1.68861759789696,
-1.66829994393287, -1.5910928588693, -1.59515638966212, -1.6967446594826,
-1.63172816679749), .Dim = c(6L, 1L)), `EUR/GBP_NewsCount` = structure(c(0.76560533722738,
0.879161625683434, 1.33717198912285, 1.90306082659552, 0.487392430510049,
0.487392430510049), .Dim = c(6L, 1L))), na.action = structure(c(`6` = 6L,
`38` = 38L, `74` = 74L, `101` = 101L, `140` = 140L, `165` = 165L,
`189` = 189L, `197` = 197L, `236` = 236L, `256` = 256L, `323` = 323L,
`351` = 351L, `393` = 393L, `423` = 423L, `442` = 442L, `455` = 455L,
`490` = 490L, `510` = 510L, `551` = 551L, `576` = 576L, `605` = 605L,
`646` = 646L, `676` = 676L, `696` = 696L, `708` = 708L, `742` = 742L,
`762` = 762L, `793` = 793L, `829` = 829L, `858` = 858L, `904` = 904L,
`929` = 929L, `950` = 950L, `961` = 961L, `996` = 996L, `1016` = 1016L,
`1089` = 1089L, `1114` = 1114L, `1159` = 1159L, `1184` = 1184L,
`1207` = 1207L, `1216` = 1216L, `1238` = 1238L, `1243` = 1243L,
`1253` = 1253L, `1278` = 1278L, `1315` = 1315L, `1346` = 1346L,
`1372` = 1372L, `1416` = 1416L, `1441` = 1441L, `1473` = 1473L,
`1532` = 1532L, `1599` = 1599L, `1626` = 1626L, `1669` = 1669L,
`1694` = 1694L, `1718` = 1718L, `1726` = 1726L, `1766` = 1766L,
`1786` = 1786L, `1827` = 1827L, `1853` = 1853L, `1881` = 1881L,
`1922` = 1922L, `1952` = 1952L, `1971` = 1971L, `1984` = 1984L,
`2019` = 2019L, `2039` = 2039L, `2075` = 2075L, `2106` = 2106L,
`2135` = 2135L, `2181` = 2181L, `2206` = 2206L, `2227` = 2227L,
`2238` = 2238L, `2273` = 2273L, `2293` = 2293L, `2325` = 2325L,
`2366` = 2366L, `2391` = 2391L, `2436` = 2436L, `2461` = 2461L,
`2483` = 2483L, `2493` = 2493L), class = "omit"), row.names = c(1L,
2L, 3L, 4L, 5L, 7L), class = "data.frame")
I have built 9 regression models per forecast horizon (t+1, t+5 and t+22) and I am using the predict function to make my forecasts. I have coded this in an R loop, where I also try to assign each forecast to a matrix. My code is the following:
EUR/GBP_RV`+data.estimateI am trying to calculate realized volatility forecasts using a rolling window forecast. My aim is to use the first 500 observations to forecast the 501st observations, then shift the window forward one step using observations 2 to 501 to predict the 502nd observation. I want this to repeat until I have a complete pseudo out-of-sample forecast.
My df contains 2411 observations of 23 variables, here is small example:
Date
EUR/GBP_RV t+1
EUR/GBP_RV
EUR/GBP_RV_5
EUR/GBP_RV_22
2012-02-13
0.004019947
0.004467109
0.004995980
0.005150602
2012-02-14
0.004077322
0.004019947
0.004704742
0.005099209
2012-02-15
0.004666244
0.004077322
0.004564522
0.005020790
2012-02-16
0.004582351
0.004666244
0.004532930
0.005011078
2012-02-17
0.003951071
0.004582351
0.004362595
0.004999634
2012-02-21
0.005549329
0.004824547
0.004467109
0.004954358
The head of the df can be reproduced with
structure(list(Date = structure(c(15383, 15384, 15385, 15386,
15387, 15391), class = "Date"), `EUR/GBP_RV t+1,t+22` = c(0.00437808494654599,
0.00439764887779732, 0.00441997330738947, 0.00437799055732722,
0.00435021150904479, 0.00434881306458859), `EUR/GBP_RGV t+1,t+22` = c(0.00310674728131117,
0.00311502965608506, 0.00313756204195853, 0.00312923997431178,
0.00310846773074243, 0.00309755540903969), `EUR/GBP_RBV t+1,t+22` = c(0.00304961980133602,
0.00306866297401415, 0.00307794319983677, 0.00302801249035602,
0.00300946121851254, 0.00302272755554915), `EUR/GBP_RV t+1,t+5` = c(0.00425938711995146,
0.00442030721926592, 0.00471470868108043, 0.00487869292442023,
0.00476849421943949, 0.0046067439660438), `EUR/GBP_RGV t+1,t+5` = c(0.00287718093809447,
0.00311308998902836, 0.00344398536439729, 0.00376911066284235,
0.00377425759242542, 0.00353909902900148), `EUR/GBP_RBV t+1,t+5` = c(0.00313771439501486,
0.00310626895475871, 0.0031789431316576, 0.00305962424370556,
0.00288671182187571, 0.00291630955829613), `EUR/GBP_RV t+1` = c(0.00401994700051122,
0.00407732180013827, 0.00466624428620966, 0.00458235106134663,
0.00395107145155152, 0.00554932910921084), `EUR/GBP_RGV t+1` = c(0.00280067842079775,
0.00275522601341373, 0.00296142025653418, 0.00320716195737542,
0.00266141804235125, 0.00440970289025837), `EUR/GBP_RBV t+1` = c(0.00288377777753365,
0.00300554199386584, 0.00360608177982326, 0.00327292734850446,
0.0029202430753471, 0.00336891287836027), `EUR/GBP_RV` = c(0.00446710941914797,
0.00401994700051122, 0.00407732180013827, 0.00466624428620966,
0.00458235106134663, 0.00482454749708351), `EUR/GBP_RV_5` = c(0.00499598016427624,
0.00470474196716823, 0.00456452150727461, 0.00453292965488229,
0.00436259471347075, 0.00442030721926592), `EUR/GBP_RV_22` = c(0.00515060219897263,
0.00509920878086075, 0.00502079002092667, 0.00501107755050095,
0.00499963428727425, 0.00495435807685843), `EUR/GBP_RBV` = c(0.00324667045338159,
0.00288377777753365, 0.00300554199386584, 0.00360608177982326,
0.00327292734850446, 0.00272655057625291), `EUR/GBP_RBV_5` = c(0.0034985439252634,
0.00318731350301598, 0.00319529774619179, 0.0032799330165155,
0.00320299987062176, 0.00310626895475871), `EUR/GBP_RBV_22` = c(0.0036581887941976,
0.00362298829344015, 0.00355498498935768, 0.0035465419934449,
0.00355752455210586, 0.00351669973034298), `EUR/GBP_RGV` = c(0.00306825643155514,
0.00280067842079775, 0.00275522601341373, 0.00296142025653418,
0.00320716195737542, 0.00398022367546721), `EUR/GBP_RGV_5` = c(0.00353290218424469,
0.00345194162523714, 0.00325362896209417, 0.00312087362386985,
0.00295854861593525, 0.00311308998902836), `EUR/GBP_RGV_22` = c(0.00359974659692405,
0.00356342531619103, 0.00352224165959556, 0.00351722666683608,
0.00349184335907274, 0.00346394410318992), `EUR/GBP_TotalCount` = structure(c(-0.179518680545716,
-0.0757259172924681, 0.333514120677483, 0.759064450015801, -0.419724789788948,
-0.360414639358521), .Dim = c(6L, 1L)), `EUR/GBP_BloombergCount` = structure(c(-0.701694550941621,
-0.669811381311996, -0.574161872423118, -0.644304845608295, -0.784590791978649,
-0.631551577756444), .Dim = c(6L, 1L)), `EUR/GBP_SocialMediaCount` = structure(c(-1.68861759789696,
-1.66829994393287, -1.5910928588693, -1.59515638966212, -1.6967446594826,
-1.63172816679749), .Dim = c(6L, 1L)), `EUR/GBP_NewsCount` = structure(c(0.76560533722738,
0.879161625683434, 1.33717198912285, 1.90306082659552, 0.487392430510049,
0.487392430510049), .Dim = c(6L, 1L))), na.action = structure(c(`6` = 6L,
`38` = 38L, `74` = 74L, `101` = 101L, `140` = 140L, `165` = 165L,
`189` = 189L, `197` = 197L, `236` = 236L, `256` = 256L, `323` = 323L,
`351` = 351L, `393` = 393L, `423` = 423L, `442` = 442L, `455` = 455L,
`490` = 490L, `510` = 510L, `551` = 551L, `576` = 576L, `605` = 605L,
`646` = 646L, `676` = 676L, `696` = 696L, `708` = 708L, `742` = 742L,
`762` = 762L, `793` = 793L, `829` = 829L, `858` = 858L, `904` = 904L,
`929` = 929L, `950` = 950L, `961` = 961L, `996` = 996L, `1016` = 1016L,
`1089` = 1089L, `1114` = 1114L, `1159` = 1159L, `1184` = 1184L,
`1207` = 1207L, `1216` = 1216L, `1238` = 1238L, `1243` = 1243L,
`1253` = 1253L, `1278` = 1278L, `1315` = 1315L, `1346` = 1346L,
`1372` = 1372L, `1416` = 1416L, `1441` = 1441L, `1473` = 1473L,
`1532` = 1532L, `1599` = 1599L, `1626` = 1626L, `1669` = 1669L,
`1694` = 1694L, `1718` = 1718L, `1726` = 1726L, `1766` = 1766L,
`1786` = 1786L, `1827` = 1827L, `1853` = 1853L, `1881` = 1881L,
`1922` = 1922L, `1952` = 1952L, `1971` = 1971L, `1984` = 1984L,
`2019` = 2019L, `2039` = 2039L, `2075` = 2075L, `2106` = 2106L,
`2135` = 2135L, `2181` = 2181L, `2206` = 2206L, `2227` = 2227L,
`2238` = 2238L, `2273` = 2273L, `2293` = 2293L, `2325` = 2325L,
`2366` = 2366L, `2391` = 2391L, `2436` = 2436L, `2461` = 2461L,
`2483` = 2483L, `2493` = 2493L), class = "omit"), row.names = c(1L,
2L, 3L, 4L, 5L, 7L), class = "data.frame")
I have built 9 regression models per forecast horizon (t+1, t+5 and t+22) and I am using the predict function to make my forecasts. I have coded this in an R loop, where I also try to assign each forecast to a matrix. My code is the following:
EUR/GBP_RV_5`+data.estimateI am trying to calculate realized volatility forecasts using a rolling window forecast. My aim is to use the first 500 observations to forecast the 501st observations, then shift the window forward one step using observations 2 to 501 to predict the 502nd observation. I want this to repeat until I have a complete pseudo out-of-sample forecast.
My df contains 2411 observations of 23 variables, here is small example:
Date
EUR/GBP_RV t+1
EUR/GBP_RV
EUR/GBP_RV_5
EUR/GBP_RV_22
2012-02-13
0.004019947
0.004467109
0.004995980
0.005150602
2012-02-14
0.004077322
0.004019947
0.004704742
0.005099209
2012-02-15
0.004666244
0.004077322
0.004564522
0.005020790
2012-02-16
0.004582351
0.004666244
0.004532930
0.005011078
2012-02-17
0.003951071
0.004582351
0.004362595
0.004999634
2012-02-21
0.005549329
0.004824547
0.004467109
0.004954358
The head of the df can be reproduced with
structure(list(Date = structure(c(15383, 15384, 15385, 15386,
15387, 15391), class = "Date"), `EUR/GBP_RV t+1,t+22` = c(0.00437808494654599,
0.00439764887779732, 0.00441997330738947, 0.00437799055732722,
0.00435021150904479, 0.00434881306458859), `EUR/GBP_RGV t+1,t+22` = c(0.00310674728131117,
0.00311502965608506, 0.00313756204195853, 0.00312923997431178,
0.00310846773074243, 0.00309755540903969), `EUR/GBP_RBV t+1,t+22` = c(0.00304961980133602,
0.00306866297401415, 0.00307794319983677, 0.00302801249035602,
0.00300946121851254, 0.00302272755554915), `EUR/GBP_RV t+1,t+5` = c(0.00425938711995146,
0.00442030721926592, 0.00471470868108043, 0.00487869292442023,
0.00476849421943949, 0.0046067439660438), `EUR/GBP_RGV t+1,t+5` = c(0.00287718093809447,
0.00311308998902836, 0.00344398536439729, 0.00376911066284235,
0.00377425759242542, 0.00353909902900148), `EUR/GBP_RBV t+1,t+5` = c(0.00313771439501486,
0.00310626895475871, 0.0031789431316576, 0.00305962424370556,
0.00288671182187571, 0.00291630955829613), `EUR/GBP_RV t+1` = c(0.00401994700051122,
0.00407732180013827, 0.00466624428620966, 0.00458235106134663,
0.00395107145155152, 0.00554932910921084), `EUR/GBP_RGV t+1` = c(0.00280067842079775,
0.00275522601341373, 0.00296142025653418, 0.00320716195737542,
0.00266141804235125, 0.00440970289025837), `EUR/GBP_RBV t+1` = c(0.00288377777753365,
0.00300554199386584, 0.00360608177982326, 0.00327292734850446,
0.0029202430753471, 0.00336891287836027), `EUR/GBP_RV` = c(0.00446710941914797,
0.00401994700051122, 0.00407732180013827, 0.00466624428620966,
0.00458235106134663, 0.00482454749708351), `EUR/GBP_RV_5` = c(0.00499598016427624,
0.00470474196716823, 0.00456452150727461, 0.00453292965488229,
0.00436259471347075, 0.00442030721926592), `EUR/GBP_RV_22` = c(0.00515060219897263,
0.00509920878086075, 0.00502079002092667, 0.00501107755050095,
0.00499963428727425, 0.00495435807685843), `EUR/GBP_RBV` = c(0.00324667045338159,
0.00288377777753365, 0.00300554199386584, 0.00360608177982326,
0.00327292734850446, 0.00272655057625291), `EUR/GBP_RBV_5` = c(0.0034985439252634,
0.00318731350301598, 0.00319529774619179, 0.0032799330165155,
0.00320299987062176, 0.00310626895475871), `EUR/GBP_RBV_22` = c(0.0036581887941976,
0.00362298829344015, 0.00355498498935768, 0.0035465419934449,
0.00355752455210586, 0.00351669973034298), `EUR/GBP_RGV` = c(0.00306825643155514,
0.00280067842079775, 0.00275522601341373, 0.00296142025653418,
0.00320716195737542, 0.00398022367546721), `EUR/GBP_RGV_5` = c(0.00353290218424469,
0.00345194162523714, 0.00325362896209417, 0.00312087362386985,
0.00295854861593525, 0.00311308998902836), `EUR/GBP_RGV_22` = c(0.00359974659692405,
0.00356342531619103, 0.00352224165959556, 0.00351722666683608,
0.00349184335907274, 0.00346394410318992), `EUR/GBP_TotalCount` = structure(c(-0.179518680545716,
-0.0757259172924681, 0.333514120677483, 0.759064450015801, -0.419724789788948,
-0.360414639358521), .Dim = c(6L, 1L)), `EUR/GBP_BloombergCount` = structure(c(-0.701694550941621,
-0.669811381311996, -0.574161872423118, -0.644304845608295, -0.784590791978649,
-0.631551577756444), .Dim = c(6L, 1L)), `EUR/GBP_SocialMediaCount` = structure(c(-1.68861759789696,
-1.66829994393287, -1.5910928588693, -1.59515638966212, -1.6967446594826,
-1.63172816679749), .Dim = c(6L, 1L)), `EUR/GBP_NewsCount` = structure(c(0.76560533722738,
0.879161625683434, 1.33717198912285, 1.90306082659552, 0.487392430510049,
0.487392430510049), .Dim = c(6L, 1L))), na.action = structure(c(`6` = 6L,
`38` = 38L, `74` = 74L, `101` = 101L, `140` = 140L, `165` = 165L,
`189` = 189L, `197` = 197L, `236` = 236L, `256` = 256L, `323` = 323L,
`351` = 351L, `393` = 393L, `423` = 423L, `442` = 442L, `455` = 455L,
`490` = 490L, `510` = 510L, `551` = 551L, `576` = 576L, `605` = 605L,
`646` = 646L, `676` = 676L, `696` = 696L, `708` = 708L, `742` = 742L,
`762` = 762L, `793` = 793L, `829` = 829L, `858` = 858L, `904` = 904L,
`929` = 929L, `950` = 950L, `961` = 961L, `996` = 996L, `1016` = 1016L,
`1089` = 1089L, `1114` = 1114L, `1159` = 1159L, `1184` = 1184L,
`1207` = 1207L, `1216` = 1216L, `1238` = 1238L, `1243` = 1243L,
`1253` = 1253L, `1278` = 1278L, `1315` = 1315L, `1346` = 1346L,
`1372` = 1372L, `1416` = 1416L, `1441` = 1441L, `1473` = 1473L,
`1532` = 1532L, `1599` = 1599L, `1626` = 1626L, `1669` = 1669L,
`1694` = 1694L, `1718` = 1718L, `1726` = 1726L, `1766` = 1766L,
`1786` = 1786L, `1827` = 1827L, `1853` = 1853L, `1881` = 1881L,
`1922` = 1922L, `1952` = 1952L, `1971` = 1971L, `1984` = 1984L,
`2019` = 2019L, `2039` = 2039L, `2075` = 2075L, `2106` = 2106L,
`2135` = 2135L, `2181` = 2181L, `2206` = 2206L, `2227` = 2227L,
`2238` = 2238L, `2273` = 2273L, `2293` = 2293L, `2325` = 2325L,
`2366` = 2366L, `2391` = 2391L, `2436` = 2436L, `2461` = 2461L,
`2483` = 2483L, `2493` = 2493L), class = "omit"), row.names = c(1L,
2L, 3L, 4L, 5L, 7L), class = "data.frame")
I have built 9 regression models per forecast horizon (t+1, t+5 and t+22) and I am using the predict function to make my forecasts. I have coded this in an R loop, where I also try to assign each forecast to a matrix. My code is the following:
EUR/GBP_RV_22`)
EURGBP_HAR_RV_NT_train <- lm(data.estimateI am trying to calculate realized volatility forecasts using a rolling window forecast. My aim is to use the first 500 observations to forecast the 501st observations, then shift the window forward one step using observations 2 to 501 to predict the 502nd observation. I want this to repeat until I have a complete pseudo out-of-sample forecast.
My df contains 2411 observations of 23 variables, here is small example:
Date
EUR/GBP_RV t+1
EUR/GBP_RV
EUR/GBP_RV_5
EUR/GBP_RV_22
2012-02-13
0.004019947
0.004467109
0.004995980
0.005150602
2012-02-14
0.004077322
0.004019947
0.004704742
0.005099209
2012-02-15
0.004666244
0.004077322
0.004564522
0.005020790
2012-02-16
0.004582351
0.004666244
0.004532930
0.005011078
2012-02-17
0.003951071
0.004582351
0.004362595
0.004999634
2012-02-21
0.005549329
0.004824547
0.004467109
0.004954358
The head of the df can be reproduced with
structure(list(Date = structure(c(15383, 15384, 15385, 15386,
15387, 15391), class = "Date"), `EUR/GBP_RV t+1,t+22` = c(0.00437808494654599,
0.00439764887779732, 0.00441997330738947, 0.00437799055732722,
0.00435021150904479, 0.00434881306458859), `EUR/GBP_RGV t+1,t+22` = c(0.00310674728131117,
0.00311502965608506, 0.00313756204195853, 0.00312923997431178,
0.00310846773074243, 0.00309755540903969), `EUR/GBP_RBV t+1,t+22` = c(0.00304961980133602,
0.00306866297401415, 0.00307794319983677, 0.00302801249035602,
0.00300946121851254, 0.00302272755554915), `EUR/GBP_RV t+1,t+5` = c(0.00425938711995146,
0.00442030721926592, 0.00471470868108043, 0.00487869292442023,
0.00476849421943949, 0.0046067439660438), `EUR/GBP_RGV t+1,t+5` = c(0.00287718093809447,
0.00311308998902836, 0.00344398536439729, 0.00376911066284235,
0.00377425759242542, 0.00353909902900148), `EUR/GBP_RBV t+1,t+5` = c(0.00313771439501486,
0.00310626895475871, 0.0031789431316576, 0.00305962424370556,
0.00288671182187571, 0.00291630955829613), `EUR/GBP_RV t+1` = c(0.00401994700051122,
0.00407732180013827, 0.00466624428620966, 0.00458235106134663,
0.00395107145155152, 0.00554932910921084), `EUR/GBP_RGV t+1` = c(0.00280067842079775,
0.00275522601341373, 0.00296142025653418, 0.00320716195737542,
0.00266141804235125, 0.00440970289025837), `EUR/GBP_RBV t+1` = c(0.00288377777753365,
0.00300554199386584, 0.00360608177982326, 0.00327292734850446,
0.0029202430753471, 0.00336891287836027), `EUR/GBP_RV` = c(0.00446710941914797,
0.00401994700051122, 0.00407732180013827, 0.00466624428620966,
0.00458235106134663, 0.00482454749708351), `EUR/GBP_RV_5` = c(0.00499598016427624,
0.00470474196716823, 0.00456452150727461, 0.00453292965488229,
0.00436259471347075, 0.00442030721926592), `EUR/GBP_RV_22` = c(0.00515060219897263,
0.00509920878086075, 0.00502079002092667, 0.00501107755050095,
0.00499963428727425, 0.00495435807685843), `EUR/GBP_RBV` = c(0.00324667045338159,
0.00288377777753365, 0.00300554199386584, 0.00360608177982326,
0.00327292734850446, 0.00272655057625291), `EUR/GBP_RBV_5` = c(0.0034985439252634,
0.00318731350301598, 0.00319529774619179, 0.0032799330165155,
0.00320299987062176, 0.00310626895475871), `EUR/GBP_RBV_22` = c(0.0036581887941976,
0.00362298829344015, 0.00355498498935768, 0.0035465419934449,
0.00355752455210586, 0.00351669973034298), `EUR/GBP_RGV` = c(0.00306825643155514,
0.00280067842079775, 0.00275522601341373, 0.00296142025653418,
0.00320716195737542, 0.00398022367546721), `EUR/GBP_RGV_5` = c(0.00353290218424469,
0.00345194162523714, 0.00325362896209417, 0.00312087362386985,
0.00295854861593525, 0.00311308998902836), `EUR/GBP_RGV_22` = c(0.00359974659692405,
0.00356342531619103, 0.00352224165959556, 0.00351722666683608,
0.00349184335907274, 0.00346394410318992), `EUR/GBP_TotalCount` = structure(c(-0.179518680545716,
-0.0757259172924681, 0.333514120677483, 0.759064450015801, -0.419724789788948,
-0.360414639358521), .Dim = c(6L, 1L)), `EUR/GBP_BloombergCount` = structure(c(-0.701694550941621,
-0.669811381311996, -0.574161872423118, -0.644304845608295, -0.784590791978649,
-0.631551577756444), .Dim = c(6L, 1L)), `EUR/GBP_SocialMediaCount` = structure(c(-1.68861759789696,
-1.66829994393287, -1.5910928588693, -1.59515638966212, -1.6967446594826,
-1.63172816679749), .Dim = c(6L, 1L)), `EUR/GBP_NewsCount` = structure(c(0.76560533722738,
0.879161625683434, 1.33717198912285, 1.90306082659552, 0.487392430510049,
0.487392430510049), .Dim = c(6L, 1L))), na.action = structure(c(`6` = 6L,
`38` = 38L, `74` = 74L, `101` = 101L, `140` = 140L, `165` = 165L,
`189` = 189L, `197` = 197L, `236` = 236L, `256` = 256L, `323` = 323L,
`351` = 351L, `393` = 393L, `423` = 423L, `442` = 442L, `455` = 455L,
`490` = 490L, `510` = 510L, `551` = 551L, `576` = 576L, `605` = 605L,
`646` = 646L, `676` = 676L, `696` = 696L, `708` = 708L, `742` = 742L,
`762` = 762L, `793` = 793L, `829` = 829L, `858` = 858L, `904` = 904L,
`929` = 929L, `950` = 950L, `961` = 961L, `996` = 996L, `1016` = 1016L,
`1089` = 1089L, `1114` = 1114L, `1159` = 1159L, `1184` = 1184L,
`1207` = 1207L, `1216` = 1216L, `1238` = 1238L, `1243` = 1243L,
`1253` = 1253L, `1278` = 1278L, `1315` = 1315L, `1346` = 1346L,
`1372` = 1372L, `1416` = 1416L, `1441` = 1441L, `1473` = 1473L,
`1532` = 1532L, `1599` = 1599L, `1626` = 1626L, `1669` = 1669L,
`1694` = 1694L, `1718` = 1718L, `1726` = 1726L, `1766` = 1766L,
`1786` = 1786L, `1827` = 1827L, `1853` = 1853L, `1881` = 1881L,
`1922` = 1922L, `1952` = 1952L, `1971` = 1971L, `1984` = 1984L,
`2019` = 2019L, `2039` = 2039L, `2075` = 2075L, `2106` = 2106L,
`2135` = 2135L, `2181` = 2181L, `2206` = 2206L, `2227` = 2227L,
`2238` = 2238L, `2273` = 2273L, `2293` = 2293L, `2325` = 2325L,
`2366` = 2366L, `2391` = 2391L, `2436` = 2436L, `2461` = 2461L,
`2483` = 2483L, `2493` = 2493L), class = "omit"), row.names = c(1L,
2L, 3L, 4L, 5L, 7L), class = "data.frame")
I have built 9 regression models per forecast horizon (t+1, t+5 and t+22) and I am using the predict function to make my forecasts. I have coded this in an R loop, where I also try to assign each forecast to a matrix. My code is the following:
EUR/GBP_RV t+1`~data.estimateI am trying to calculate realized volatility forecasts using a rolling window forecast. My aim is to use the first 500 observations to forecast the 501st observations, then shift the window forward one step using observations 2 to 501 to predict the 502nd observation. I want this to repeat until I have a complete pseudo out-of-sample forecast.
My df contains 2411 observations of 23 variables, here is small example:
Date
EUR/GBP_RV t+1
EUR/GBP_RV
EUR/GBP_RV_5
EUR/GBP_RV_22
2012-02-13
0.004019947
0.004467109
0.004995980
0.005150602
2012-02-14
0.004077322
0.004019947
0.004704742
0.005099209
2012-02-15
0.004666244
0.004077322
0.004564522
0.005020790
2012-02-16
0.004582351
0.004666244
0.004532930
0.005011078
2012-02-17
0.003951071
0.004582351
0.004362595
0.004999634
2012-02-21
0.005549329
0.004824547
0.004467109
0.004954358
The head of the df can be reproduced with
structure(list(Date = structure(c(15383, 15384, 15385, 15386,
15387, 15391), class = "Date"), `EUR/GBP_RV t+1,t+22` = c(0.00437808494654599,
0.00439764887779732, 0.00441997330738947, 0.00437799055732722,
0.00435021150904479, 0.00434881306458859), `EUR/GBP_RGV t+1,t+22` = c(0.00310674728131117,
0.00311502965608506, 0.00313756204195853, 0.00312923997431178,
0.00310846773074243, 0.00309755540903969), `EUR/GBP_RBV t+1,t+22` = c(0.00304961980133602,
0.00306866297401415, 0.00307794319983677, 0.00302801249035602,
0.00300946121851254, 0.00302272755554915), `EUR/GBP_RV t+1,t+5` = c(0.00425938711995146,
0.00442030721926592, 0.00471470868108043, 0.00487869292442023,
0.00476849421943949, 0.0046067439660438), `EUR/GBP_RGV t+1,t+5` = c(0.00287718093809447,
0.00311308998902836, 0.00344398536439729, 0.00376911066284235,
0.00377425759242542, 0.00353909902900148), `EUR/GBP_RBV t+1,t+5` = c(0.00313771439501486,
0.00310626895475871, 0.0031789431316576, 0.00305962424370556,
0.00288671182187571, 0.00291630955829613), `EUR/GBP_RV t+1` = c(0.00401994700051122,
0.00407732180013827, 0.00466624428620966, 0.00458235106134663,
0.00395107145155152, 0.00554932910921084), `EUR/GBP_RGV t+1` = c(0.00280067842079775,
0.00275522601341373, 0.00296142025653418, 0.00320716195737542,
0.00266141804235125, 0.00440970289025837), `EUR/GBP_RBV t+1` = c(0.00288377777753365,
0.00300554199386584, 0.00360608177982326, 0.00327292734850446,
0.0029202430753471, 0.00336891287836027), `EUR/GBP_RV` = c(0.00446710941914797,
0.00401994700051122, 0.00407732180013827, 0.00466624428620966,
0.00458235106134663, 0.00482454749708351), `EUR/GBP_RV_5` = c(0.00499598016427624,
0.00470474196716823, 0.00456452150727461, 0.00453292965488229,
0.00436259471347075, 0.00442030721926592), `EUR/GBP_RV_22` = c(0.00515060219897263,
0.00509920878086075, 0.00502079002092667, 0.00501107755050095,
0.00499963428727425, 0.00495435807685843), `EUR/GBP_RBV` = c(0.00324667045338159,
0.00288377777753365, 0.00300554199386584, 0.00360608177982326,
0.00327292734850446, 0.00272655057625291), `EUR/GBP_RBV_5` = c(0.0034985439252634,
0.00318731350301598, 0.00319529774619179, 0.0032799330165155,
0.00320299987062176, 0.00310626895475871), `EUR/GBP_RBV_22` = c(0.0036581887941976,
0.00362298829344015, 0.00355498498935768, 0.0035465419934449,
0.00355752455210586, 0.00351669973034298), `EUR/GBP_RGV` = c(0.00306825643155514,
0.00280067842079775, 0.00275522601341373, 0.00296142025653418,
0.00320716195737542, 0.00398022367546721), `EUR/GBP_RGV_5` = c(0.00353290218424469,
0.00345194162523714, 0.00325362896209417, 0.00312087362386985,
0.00295854861593525, 0.00311308998902836), `EUR/GBP_RGV_22` = c(0.00359974659692405,
0.00356342531619103, 0.00352224165959556, 0.00351722666683608,
0.00349184335907274, 0.00346394410318992), `EUR/GBP_TotalCount` = structure(c(-0.179518680545716,
-0.0757259172924681, 0.333514120677483, 0.759064450015801, -0.419724789788948,
-0.360414639358521), .Dim = c(6L, 1L)), `EUR/GBP_BloombergCount` = structure(c(-0.701694550941621,
-0.669811381311996, -0.574161872423118, -0.644304845608295, -0.784590791978649,
-0.631551577756444), .Dim = c(6L, 1L)), `EUR/GBP_SocialMediaCount` = structure(c(-1.68861759789696,
-1.66829994393287, -1.5910928588693, -1.59515638966212, -1.6967446594826,
-1.63172816679749), .Dim = c(6L, 1L)), `EUR/GBP_NewsCount` = structure(c(0.76560533722738,
0.879161625683434, 1.33717198912285, 1.90306082659552, 0.487392430510049,
0.487392430510049), .Dim = c(6L, 1L))), na.action = structure(c(`6` = 6L,
`38` = 38L, `74` = 74L, `101` = 101L, `140` = 140L, `165` = 165L,
`189` = 189L, `197` = 197L, `236` = 236L, `256` = 256L, `323` = 323L,
`351` = 351L, `393` = 393L, `423` = 423L, `442` = 442L, `455` = 455L,
`490` = 490L, `510` = 510L, `551` = 551L, `576` = 576L, `605` = 605L,
`646` = 646L, `676` = 676L, `696` = 696L, `708` = 708L, `742` = 742L,
`762` = 762L, `793` = 793L, `829` = 829L, `858` = 858L, `904` = 904L,
`929` = 929L, `950` = 950L, `961` = 961L, `996` = 996L, `1016` = 1016L,
`1089` = 1089L, `1114` = 1114L, `1159` = 1159L, `1184` = 1184L,
`1207` = 1207L, `1216` = 1216L, `1238` = 1238L, `1243` = 1243L,
`1253` = 1253L, `1278` = 1278L, `1315` = 1315L, `1346` = 1346L,
`1372` = 1372L, `1416` = 1416L, `1441` = 1441L, `1473` = 1473L,
`1532` = 1532L, `1599` = 1599L, `1626` = 1626L, `1669` = 1669L,
`1694` = 1694L, `1718` = 1718L, `1726` = 1726L, `1766` = 1766L,
`1786` = 1786L, `1827` = 1827L, `1853` = 1853L, `1881` = 1881L,
`1922` = 1922L, `1952` = 1952L, `1971` = 1971L, `1984` = 1984L,
`2019` = 2019L, `2039` = 2039L, `2075` = 2075L, `2106` = 2106L,
`2135` = 2135L, `2181` = 2181L, `2206` = 2206L, `2227` = 2227L,
`2238` = 2238L, `2273` = 2273L, `2293` = 2293L, `2325` = 2325L,
`2366` = 2366L, `2391` = 2391L, `2436` = 2436L, `2461` = 2461L,
`2483` = 2483L, `2493` = 2493L), class = "omit"), row.names = c(1L,
2L, 3L, 4L, 5L, 7L), class = "data.frame")
I have built 9 regression models per forecast horizon (t+1, t+5 and t+22) and I am using the predict function to make my forecasts. I have coded this in an R loop, where I also try to assign each forecast to a matrix. My code is the following:
EUR/GBP_RV`+data.estimateI am trying to calculate realized volatility forecasts using a rolling window forecast. My aim is to use the first 500 observations to forecast the 501st observations, then shift the window forward one step using observations 2 to 501 to predict the 502nd observation. I want this to repeat until I have a complete pseudo out-of-sample forecast.
My df contains 2411 observations of 23 variables, here is small example:
Date
EUR/GBP_RV t+1
EUR/GBP_RV
EUR/GBP_RV_5
EUR/GBP_RV_22
2012-02-13
0.004019947
0.004467109
0.004995980
0.005150602
2012-02-14
0.004077322
0.004019947
0.004704742
0.005099209
2012-02-15
0.004666244
0.004077322
0.004564522
0.005020790
2012-02-16
0.004582351
0.004666244
0.004532930
0.005011078
2012-02-17
0.003951071
0.004582351
0.004362595
0.004999634
2012-02-21
0.005549329
0.004824547
0.004467109
0.004954358
The head of the df can be reproduced with
structure(list(Date = structure(c(15383, 15384, 15385, 15386,
15387, 15391), class = "Date"), `EUR/GBP_RV t+1,t+22` = c(0.00437808494654599,
0.00439764887779732, 0.00441997330738947, 0.00437799055732722,
0.00435021150904479, 0.00434881306458859), `EUR/GBP_RGV t+1,t+22` = c(0.00310674728131117,
0.00311502965608506, 0.00313756204195853, 0.00312923997431178,
0.00310846773074243, 0.00309755540903969), `EUR/GBP_RBV t+1,t+22` = c(0.00304961980133602,
0.00306866297401415, 0.00307794319983677, 0.00302801249035602,
0.00300946121851254, 0.00302272755554915), `EUR/GBP_RV t+1,t+5` = c(0.00425938711995146,
0.00442030721926592, 0.00471470868108043, 0.00487869292442023,
0.00476849421943949, 0.0046067439660438), `EUR/GBP_RGV t+1,t+5` = c(0.00287718093809447,
0.00311308998902836, 0.00344398536439729, 0.00376911066284235,
0.00377425759242542, 0.00353909902900148), `EUR/GBP_RBV t+1,t+5` = c(0.00313771439501486,
0.00310626895475871, 0.0031789431316576, 0.00305962424370556,
0.00288671182187571, 0.00291630955829613), `EUR/GBP_RV t+1` = c(0.00401994700051122,
0.00407732180013827, 0.00466624428620966, 0.00458235106134663,
0.00395107145155152, 0.00554932910921084), `EUR/GBP_RGV t+1` = c(0.00280067842079775,
0.00275522601341373, 0.00296142025653418, 0.00320716195737542,
0.00266141804235125, 0.00440970289025837), `EUR/GBP_RBV t+1` = c(0.00288377777753365,
0.00300554199386584, 0.00360608177982326, 0.00327292734850446,
0.0029202430753471, 0.00336891287836027), `EUR/GBP_RV` = c(0.00446710941914797,
0.00401994700051122, 0.00407732180013827, 0.00466624428620966,
0.00458235106134663, 0.00482454749708351), `EUR/GBP_RV_5` = c(0.00499598016427624,
0.00470474196716823, 0.00456452150727461, 0.00453292965488229,
0.00436259471347075, 0.00442030721926592), `EUR/GBP_RV_22` = c(0.00515060219897263,
0.00509920878086075, 0.00502079002092667, 0.00501107755050095,
0.00499963428727425, 0.00495435807685843), `EUR/GBP_RBV` = c(0.00324667045338159,
0.00288377777753365, 0.00300554199386584, 0.00360608177982326,
0.00327292734850446, 0.00272655057625291), `EUR/GBP_RBV_5` = c(0.0034985439252634,
0.00318731350301598, 0.00319529774619179, 0.0032799330165155,
0.00320299987062176, 0.00310626895475871), `EUR/GBP_RBV_22` = c(0.0036581887941976,
0.00362298829344015, 0.00355498498935768, 0.0035465419934449,
0.00355752455210586, 0.00351669973034298), `EUR/GBP_RGV` = c(0.00306825643155514,
0.00280067842079775, 0.00275522601341373, 0.00296142025653418,
0.00320716195737542, 0.00398022367546721), `EUR/GBP_RGV_5` = c(0.00353290218424469,
0.00345194162523714, 0.00325362896209417, 0.00312087362386985,
0.00295854861593525, 0.00311308998902836), `EUR/GBP_RGV_22` = c(0.00359974659692405,
0.00356342531619103, 0.00352224165959556, 0.00351722666683608,
0.00349184335907274, 0.00346394410318992), `EUR/GBP_TotalCount` = structure(c(-0.179518680545716,
-0.0757259172924681, 0.333514120677483, 0.759064450015801, -0.419724789788948,
-0.360414639358521), .Dim = c(6L, 1L)), `EUR/GBP_BloombergCount` = structure(c(-0.701694550941621,
-0.669811381311996, -0.574161872423118, -0.644304845608295, -0.784590791978649,
-0.631551577756444), .Dim = c(6L, 1L)), `EUR/GBP_SocialMediaCount` = structure(c(-1.68861759789696,
-1.66829994393287, -1.5910928588693, -1.59515638966212, -1.6967446594826,
-1.63172816679749), .Dim = c(6L, 1L)), `EUR/GBP_NewsCount` = structure(c(0.76560533722738,
0.879161625683434, 1.33717198912285, 1.90306082659552, 0.487392430510049,
0.487392430510049), .Dim = c(6L, 1L))), na.action = structure(c(`6` = 6L,
`38` = 38L, `74` = 74L, `101` = 101L, `140` = 140L, `165` = 165L,
`189` = 189L, `197` = 197L, `236` = 236L, `256` = 256L, `323` = 323L,
`351` = 351L, `393` = 393L, `423` = 423L, `442` = 442L, `455` = 455L,
`490` = 490L, `510` = 510L, `551` = 551L, `576` = 576L, `605` = 605L,
`646` = 646L, `676` = 676L, `696` = 696L, `708` = 708L, `742` = 742L,
`762` = 762L, `793` = 793L, `829` = 829L, `858` = 858L, `904` = 904L,
`929` = 929L, `950` = 950L, `961` = 961L, `996` = 996L, `1016` = 1016L,
`1089` = 1089L, `1114` = 1114L, `1159` = 1159L, `1184` = 1184L,
`1207` = 1207L, `1216` = 1216L, `1238` = 1238L, `1243` = 1243L,
`1253` = 1253L, `1278` = 1278L, `1315` = 1315L, `1346` = 1346L,
`1372` = 1372L, `1416` = 1416L, `1441` = 1441L, `1473` = 1473L,
`1532` = 1532L, `1599` = 1599L, `1626` = 1626L, `1669` = 1669L,
`1694` = 1694L, `1718` = 1718L, `1726` = 1726L, `1766` = 1766L,
`1786` = 1786L, `1827` = 1827L, `1853` = 1853L, `1881` = 1881L,
`1922` = 1922L, `1952` = 1952L, `1971` = 1971L, `1984` = 1984L,
`2019` = 2019L, `2039` = 2039L, `2075` = 2075L, `2106` = 2106L,
`2135` = 2135L, `2181` = 2181L, `2206` = 2206L, `2227` = 2227L,
`2238` = 2238L, `2273` = 2273L, `2293` = 2293L, `2325` = 2325L,
`2366` = 2366L, `2391` = 2391L, `2436` = 2436L, `2461` = 2461L,
`2483` = 2483L, `2493` = 2493L), class = "omit"), row.names = c(1L,
2L, 3L, 4L, 5L, 7L), class = "data.frame")
I have built 9 regression models per forecast horizon (t+1, t+5 and t+22) and I am using the predict function to make my forecasts. I have coded this in an R loop, where I also try to assign each forecast to a matrix. My code is the following:
EUR/GBP_RV_5`+data.estimateI am trying to calculate realized volatility forecasts using a rolling window forecast. My aim is to use the first 500 observations to forecast the 501st observations, then shift the window forward one step using observations 2 to 501 to predict the 502nd observation. I want this to repeat until I have a complete pseudo out-of-sample forecast.
My df contains 2411 observations of 23 variables, here is small example:
Date
EUR/GBP_RV t+1
EUR/GBP_RV
EUR/GBP_RV_5
EUR/GBP_RV_22
2012-02-13
0.004019947
0.004467109
0.004995980
0.005150602
2012-02-14
0.004077322
0.004019947
0.004704742
0.005099209
2012-02-15
0.004666244
0.004077322
0.004564522
0.005020790
2012-02-16
0.004582351
0.004666244
0.004532930
0.005011078
2012-02-17
0.003951071
0.004582351
0.004362595
0.004999634
2012-02-21
0.005549329
0.004824547
0.004467109
0.004954358
The head of the df can be reproduced with
structure(list(Date = structure(c(15383, 15384, 15385, 15386,
15387, 15391), class = "Date"), `EUR/GBP_RV t+1,t+22` = c(0.00437808494654599,
0.00439764887779732, 0.00441997330738947, 0.00437799055732722,
0.00435021150904479, 0.00434881306458859), `EUR/GBP_RGV t+1,t+22` = c(0.00310674728131117,
0.00311502965608506, 0.00313756204195853, 0.00312923997431178,
0.00310846773074243, 0.00309755540903969), `EUR/GBP_RBV t+1,t+22` = c(0.00304961980133602,
0.00306866297401415, 0.00307794319983677, 0.00302801249035602,
0.00300946121851254, 0.00302272755554915), `EUR/GBP_RV t+1,t+5` = c(0.00425938711995146,
0.00442030721926592, 0.00471470868108043, 0.00487869292442023,
0.00476849421943949, 0.0046067439660438), `EUR/GBP_RGV t+1,t+5` = c(0.00287718093809447,
0.00311308998902836, 0.00344398536439729, 0.00376911066284235,
0.00377425759242542, 0.00353909902900148), `EUR/GBP_RBV t+1,t+5` = c(0.00313771439501486,
0.00310626895475871, 0.0031789431316576, 0.00305962424370556,
0.00288671182187571, 0.00291630955829613), `EUR/GBP_RV t+1` = c(0.00401994700051122,
0.00407732180013827, 0.00466624428620966, 0.00458235106134663,
0.00395107145155152, 0.00554932910921084), `EUR/GBP_RGV t+1` = c(0.00280067842079775,
0.00275522601341373, 0.00296142025653418, 0.00320716195737542,
0.00266141804235125, 0.00440970289025837), `EUR/GBP_RBV t+1` = c(0.00288377777753365,
0.00300554199386584, 0.00360608177982326, 0.00327292734850446,
0.0029202430753471, 0.00336891287836027), `EUR/GBP_RV` = c(0.00446710941914797,
0.00401994700051122, 0.00407732180013827, 0.00466624428620966,
0.00458235106134663, 0.00482454749708351), `EUR/GBP_RV_5` = c(0.00499598016427624,
0.00470474196716823, 0.00456452150727461, 0.00453292965488229,
0.00436259471347075, 0.00442030721926592), `EUR/GBP_RV_22` = c(0.00515060219897263,
0.00509920878086075, 0.00502079002092667, 0.00501107755050095,
0.00499963428727425, 0.00495435807685843), `EUR/GBP_RBV` = c(0.00324667045338159,
0.00288377777753365, 0.00300554199386584, 0.00360608177982326,
0.00327292734850446, 0.00272655057625291), `EUR/GBP_RBV_5` = c(0.0034985439252634,
0.00318731350301598, 0.00319529774619179, 0.0032799330165155,
0.00320299987062176, 0.00310626895475871), `EUR/GBP_RBV_22` = c(0.0036581887941976,
0.00362298829344015, 0.00355498498935768, 0.0035465419934449,
0.00355752455210586, 0.00351669973034298), `EUR/GBP_RGV` = c(0.00306825643155514,
0.00280067842079775, 0.00275522601341373, 0.00296142025653418,
0.00320716195737542, 0.00398022367546721), `EUR/GBP_RGV_5` = c(0.00353290218424469,
0.00345194162523714, 0.00325362896209417, 0.00312087362386985,
0.00295854861593525, 0.00311308998902836), `EUR/GBP_RGV_22` = c(0.00359974659692405,
0.00356342531619103, 0.00352224165959556, 0.00351722666683608,
0.00349184335907274, 0.00346394410318992), `EUR/GBP_TotalCount` = structure(c(-0.179518680545716,
-0.0757259172924681, 0.333514120677483, 0.759064450015801, -0.419724789788948,
-0.360414639358521), .Dim = c(6L, 1L)), `EUR/GBP_BloombergCount` = structure(c(-0.701694550941621,
-0.669811381311996, -0.574161872423118, -0.644304845608295, -0.784590791978649,
-0.631551577756444), .Dim = c(6L, 1L)), `EUR/GBP_SocialMediaCount` = structure(c(-1.68861759789696,
-1.66829994393287, -1.5910928588693, -1.59515638966212, -1.6967446594826,
-1.63172816679749), .Dim = c(6L, 1L)), `EUR/GBP_NewsCount` = structure(c(0.76560533722738,
0.879161625683434, 1.33717198912285, 1.90306082659552, 0.487392430510049,
0.487392430510049), .Dim = c(6L, 1L))), na.action = structure(c(`6` = 6L,
`38` = 38L, `74` = 74L, `101` = 101L, `140` = 140L, `165` = 165L,
`189` = 189L, `197` = 197L, `236` = 236L, `256` = 256L, `323` = 323L,
`351` = 351L, `393` = 393L, `423` = 423L, `442` = 442L, `455` = 455L,
`490` = 490L, `510` = 510L, `551` = 551L, `576` = 576L, `605` = 605L,
`646` = 646L, `676` = 676L, `696` = 696L, `708` = 708L, `742` = 742L,
`762` = 762L, `793` = 793L, `829` = 829L, `858` = 858L, `904` = 904L,
`929` = 929L, `950` = 950L, `961` = 961L, `996` = 996L, `1016` = 1016L,
`1089` = 1089L, `1114` = 1114L, `1159` = 1159L, `1184` = 1184L,
`1207` = 1207L, `1216` = 1216L, `1238` = 1238L, `1243` = 1243L,
`1253` = 1253L, `1278` = 1278L, `1315` = 1315L, `1346` = 1346L,
`1372` = 1372L, `1416` = 1416L, `1441` = 1441L, `1473` = 1473L,
`1532` = 1532L, `1599` = 1599L, `1626` = 1626L, `1669` = 1669L,
`1694` = 1694L, `1718` = 1718L, `1726` = 1726L, `1766` = 1766L,
`1786` = 1786L, `1827` = 1827L, `1853` = 1853L, `1881` = 1881L,
`1922` = 1922L, `1952` = 1952L, `1971` = 1971L, `1984` = 1984L,
`2019` = 2019L, `2039` = 2039L, `2075` = 2075L, `2106` = 2106L,
`2135` = 2135L, `2181` = 2181L, `2206` = 2206L, `2227` = 2227L,
`2238` = 2238L, `2273` = 2273L, `2293` = 2293L, `2325` = 2325L,
`2366` = 2366L, `2391` = 2391L, `2436` = 2436L, `2461` = 2461L,
`2483` = 2483L, `2493` = 2493L), class = "omit"), row.names = c(1L,
2L, 3L, 4L, 5L, 7L), class = "data.frame")
I have built 9 regression models per forecast horizon (t+1, t+5 and t+22) and I am using the predict function to make my forecasts. I have coded this in an R loop, where I also try to assign each forecast to a matrix. My code is the following:
EUR/GBP_RV_22`+data.estimateI am trying to calculate realized volatility forecasts using a rolling window forecast. My aim is to use the first 500 observations to forecast the 501st observations, then shift the window forward one step using observations 2 to 501 to predict the 502nd observation. I want this to repeat until I have a complete pseudo out-of-sample forecast.
My df contains 2411 observations of 23 variables, here is small example:
Date
EUR/GBP_RV t+1
EUR/GBP_RV
EUR/GBP_RV_5
EUR/GBP_RV_22
2012-02-13
0.004019947
0.004467109
0.004995980
0.005150602
2012-02-14
0.004077322
0.004019947
0.004704742
0.005099209
2012-02-15
0.004666244
0.004077322
0.004564522
0.005020790
2012-02-16
0.004582351
0.004666244
0.004532930
0.005011078
2012-02-17
0.003951071
0.004582351
0.004362595
0.004999634
2012-02-21
0.005549329
0.004824547
0.004467109
0.004954358
The head of the df can be reproduced with
structure(list(Date = structure(c(15383, 15384, 15385, 15386,
15387, 15391), class = "Date"), `EUR/GBP_RV t+1,t+22` = c(0.00437808494654599,
0.00439764887779732, 0.00441997330738947, 0.00437799055732722,
0.00435021150904479, 0.00434881306458859), `EUR/GBP_RGV t+1,t+22` = c(0.00310674728131117,
0.00311502965608506, 0.00313756204195853, 0.00312923997431178,
0.00310846773074243, 0.00309755540903969), `EUR/GBP_RBV t+1,t+22` = c(0.00304961980133602,
0.00306866297401415, 0.00307794319983677, 0.00302801249035602,
0.00300946121851254, 0.00302272755554915), `EUR/GBP_RV t+1,t+5` = c(0.00425938711995146,
0.00442030721926592, 0.00471470868108043, 0.00487869292442023,
0.00476849421943949, 0.0046067439660438), `EUR/GBP_RGV t+1,t+5` = c(0.00287718093809447,
0.00311308998902836, 0.00344398536439729, 0.00376911066284235,
0.00377425759242542, 0.00353909902900148), `EUR/GBP_RBV t+1,t+5` = c(0.00313771439501486,
0.00310626895475871, 0.0031789431316576, 0.00305962424370556,
0.00288671182187571, 0.00291630955829613), `EUR/GBP_RV t+1` = c(0.00401994700051122,
0.00407732180013827, 0.00466624428620966, 0.00458235106134663,
0.00395107145155152, 0.00554932910921084), `EUR/GBP_RGV t+1` = c(0.00280067842079775,
0.00275522601341373, 0.00296142025653418, 0.00320716195737542,
0.00266141804235125, 0.00440970289025837), `EUR/GBP_RBV t+1` = c(0.00288377777753365,
0.00300554199386584, 0.00360608177982326, 0.00327292734850446,
0.0029202430753471, 0.00336891287836027), `EUR/GBP_RV` = c(0.00446710941914797,
0.00401994700051122, 0.00407732180013827, 0.00466624428620966,
0.00458235106134663, 0.00482454749708351), `EUR/GBP_RV_5` = c(0.00499598016427624,
0.00470474196716823, 0.00456452150727461, 0.00453292965488229,
0.00436259471347075, 0.00442030721926592), `EUR/GBP_RV_22` = c(0.00515060219897263,
0.00509920878086075, 0.00502079002092667, 0.00501107755050095,
0.00499963428727425, 0.00495435807685843), `EUR/GBP_RBV` = c(0.00324667045338159,
0.00288377777753365, 0.00300554199386584, 0.00360608177982326,
0.00327292734850446, 0.00272655057625291), `EUR/GBP_RBV_5` = c(0.0034985439252634,
0.00318731350301598, 0.00319529774619179, 0.0032799330165155,
0.00320299987062176, 0.00310626895475871), `EUR/GBP_RBV_22` = c(0.0036581887941976,
0.00362298829344015, 0.00355498498935768, 0.0035465419934449,
0.00355752455210586, 0.00351669973034298), `EUR/GBP_RGV` = c(0.00306825643155514,
0.00280067842079775, 0.00275522601341373, 0.00296142025653418,
0.00320716195737542, 0.00398022367546721), `EUR/GBP_RGV_5` = c(0.00353290218424469,
0.00345194162523714, 0.00325362896209417, 0.00312087362386985,
0.00295854861593525, 0.00311308998902836), `EUR/GBP_RGV_22` = c(0.00359974659692405,
0.00356342531619103, 0.00352224165959556, 0.00351722666683608,
0.00349184335907274, 0.00346394410318992), `EUR/GBP_TotalCount` = structure(c(-0.179518680545716,
-0.0757259172924681, 0.333514120677483, 0.759064450015801, -0.419724789788948,
-0.360414639358521), .Dim = c(6L, 1L)), `EUR/GBP_BloombergCount` = structure(c(-0.701694550941621,
-0.669811381311996, -0.574161872423118, -0.644304845608295, -0.784590791978649,
-0.631551577756444), .Dim = c(6L, 1L)), `EUR/GBP_SocialMediaCount` = structure(c(-1.68861759789696,
-1.66829994393287, -1.5910928588693, -1.59515638966212, -1.6967446594826,
-1.63172816679749), .Dim = c(6L, 1L)), `EUR/GBP_NewsCount` = structure(c(0.76560533722738,
0.879161625683434, 1.33717198912285, 1.90306082659552, 0.487392430510049,
0.487392430510049), .Dim = c(6L, 1L))), na.action = structure(c(`6` = 6L,
`38` = 38L, `74` = 74L, `101` = 101L, `140` = 140L, `165` = 165L,
`189` = 189L, `197` = 197L, `236` = 236L, `256` = 256L, `323` = 323L,
`351` = 351L, `393` = 393L, `423` = 423L, `442` = 442L, `455` = 455L,
`490` = 490L, `510` = 510L, `551` = 551L, `576` = 576L, `605` = 605L,
`646` = 646L, `676` = 676L, `696` = 696L, `708` = 708L, `742` = 742L,
`762` = 762L, `793` = 793L, `829` = 829L, `858` = 858L, `904` = 904L,
`929` = 929L, `950` = 950L, `961` = 961L, `996` = 996L, `1016` = 1016L,
`1089` = 1089L, `1114` = 1114L, `1159` = 1159L, `1184` = 1184L,
`1207` = 1207L, `1216` = 1216L, `1238` = 1238L, `1243` = 1243L,
`1253` = 1253L, `1278` = 1278L, `1315` = 1315L, `1346` = 1346L,
`1372` = 1372L, `1416` = 1416L, `1441` = 1441L, `1473` = 1473L,
`1532` = 1532L, `1599` = 1599L, `1626` = 1626L, `1669` = 1669L,
`1694` = 1694L, `1718` = 1718L, `1726` = 1726L, `1766` = 1766L,
`1786` = 1786L, `1827` = 1827L, `1853` = 1853L, `1881` = 1881L,
`1922` = 1922L, `1952` = 1952L, `1971` = 1971L, `1984` = 1984L,
`2019` = 2019L, `2039` = 2039L, `2075` = 2075L, `2106` = 2106L,
`2135` = 2135L, `2181` = 2181L, `2206` = 2206L, `2227` = 2227L,
`2238` = 2238L, `2273` = 2273L, `2293` = 2293L, `2325` = 2325L,
`2366` = 2366L, `2391` = 2391L, `2436` = 2436L, `2461` = 2461L,
`2483` = 2483L, `2493` = 2493L), class = "omit"), row.names = c(1L,
2L, 3L, 4L, 5L, 7L), class = "data.frame")
I have built 9 regression models per forecast horizon (t+1, t+5 and t+22) and I am using the predict function to make my forecasts. I have coded this in an R loop, where I also try to assign each forecast to a matrix. My code is the following:
EUR/GBP_TotalCount`)
EURGBP_HAR_RVB_train <- lm(data.estimateI am trying to calculate realized volatility forecasts using a rolling window forecast. My aim is to use the first 500 observations to forecast the 501st observations, then shift the window forward one step using observations 2 to 501 to predict the 502nd observation. I want this to repeat until I have a complete pseudo out-of-sample forecast.
My df contains 2411 observations of 23 variables, here is small example:
Date
EUR/GBP_RV t+1
EUR/GBP_RV
EUR/GBP_RV_5
EUR/GBP_RV_22
2012-02-13
0.004019947
0.004467109
0.004995980
0.005150602
2012-02-14
0.004077322
0.004019947
0.004704742
0.005099209
2012-02-15
0.004666244
0.004077322
0.004564522
0.005020790
2012-02-16
0.004582351
0.004666244
0.004532930
0.005011078
2012-02-17
0.003951071
0.004582351
0.004362595
0.004999634
2012-02-21
0.005549329
0.004824547
0.004467109
0.004954358
The head of the df can be reproduced with
structure(list(Date = structure(c(15383, 15384, 15385, 15386,
15387, 15391), class = "Date"), `EUR/GBP_RV t+1,t+22` = c(0.00437808494654599,
0.00439764887779732, 0.00441997330738947, 0.00437799055732722,
0.00435021150904479, 0.00434881306458859), `EUR/GBP_RGV t+1,t+22` = c(0.00310674728131117,
0.00311502965608506, 0.00313756204195853, 0.00312923997431178,
0.00310846773074243, 0.00309755540903969), `EUR/GBP_RBV t+1,t+22` = c(0.00304961980133602,
0.00306866297401415, 0.00307794319983677, 0.00302801249035602,
0.00300946121851254, 0.00302272755554915), `EUR/GBP_RV t+1,t+5` = c(0.00425938711995146,
0.00442030721926592, 0.00471470868108043, 0.00487869292442023,
0.00476849421943949, 0.0046067439660438), `EUR/GBP_RGV t+1,t+5` = c(0.00287718093809447,
0.00311308998902836, 0.00344398536439729, 0.00376911066284235,
0.00377425759242542, 0.00353909902900148), `EUR/GBP_RBV t+1,t+5` = c(0.00313771439501486,
0.00310626895475871, 0.0031789431316576, 0.00305962424370556,
0.00288671182187571, 0.00291630955829613), `EUR/GBP_RV t+1` = c(0.00401994700051122,
0.00407732180013827, 0.00466624428620966, 0.00458235106134663,
0.00395107145155152, 0.00554932910921084), `EUR/GBP_RGV t+1` = c(0.00280067842079775,
0.00275522601341373, 0.00296142025653418, 0.00320716195737542,
0.00266141804235125, 0.00440970289025837), `EUR/GBP_RBV t+1` = c(0.00288377777753365,
0.00300554199386584, 0.00360608177982326, 0.00327292734850446,
0.0029202430753471, 0.00336891287836027), `EUR/GBP_RV` = c(0.00446710941914797,
0.00401994700051122, 0.00407732180013827, 0.00466624428620966,
0.00458235106134663, 0.00482454749708351), `EUR/GBP_RV_5` = c(0.00499598016427624,
0.00470474196716823, 0.00456452150727461, 0.00453292965488229,
0.00436259471347075, 0.00442030721926592), `EUR/GBP_RV_22` = c(0.00515060219897263,
0.00509920878086075, 0.00502079002092667, 0.00501107755050095,
0.00499963428727425, 0.00495435807685843), `EUR/GBP_RBV` = c(0.00324667045338159,
0.00288377777753365, 0.00300554199386584, 0.00360608177982326,
0.00327292734850446, 0.00272655057625291), `EUR/GBP_RBV_5` = c(0.0034985439252634,
0.00318731350301598, 0.00319529774619179, 0.0032799330165155,
0.00320299987062176, 0.00310626895475871), `EUR/GBP_RBV_22` = c(0.0036581887941976,
0.00362298829344015, 0.00355498498935768, 0.0035465419934449,
0.00355752455210586, 0.00351669973034298), `EUR/GBP_RGV` = c(0.00306825643155514,
0.00280067842079775, 0.00275522601341373, 0.00296142025653418,
0.00320716195737542, 0.00398022367546721), `EUR/GBP_RGV_5` = c(0.00353290218424469,
0.00345194162523714, 0.00325362896209417, 0.00312087362386985,
0.00295854861593525, 0.00311308998902836), `EUR/GBP_RGV_22` = c(0.00359974659692405,
0.00356342531619103, 0.00352224165959556, 0.00351722666683608,
0.00349184335907274, 0.00346394410318992), `EUR/GBP_TotalCount` = structure(c(-0.179518680545716,
-0.0757259172924681, 0.333514120677483, 0.759064450015801, -0.419724789788948,
-0.360414639358521), .Dim = c(6L, 1L)), `EUR/GBP_BloombergCount` = structure(c(-0.701694550941621,
-0.669811381311996, -0.574161872423118, -0.644304845608295, -0.784590791978649,
-0.631551577756444), .Dim = c(6L, 1L)), `EUR/GBP_SocialMediaCount` = structure(c(-1.68861759789696,
-1.66829994393287, -1.5910928588693, -1.59515638966212, -1.6967446594826,
-1.63172816679749), .Dim = c(6L, 1L)), `EUR/GBP_NewsCount` = structure(c(0.76560533722738,
0.879161625683434, 1.33717198912285, 1.90306082659552, 0.487392430510049,
0.487392430510049), .Dim = c(6L, 1L))), na.action = structure(c(`6` = 6L,
`38` = 38L, `74` = 74L, `101` = 101L, `140` = 140L, `165` = 165L,
`189` = 189L, `197` = 197L, `236` = 236L, `256` = 256L, `323` = 323L,
`351` = 351L, `393` = 393L, `423` = 423L, `442` = 442L, `455` = 455L,
`490` = 490L, `510` = 510L, `551` = 551L, `576` = 576L, `605` = 605L,
`646` = 646L, `676` = 676L, `696` = 696L, `708` = 708L, `742` = 742L,
`762` = 762L, `793` = 793L, `829` = 829L, `858` = 858L, `904` = 904L,
`929` = 929L, `950` = 950L, `961` = 961L, `996` = 996L, `1016` = 1016L,
`1089` = 1089L, `1114` = 1114L, `1159` = 1159L, `1184` = 1184L,
`1207` = 1207L, `1216` = 1216L, `1238` = 1238L, `1243` = 1243L,
`1253` = 1253L, `1278` = 1278L, `1315` = 1315L, `1346` = 1346L,
`1372` = 1372L, `1416` = 1416L, `1441` = 1441L, `1473` = 1473L,
`1532` = 1532L, `1599` = 1599L, `1626` = 1626L, `1669` = 1669L,
`1694` = 1694L, `1718` = 1718L, `1726` = 1726L, `1766` = 1766L,
`1786` = 1786L, `1827` = 1827L, `1853` = 1853L, `1881` = 1881L,
`1922` = 1922L, `1952` = 1952L, `1971` = 1971L, `1984` = 1984L,
`2019` = 2019L, `2039` = 2039L, `2075` = 2075L, `2106` = 2106L,
`2135` = 2135L, `2181` = 2181L, `2206` = 2206L, `2227` = 2227L,
`2238` = 2238L, `2273` = 2273L, `2293` = 2293L, `2325` = 2325L,
`2366` = 2366L, `2391` = 2391L, `2436` = 2436L, `2461` = 2461L,
`2483` = 2483L, `2493` = 2493L), class = "omit"), row.names = c(1L,
2L, 3L, 4L, 5L, 7L), class = "data.frame")
I have built 9 regression models per forecast horizon (t+1, t+5 and t+22) and I am using the predict function to make my forecasts. I have coded this in an R loop, where I also try to assign each forecast to a matrix. My code is the following:
EUR/GBP_RBV t+1`~data.estimateI am trying to calculate realized volatility forecasts using a rolling window forecast. My aim is to use the first 500 observations to forecast the 501st observations, then shift the window forward one step using observations 2 to 501 to predict the 502nd observation. I want this to repeat until I have a complete pseudo out-of-sample forecast.
My df contains 2411 observations of 23 variables, here is small example:
Date
EUR/GBP_RV t+1
EUR/GBP_RV
EUR/GBP_RV_5
EUR/GBP_RV_22
2012-02-13
0.004019947
0.004467109
0.004995980
0.005150602
2012-02-14
0.004077322
0.004019947
0.004704742
0.005099209
2012-02-15
0.004666244
0.004077322
0.004564522
0.005020790
2012-02-16
0.004582351
0.004666244
0.004532930
0.005011078
2012-02-17
0.003951071
0.004582351
0.004362595
0.004999634
2012-02-21
0.005549329
0.004824547
0.004467109
0.004954358
The head of the df can be reproduced with
structure(list(Date = structure(c(15383, 15384, 15385, 15386,
15387, 15391), class = "Date"), `EUR/GBP_RV t+1,t+22` = c(0.00437808494654599,
0.00439764887779732, 0.00441997330738947, 0.00437799055732722,
0.00435021150904479, 0.00434881306458859), `EUR/GBP_RGV t+1,t+22` = c(0.00310674728131117,
0.00311502965608506, 0.00313756204195853, 0.00312923997431178,
0.00310846773074243, 0.00309755540903969), `EUR/GBP_RBV t+1,t+22` = c(0.00304961980133602,
0.00306866297401415, 0.00307794319983677, 0.00302801249035602,
0.00300946121851254, 0.00302272755554915), `EUR/GBP_RV t+1,t+5` = c(0.00425938711995146,
0.00442030721926592, 0.00471470868108043, 0.00487869292442023,
0.00476849421943949, 0.0046067439660438), `EUR/GBP_RGV t+1,t+5` = c(0.00287718093809447,
0.00311308998902836, 0.00344398536439729, 0.00376911066284235,
0.00377425759242542, 0.00353909902900148), `EUR/GBP_RBV t+1,t+5` = c(0.00313771439501486,
0.00310626895475871, 0.0031789431316576, 0.00305962424370556,
0.00288671182187571, 0.00291630955829613), `EUR/GBP_RV t+1` = c(0.00401994700051122,
0.00407732180013827, 0.00466624428620966, 0.00458235106134663,
0.00395107145155152, 0.00554932910921084), `EUR/GBP_RGV t+1` = c(0.00280067842079775,
0.00275522601341373, 0.00296142025653418, 0.00320716195737542,
0.00266141804235125, 0.00440970289025837), `EUR/GBP_RBV t+1` = c(0.00288377777753365,
0.00300554199386584, 0.00360608177982326, 0.00327292734850446,
0.0029202430753471, 0.00336891287836027), `EUR/GBP_RV` = c(0.00446710941914797,
0.00401994700051122, 0.00407732180013827, 0.00466624428620966,
0.00458235106134663, 0.00482454749708351), `EUR/GBP_RV_5` = c(0.00499598016427624,
0.00470474196716823, 0.00456452150727461, 0.00453292965488229,
0.00436259471347075, 0.00442030721926592), `EUR/GBP_RV_22` = c(0.00515060219897263,
0.00509920878086075, 0.00502079002092667, 0.00501107755050095,
0.00499963428727425, 0.00495435807685843), `EUR/GBP_RBV` = c(0.00324667045338159,
0.00288377777753365, 0.00300554199386584, 0.00360608177982326,
0.00327292734850446, 0.00272655057625291), `EUR/GBP_RBV_5` = c(0.0034985439252634,
0.00318731350301598, 0.00319529774619179, 0.0032799330165155,
0.00320299987062176, 0.00310626895475871), `EUR/GBP_RBV_22` = c(0.0036581887941976,
0.00362298829344015, 0.00355498498935768, 0.0035465419934449,
0.00355752455210586, 0.00351669973034298), `EUR/GBP_RGV` = c(0.00306825643155514,
0.00280067842079775, 0.00275522601341373, 0.00296142025653418,
0.00320716195737542, 0.00398022367546721), `EUR/GBP_RGV_5` = c(0.00353290218424469,
0.00345194162523714, 0.00325362896209417, 0.00312087362386985,
0.00295854861593525, 0.00311308998902836), `EUR/GBP_RGV_22` = c(0.00359974659692405,
0.00356342531619103, 0.00352224165959556, 0.00351722666683608,
0.00349184335907274, 0.00346394410318992), `EUR/GBP_TotalCount` = structure(c(-0.179518680545716,
-0.0757259172924681, 0.333514120677483, 0.759064450015801, -0.419724789788948,
-0.360414639358521), .Dim = c(6L, 1L)), `EUR/GBP_BloombergCount` = structure(c(-0.701694550941621,
-0.669811381311996, -0.574161872423118, -0.644304845608295, -0.784590791978649,
-0.631551577756444), .Dim = c(6L, 1L)), `EUR/GBP_SocialMediaCount` = structure(c(-1.68861759789696,
-1.66829994393287, -1.5910928588693, -1.59515638966212, -1.6967446594826,
-1.63172816679749), .Dim = c(6L, 1L)), `EUR/GBP_NewsCount` = structure(c(0.76560533722738,
0.879161625683434, 1.33717198912285, 1.90306082659552, 0.487392430510049,
0.487392430510049), .Dim = c(6L, 1L))), na.action = structure(c(`6` = 6L,
`38` = 38L, `74` = 74L, `101` = 101L, `140` = 140L, `165` = 165L,
`189` = 189L, `197` = 197L, `236` = 236L, `256` = 256L, `323` = 323L,
`351` = 351L, `393` = 393L, `423` = 423L, `442` = 442L, `455` = 455L,
`490` = 490L, `510` = 510L, `551` = 551L, `576` = 576L, `605` = 605L,
`646` = 646L, `676` = 676L, `696` = 696L, `708` = 708L, `742` = 742L,
`762` = 762L, `793` = 793L, `829` = 829L, `858` = 858L, `904` = 904L,
`929` = 929L, `950` = 950L, `961` = 961L, `996` = 996L, `1016` = 1016L,
`1089` = 1089L, `1114` = 1114L, `1159` = 1159L, `1184` = 1184L,
`1207` = 1207L, `1216` = 1216L, `1238` = 1238L, `1243` = 1243L,
`1253` = 1253L, `1278` = 1278L, `1315` = 1315L, `1346` = 1346L,
`1372` = 1372L, `1416` = 1416L, `1441` = 1441L, `1473` = 1473L,
`1532` = 1532L, `1599` = 1599L, `1626` = 1626L, `1669` = 1669L,
`1694` = 1694L, `1718` = 1718L, `1726` = 1726L, `1766` = 1766L,
`1786` = 1786L, `1827` = 1827L, `1853` = 1853L, `1881` = 1881L,
`1922` = 1922L, `1952` = 1952L, `1971` = 1971L, `1984` = 1984L,
`2019` = 2019L, `2039` = 2039L, `2075` = 2075L, `2106` = 2106L,
`2135` = 2135L, `2181` = 2181L, `2206` = 2206L, `2227` = 2227L,
`2238` = 2238L, `2273` = 2273L, `2293` = 2293L, `2325` = 2325L,
`2366` = 2366L, `2391` = 2391L, `2436` = 2436L, `2461` = 2461L,
`2483` = 2483L, `2493` = 2493L), class = "omit"), row.names = c(1L,
2L, 3L, 4L, 5L, 7L), class = "data.frame")
I have built 9 regression models per forecast horizon (t+1, t+5 and t+22) and I am using the predict function to make my forecasts. I have coded this in an R loop, where I also try to assign each forecast to a matrix. My code is the following:
EUR/GBP_RBV`+data.estimateI am trying to calculate realized volatility forecasts using a rolling window forecast. My aim is to use the first 500 observations to forecast the 501st observations, then shift the window forward one step using observations 2 to 501 to predict the 502nd observation. I want this to repeat until I have a complete pseudo out-of-sample forecast.
My df contains 2411 observations of 23 variables, here is small example:
Date
EUR/GBP_RV t+1
EUR/GBP_RV
EUR/GBP_RV_5
EUR/GBP_RV_22
2012-02-13
0.004019947
0.004467109
0.004995980
0.005150602
2012-02-14
0.004077322
0.004019947
0.004704742
0.005099209
2012-02-15
0.004666244
0.004077322
0.004564522
0.005020790
2012-02-16
0.004582351
0.004666244
0.004532930
0.005011078
2012-02-17
0.003951071
0.004582351
0.004362595
0.004999634
2012-02-21
0.005549329
0.004824547
0.004467109
0.004954358
The head of the df can be reproduced with
structure(list(Date = structure(c(15383, 15384, 15385, 15386,
15387, 15391), class = "Date"), `EUR/GBP_RV t+1,t+22` = c(0.00437808494654599,
0.00439764887779732, 0.00441997330738947, 0.00437799055732722,
0.00435021150904479, 0.00434881306458859), `EUR/GBP_RGV t+1,t+22` = c(0.00310674728131117,
0.00311502965608506, 0.00313756204195853, 0.00312923997431178,
0.00310846773074243, 0.00309755540903969), `EUR/GBP_RBV t+1,t+22` = c(0.00304961980133602,
0.00306866297401415, 0.00307794319983677, 0.00302801249035602,
0.00300946121851254, 0.00302272755554915), `EUR/GBP_RV t+1,t+5` = c(0.00425938711995146,
0.00442030721926592, 0.00471470868108043, 0.00487869292442023,
0.00476849421943949, 0.0046067439660438), `EUR/GBP_RGV t+1,t+5` = c(0.00287718093809447,
0.00311308998902836, 0.00344398536439729, 0.00376911066284235,
0.00377425759242542, 0.00353909902900148), `EUR/GBP_RBV t+1,t+5` = c(0.00313771439501486,
0.00310626895475871, 0.0031789431316576, 0.00305962424370556,
0.00288671182187571, 0.00291630955829613), `EUR/GBP_RV t+1` = c(0.00401994700051122,
0.00407732180013827, 0.00466624428620966, 0.00458235106134663,
0.00395107145155152, 0.00554932910921084), `EUR/GBP_RGV t+1` = c(0.00280067842079775,
0.00275522601341373, 0.00296142025653418, 0.00320716195737542,
0.00266141804235125, 0.00440970289025837), `EUR/GBP_RBV t+1` = c(0.00288377777753365,
0.00300554199386584, 0.00360608177982326, 0.00327292734850446,
0.0029202430753471, 0.00336891287836027), `EUR/GBP_RV` = c(0.00446710941914797,
0.00401994700051122, 0.00407732180013827, 0.00466624428620966,
0.00458235106134663, 0.00482454749708351), `EUR/GBP_RV_5` = c(0.00499598016427624,
0.00470474196716823, 0.00456452150727461, 0.00453292965488229,
0.00436259471347075, 0.00442030721926592), `EUR/GBP_RV_22` = c(0.00515060219897263,
0.00509920878086075, 0.00502079002092667, 0.00501107755050095,
0.00499963428727425, 0.00495435807685843), `EUR/GBP_RBV` = c(0.00324667045338159,
0.00288377777753365, 0.00300554199386584, 0.00360608177982326,
0.00327292734850446, 0.00272655057625291), `EUR/GBP_RBV_5` = c(0.0034985439252634,
0.00318731350301598, 0.00319529774619179, 0.0032799330165155,
0.00320299987062176, 0.00310626895475871), `EUR/GBP_RBV_22` = c(0.0036581887941976,
0.00362298829344015, 0.00355498498935768, 0.0035465419934449,
0.00355752455210586, 0.00351669973034298), `EUR/GBP_RGV` = c(0.00306825643155514,
0.00280067842079775, 0.00275522601341373, 0.00296142025653418,
0.00320716195737542, 0.00398022367546721), `EUR/GBP_RGV_5` = c(0.00353290218424469,
0.00345194162523714, 0.00325362896209417, 0.00312087362386985,
0.00295854861593525, 0.00311308998902836), `EUR/GBP_RGV_22` = c(0.00359974659692405,
0.00356342531619103, 0.00352224165959556, 0.00351722666683608,
0.00349184335907274, 0.00346394410318992), `EUR/GBP_TotalCount` = structure(c(-0.179518680545716,
-0.0757259172924681, 0.333514120677483, 0.759064450015801, -0.419724789788948,
-0.360414639358521), .Dim = c(6L, 1L)), `EUR/GBP_BloombergCount` = structure(c(-0.701694550941621,
-0.669811381311996, -0.574161872423118, -0.644304845608295, -0.784590791978649,
-0.631551577756444), .Dim = c(6L, 1L)), `EUR/GBP_SocialMediaCount` = structure(c(-1.68861759789696,
-1.66829994393287, -1.5910928588693, -1.59515638966212, -1.6967446594826,
-1.63172816679749), .Dim = c(6L, 1L)), `EUR/GBP_NewsCount` = structure(c(0.76560533722738,
0.879161625683434, 1.33717198912285, 1.90306082659552, 0.487392430510049,
0.487392430510049), .Dim = c(6L, 1L))), na.action = structure(c(`6` = 6L,
`38` = 38L, `74` = 74L, `101` = 101L, `140` = 140L, `165` = 165L,
`189` = 189L, `197` = 197L, `236` = 236L, `256` = 256L, `323` = 323L,
`351` = 351L, `393` = 393L, `423` = 423L, `442` = 442L, `455` = 455L,
`490` = 490L, `510` = 510L, `551` = 551L, `576` = 576L, `605` = 605L,
`646` = 646L, `676` = 676L, `696` = 696L, `708` = 708L, `742` = 742L,
`762` = 762L, `793` = 793L, `829` = 829L, `858` = 858L, `904` = 904L,
`929` = 929L, `950` = 950L, `961` = 961L, `996` = 996L, `1016` = 1016L,
`1089` = 1089L, `1114` = 1114L, `1159` = 1159L, `1184` = 1184L,
`1207` = 1207L, `1216` = 1216L, `1238` = 1238L, `1243` = 1243L,
`1253` = 1253L, `1278` = 1278L, `1315` = 1315L, `1346` = 1346L,
`1372` = 1372L, `1416` = 1416L, `1441` = 1441L, `1473` = 1473L,
`1532` = 1532L, `1599` = 1599L, `1626` = 1626L, `1669` = 1669L,
`1694` = 1694L, `1718` = 1718L, `1726` = 1726L, `1766` = 1766L,
`1786` = 1786L, `1827` = 1827L, `1853` = 1853L, `1881` = 1881L,
`1922` = 1922L, `1952` = 1952L, `1971` = 1971L, `1984` = 1984L,
`2019` = 2019L, `2039` = 2039L, `2075` = 2075L, `2106` = 2106L,
`2135` = 2135L, `2181` = 2181L, `2206` = 2206L, `2227` = 2227L,
`2238` = 2238L, `2273` = 2273L, `2293` = 2293L, `2325` = 2325L,
`2366` = 2366L, `2391` = 2391L, `2436` = 2436L, `2461` = 2461L,
`2483` = 2483L, `2493` = 2493L), class = "omit"), row.names = c(1L,
2L, 3L, 4L, 5L, 7L), class = "data.frame")
I have built 9 regression models per forecast horizon (t+1, t+5 and t+22) and I am using the predict function to make my forecasts. I have coded this in an R loop, where I also try to assign each forecast to a matrix. My code is the following:
EUR/GBP_RBV_5`+data.estimateI am trying to calculate realized volatility forecasts using a rolling window forecast. My aim is to use the first 500 observations to forecast the 501st observations, then shift the window forward one step using observations 2 to 501 to predict the 502nd observation. I want this to repeat until I have a complete pseudo out-of-sample forecast.
My df contains 2411 observations of 23 variables, here is small example:
Date
EUR/GBP_RV t+1
EUR/GBP_RV
EUR/GBP_RV_5
EUR/GBP_RV_22
2012-02-13
0.004019947
0.004467109
0.004995980
0.005150602
2012-02-14
0.004077322
0.004019947
0.004704742
0.005099209
2012-02-15
0.004666244
0.004077322
0.004564522
0.005020790
2012-02-16
0.004582351
0.004666244
0.004532930
0.005011078
2012-02-17
0.003951071
0.004582351
0.004362595
0.004999634
2012-02-21
0.005549329
0.004824547
0.004467109
0.004954358
The head of the df can be reproduced with
structure(list(Date = structure(c(15383, 15384, 15385, 15386,
15387, 15391), class = "Date"), `EUR/GBP_RV t+1,t+22` = c(0.00437808494654599,
0.00439764887779732, 0.00441997330738947, 0.00437799055732722,
0.00435021150904479, 0.00434881306458859), `EUR/GBP_RGV t+1,t+22` = c(0.00310674728131117,
0.00311502965608506, 0.00313756204195853, 0.00312923997431178,
0.00310846773074243, 0.00309755540903969), `EUR/GBP_RBV t+1,t+22` = c(0.00304961980133602,
0.00306866297401415, 0.00307794319983677, 0.00302801249035602,
0.00300946121851254, 0.00302272755554915), `EUR/GBP_RV t+1,t+5` = c(0.00425938711995146,
0.00442030721926592, 0.00471470868108043, 0.00487869292442023,
0.00476849421943949, 0.0046067439660438), `EUR/GBP_RGV t+1,t+5` = c(0.00287718093809447,
0.00311308998902836, 0.00344398536439729, 0.00376911066284235,
0.00377425759242542, 0.00353909902900148), `EUR/GBP_RBV t+1,t+5` = c(0.00313771439501486,
0.00310626895475871, 0.0031789431316576, 0.00305962424370556,
0.00288671182187571, 0.00291630955829613), `EUR/GBP_RV t+1` = c(0.00401994700051122,
0.00407732180013827, 0.00466624428620966, 0.00458235106134663,
0.00395107145155152, 0.00554932910921084), `EUR/GBP_RGV t+1` = c(0.00280067842079775,
0.00275522601341373, 0.00296142025653418, 0.00320716195737542,
0.00266141804235125, 0.00440970289025837), `EUR/GBP_RBV t+1` = c(0.00288377777753365,
0.00300554199386584, 0.00360608177982326, 0.00327292734850446,
0.0029202430753471, 0.00336891287836027), `EUR/GBP_RV` = c(0.00446710941914797,
0.00401994700051122, 0.00407732180013827, 0.00466624428620966,
0.00458235106134663, 0.00482454749708351), `EUR/GBP_RV_5` = c(0.00499598016427624,
0.00470474196716823, 0.00456452150727461, 0.00453292965488229,
0.00436259471347075, 0.00442030721926592), `EUR/GBP_RV_22` = c(0.00515060219897263,
0.00509920878086075, 0.00502079002092667, 0.00501107755050095,
0.00499963428727425, 0.00495435807685843), `EUR/GBP_RBV` = c(0.00324667045338159,
0.00288377777753365, 0.00300554199386584, 0.00360608177982326,
0.00327292734850446, 0.00272655057625291), `EUR/GBP_RBV_5` = c(0.0034985439252634,
0.00318731350301598, 0.00319529774619179, 0.0032799330165155,
0.00320299987062176, 0.00310626895475871), `EUR/GBP_RBV_22` = c(0.0036581887941976,
0.00362298829344015, 0.00355498498935768, 0.0035465419934449,
0.00355752455210586, 0.00351669973034298), `EUR/GBP_RGV` = c(0.00306825643155514,
0.00280067842079775, 0.00275522601341373, 0.00296142025653418,
0.00320716195737542, 0.00398022367546721), `EUR/GBP_RGV_5` = c(0.00353290218424469,
0.00345194162523714, 0.00325362896209417, 0.00312087362386985,
0.00295854861593525, 0.00311308998902836), `EUR/GBP_RGV_22` = c(0.00359974659692405,
0.00356342531619103, 0.00352224165959556, 0.00351722666683608,
0.00349184335907274, 0.00346394410318992), `EUR/GBP_TotalCount` = structure(c(-0.179518680545716,
-0.0757259172924681, 0.333514120677483, 0.759064450015801, -0.419724789788948,
-0.360414639358521), .Dim = c(6L, 1L)), `EUR/GBP_BloombergCount` = structure(c(-0.701694550941621,
-0.669811381311996, -0.574161872423118, -0.644304845608295, -0.784590791978649,
-0.631551577756444), .Dim = c(6L, 1L)), `EUR/GBP_SocialMediaCount` = structure(c(-1.68861759789696,
-1.66829994393287, -1.5910928588693, -1.59515638966212, -1.6967446594826,
-1.63172816679749), .Dim = c(6L, 1L)), `EUR/GBP_NewsCount` = structure(c(0.76560533722738,
0.879161625683434, 1.33717198912285, 1.90306082659552, 0.487392430510049,
0.487392430510049), .Dim = c(6L, 1L))), na.action = structure(c(`6` = 6L,
`38` = 38L, `74` = 74L, `101` = 101L, `140` = 140L, `165` = 165L,
`189` = 189L, `197` = 197L, `236` = 236L, `256` = 256L, `323` = 323L,
`351` = 351L, `393` = 393L, `423` = 423L, `442` = 442L, `455` = 455L,
`490` = 490L, `510` = 510L, `551` = 551L, `576` = 576L, `605` = 605L,
`646` = 646L, `676` = 676L, `696` = 696L, `708` = 708L, `742` = 742L,
`762` = 762L, `793` = 793L, `829` = 829L, `858` = 858L, `904` = 904L,
`929` = 929L, `950` = 950L, `961` = 961L, `996` = 996L, `1016` = 1016L,
`1089` = 1089L, `1114` = 1114L, `1159` = 1159L, `1184` = 1184L,
`1207` = 1207L, `1216` = 1216L, `1238` = 1238L, `1243` = 1243L,
`1253` = 1253L, `1278` = 1278L, `1315` = 1315L, `1346` = 1346L,
`1372` = 1372L, `1416` = 1416L, `1441` = 1441L, `1473` = 1473L,
`1532` = 1532L, `1599` = 1599L, `1626` = 1626L, `1669` = 1669L,
`1694` = 1694L, `1718` = 1718L, `1726` = 1726L, `1766` = 1766L,
`1786` = 1786L, `1827` = 1827L, `1853` = 1853L, `1881` = 1881L,
`1922` = 1922L, `1952` = 1952L, `1971` = 1971L, `1984` = 1984L,
`2019` = 2019L, `2039` = 2039L, `2075` = 2075L, `2106` = 2106L,
`2135` = 2135L, `2181` = 2181L, `2206` = 2206L, `2227` = 2227L,
`2238` = 2238L, `2273` = 2273L, `2293` = 2293L, `2325` = 2325L,
`2366` = 2366L, `2391` = 2391L, `2436` = 2436L, `2461` = 2461L,
`2483` = 2483L, `2493` = 2493L), class = "omit"), row.names = c(1L,
2L, 3L, 4L, 5L, 7L), class = "data.frame")
I have built 9 regression models per forecast horizon (t+1, t+5 and t+22) and I am using the predict function to make my forecasts. I have coded this in an R loop, where I also try to assign each forecast to a matrix. My code is the following:
EUR/GBP_RBV_22`)
EURGBP_HAR_RVB_NT_train <- lm(data.estimateI am trying to calculate realized volatility forecasts using a rolling window forecast. My aim is to use the first 500 observations to forecast the 501st observations, then shift the window forward one step using observations 2 to 501 to predict the 502nd observation. I want this to repeat until I have a complete pseudo out-of-sample forecast.
My df contains 2411 observations of 23 variables, here is small example:
Date
EUR/GBP_RV t+1
EUR/GBP_RV
EUR/GBP_RV_5
EUR/GBP_RV_22
2012-02-13
0.004019947
0.004467109
0.004995980
0.005150602
2012-02-14
0.004077322
0.004019947
0.004704742
0.005099209
2012-02-15
0.004666244
0.004077322
0.004564522
0.005020790
2012-02-16
0.004582351
0.004666244
0.004532930
0.005011078
2012-02-17
0.003951071
0.004582351
0.004362595
0.004999634
2012-02-21
0.005549329
0.004824547
0.004467109
0.004954358
The head of the df can be reproduced with
structure(list(Date = structure(c(15383, 15384, 15385, 15386,
15387, 15391), class = "Date"), `EUR/GBP_RV t+1,t+22` = c(0.00437808494654599,
0.00439764887779732, 0.00441997330738947, 0.00437799055732722,
0.00435021150904479, 0.00434881306458859), `EUR/GBP_RGV t+1,t+22` = c(0.00310674728131117,
0.00311502965608506, 0.00313756204195853, 0.00312923997431178,
0.00310846773074243, 0.00309755540903969), `EUR/GBP_RBV t+1,t+22` = c(0.00304961980133602,
0.00306866297401415, 0.00307794319983677, 0.00302801249035602,
0.00300946121851254, 0.00302272755554915), `EUR/GBP_RV t+1,t+5` = c(0.00425938711995146,
0.00442030721926592, 0.00471470868108043, 0.00487869292442023,
0.00476849421943949, 0.0046067439660438), `EUR/GBP_RGV t+1,t+5` = c(0.00287718093809447,
0.00311308998902836, 0.00344398536439729, 0.00376911066284235,
0.00377425759242542, 0.00353909902900148), `EUR/GBP_RBV t+1,t+5` = c(0.00313771439501486,
0.00310626895475871, 0.0031789431316576, 0.00305962424370556,
0.00288671182187571, 0.00291630955829613), `EUR/GBP_RV t+1` = c(0.00401994700051122,
0.00407732180013827, 0.00466624428620966, 0.00458235106134663,
0.00395107145155152, 0.00554932910921084), `EUR/GBP_RGV t+1` = c(0.00280067842079775,
0.00275522601341373, 0.00296142025653418, 0.00320716195737542,
0.00266141804235125, 0.00440970289025837), `EUR/GBP_RBV t+1` = c(0.00288377777753365,
0.00300554199386584, 0.00360608177982326, 0.00327292734850446,
0.0029202430753471, 0.00336891287836027), `EUR/GBP_RV` = c(0.00446710941914797,
0.00401994700051122, 0.00407732180013827, 0.00466624428620966,
0.00458235106134663, 0.00482454749708351), `EUR/GBP_RV_5` = c(0.00499598016427624,
0.00470474196716823, 0.00456452150727461, 0.00453292965488229,
0.00436259471347075, 0.00442030721926592), `EUR/GBP_RV_22` = c(0.00515060219897263,
0.00509920878086075, 0.00502079002092667, 0.00501107755050095,
0.00499963428727425, 0.00495435807685843), `EUR/GBP_RBV` = c(0.00324667045338159,
0.00288377777753365, 0.00300554199386584, 0.00360608177982326,
0.00327292734850446, 0.00272655057625291), `EUR/GBP_RBV_5` = c(0.0034985439252634,
0.00318731350301598, 0.00319529774619179, 0.0032799330165155,
0.00320299987062176, 0.00310626895475871), `EUR/GBP_RBV_22` = c(0.0036581887941976,
0.00362298829344015, 0.00355498498935768, 0.0035465419934449,
0.00355752455210586, 0.00351669973034298), `EUR/GBP_RGV` = c(0.00306825643155514,
0.00280067842079775, 0.00275522601341373, 0.00296142025653418,
0.00320716195737542, 0.00398022367546721), `EUR/GBP_RGV_5` = c(0.00353290218424469,
0.00345194162523714, 0.00325362896209417, 0.00312087362386985,
0.00295854861593525, 0.00311308998902836), `EUR/GBP_RGV_22` = c(0.00359974659692405,
0.00356342531619103, 0.00352224165959556, 0.00351722666683608,
0.00349184335907274, 0.00346394410318992), `EUR/GBP_TotalCount` = structure(c(-0.179518680545716,
-0.0757259172924681, 0.333514120677483, 0.759064450015801, -0.419724789788948,
-0.360414639358521), .Dim = c(6L, 1L)), `EUR/GBP_BloombergCount` = structure(c(-0.701694550941621,
-0.669811381311996, -0.574161872423118, -0.644304845608295, -0.784590791978649,
-0.631551577756444), .Dim = c(6L, 1L)), `EUR/GBP_SocialMediaCount` = structure(c(-1.68861759789696,
-1.66829994393287, -1.5910928588693, -1.59515638966212, -1.6967446594826,
-1.63172816679749), .Dim = c(6L, 1L)), `EUR/GBP_NewsCount` = structure(c(0.76560533722738,
0.879161625683434, 1.33717198912285, 1.90306082659552, 0.487392430510049,
0.487392430510049), .Dim = c(6L, 1L))), na.action = structure(c(`6` = 6L,
`38` = 38L, `74` = 74L, `101` = 101L, `140` = 140L, `165` = 165L,
`189` = 189L, `197` = 197L, `236` = 236L, `256` = 256L, `323` = 323L,
`351` = 351L, `393` = 393L, `423` = 423L, `442` = 442L, `455` = 455L,
`490` = 490L, `510` = 510L, `551` = 551L, `576` = 576L, `605` = 605L,
`646` = 646L, `676` = 676L, `696` = 696L, `708` = 708L, `742` = 742L,
`762` = 762L, `793` = 793L, `829` = 829L, `858` = 858L, `904` = 904L,
`929` = 929L, `950` = 950L, `961` = 961L, `996` = 996L, `1016` = 1016L,
`1089` = 1089L, `1114` = 1114L, `1159` = 1159L, `1184` = 1184L,
`1207` = 1207L, `1216` = 1216L, `1238` = 1238L, `1243` = 1243L,
`1253` = 1253L, `1278` = 1278L, `1315` = 1315L, `1346` = 1346L,
`1372` = 1372L, `1416` = 1416L, `1441` = 1441L, `1473` = 1473L,
`1532` = 1532L, `1599` = 1599L, `1626` = 1626L, `1669` = 1669L,
`1694` = 1694L, `1718` = 1718L, `1726` = 1726L, `1766` = 1766L,
`1786` = 1786L, `1827` = 1827L, `1853` = 1853L, `1881` = 1881L,
`1922` = 1922L, `1952` = 1952L, `1971` = 1971L, `1984` = 1984L,
`2019` = 2019L, `2039` = 2039L, `2075` = 2075L, `2106` = 2106L,
`2135` = 2135L, `2181` = 2181L, `2206` = 2206L, `2227` = 2227L,
`2238` = 2238L, `2273` = 2273L, `2293` = 2293L, `2325` = 2325L,
`2366` = 2366L, `2391` = 2391L, `2436` = 2436L, `2461` = 2461L,
`2483` = 2483L, `2493` = 2493L), class = "omit"), row.names = c(1L,
2L, 3L, 4L, 5L, 7L), class = "data.frame")
I have built 9 regression models per forecast horizon (t+1, t+5 and t+22) and I am using the predict function to make my forecasts. I have coded this in an R loop, where I also try to assign each forecast to a matrix. My code is the following:
EUR/GBP_RBV t+1`~data.estimateI am trying to calculate realized volatility forecasts using a rolling window forecast. My aim is to use the first 500 observations to forecast the 501st observations, then shift the window forward one step using observations 2 to 501 to predict the 502nd observation. I want this to repeat until I have a complete pseudo out-of-sample forecast.
My df contains 2411 observations of 23 variables, here is small example:
Date
EUR/GBP_RV t+1
EUR/GBP_RV
EUR/GBP_RV_5
EUR/GBP_RV_22
2012-02-13
0.004019947
0.004467109
0.004995980
0.005150602
2012-02-14
0.004077322
0.004019947
0.004704742
0.005099209
2012-02-15
0.004666244
0.004077322
0.004564522
0.005020790
2012-02-16
0.004582351
0.004666244
0.004532930
0.005011078
2012-02-17
0.003951071
0.004582351
0.004362595
0.004999634
2012-02-21
0.005549329
0.004824547
0.004467109
0.004954358
The head of the df can be reproduced with
structure(list(Date = structure(c(15383, 15384, 15385, 15386,
15387, 15391), class = "Date"), `EUR/GBP_RV t+1,t+22` = c(0.00437808494654599,
0.00439764887779732, 0.00441997330738947, 0.00437799055732722,
0.00435021150904479, 0.00434881306458859), `EUR/GBP_RGV t+1,t+22` = c(0.00310674728131117,
0.00311502965608506, 0.00313756204195853, 0.00312923997431178,
0.00310846773074243, 0.00309755540903969), `EUR/GBP_RBV t+1,t+22` = c(0.00304961980133602,
0.00306866297401415, 0.00307794319983677, 0.00302801249035602,
0.00300946121851254, 0.00302272755554915), `EUR/GBP_RV t+1,t+5` = c(0.00425938711995146,
0.00442030721926592, 0.00471470868108043, 0.00487869292442023,
0.00476849421943949, 0.0046067439660438), `EUR/GBP_RGV t+1,t+5` = c(0.00287718093809447,
0.00311308998902836, 0.00344398536439729, 0.00376911066284235,
0.00377425759242542, 0.00353909902900148), `EUR/GBP_RBV t+1,t+5` = c(0.00313771439501486,
0.00310626895475871, 0.0031789431316576, 0.00305962424370556,
0.00288671182187571, 0.00291630955829613), `EUR/GBP_RV t+1` = c(0.00401994700051122,
0.00407732180013827, 0.00466624428620966, 0.00458235106134663,
0.00395107145155152, 0.00554932910921084), `EUR/GBP_RGV t+1` = c(0.00280067842079775,
0.00275522601341373, 0.00296142025653418, 0.00320716195737542,
0.00266141804235125, 0.00440970289025837), `EUR/GBP_RBV t+1` = c(0.00288377777753365,
0.00300554199386584, 0.00360608177982326, 0.00327292734850446,
0.0029202430753471, 0.00336891287836027), `EUR/GBP_RV` = c(0.00446710941914797,
0.00401994700051122, 0.00407732180013827, 0.00466624428620966,
0.00458235106134663, 0.00482454749708351), `EUR/GBP_RV_5` = c(0.00499598016427624,
0.00470474196716823, 0.00456452150727461, 0.00453292965488229,
0.00436259471347075, 0.00442030721926592), `EUR/GBP_RV_22` = c(0.00515060219897263,
0.00509920878086075, 0.00502079002092667, 0.00501107755050095,
0.00499963428727425, 0.00495435807685843), `EUR/GBP_RBV` = c(0.00324667045338159,
0.00288377777753365, 0.00300554199386584, 0.00360608177982326,
0.00327292734850446, 0.00272655057625291), `EUR/GBP_RBV_5` = c(0.0034985439252634,
0.00318731350301598, 0.00319529774619179, 0.0032799330165155,
0.00320299987062176, 0.00310626895475871), `EUR/GBP_RBV_22` = c(0.0036581887941976,
0.00362298829344015, 0.00355498498935768, 0.0035465419934449,
0.00355752455210586, 0.00351669973034298), `EUR/GBP_RGV` = c(0.00306825643155514,
0.00280067842079775, 0.00275522601341373, 0.00296142025653418,
0.00320716195737542, 0.00398022367546721), `EUR/GBP_RGV_5` = c(0.00353290218424469,
0.00345194162523714, 0.00325362896209417, 0.00312087362386985,
0.00295854861593525, 0.00311308998902836), `EUR/GBP_RGV_22` = c(0.00359974659692405,
0.00356342531619103, 0.00352224165959556, 0.00351722666683608,
0.00349184335907274, 0.00346394410318992), `EUR/GBP_TotalCount` = structure(c(-0.179518680545716,
-0.0757259172924681, 0.333514120677483, 0.759064450015801, -0.419724789788948,
-0.360414639358521), .Dim = c(6L, 1L)), `EUR/GBP_BloombergCount` = structure(c(-0.701694550941621,
-0.669811381311996, -0.574161872423118, -0.644304845608295, -0.784590791978649,
-0.631551577756444), .Dim = c(6L, 1L)), `EUR/GBP_SocialMediaCount` = structure(c(-1.68861759789696,
-1.66829994393287, -1.5910928588693, -1.59515638966212, -1.6967446594826,
-1.63172816679749), .Dim = c(6L, 1L)), `EUR/GBP_NewsCount` = structure(c(0.76560533722738,
0.879161625683434, 1.33717198912285, 1.90306082659552, 0.487392430510049,
0.487392430510049), .Dim = c(6L, 1L))), na.action = structure(c(`6` = 6L,
`38` = 38L, `74` = 74L, `101` = 101L, `140` = 140L, `165` = 165L,
`189` = 189L, `197` = 197L, `236` = 236L, `256` = 256L, `323` = 323L,
`351` = 351L, `393` = 393L, `423` = 423L, `442` = 442L, `455` = 455L,
`490` = 490L, `510` = 510L, `551` = 551L, `576` = 576L, `605` = 605L,
`646` = 646L, `676` = 676L, `696` = 696L, `708` = 708L, `742` = 742L,
`762` = 762L, `793` = 793L, `829` = 829L, `858` = 858L, `904` = 904L,
`929` = 929L, `950` = 950L, `961` = 961L, `996` = 996L, `1016` = 1016L,
`1089` = 1089L, `1114` = 1114L, `1159` = 1159L, `1184` = 1184L,
`1207` = 1207L, `1216` = 1216L, `1238` = 1238L, `1243` = 1243L,
`1253` = 1253L, `1278` = 1278L, `1315` = 1315L, `1346` = 1346L,
`1372` = 1372L, `1416` = 1416L, `1441` = 1441L, `1473` = 1473L,
`1532` = 1532L, `1599` = 1599L, `1626` = 1626L, `1669` = 1669L,
`1694` = 1694L, `1718` = 1718L, `1726` = 1726L, `1766` = 1766L,
`1786` = 1786L, `1827` = 1827L, `1853` = 1853L, `1881` = 1881L,
`1922` = 1922L, `1952` = 1952L, `1971` = 1971L, `1984` = 1984L,
`2019` = 2019L, `2039` = 2039L, `2075` = 2075L, `2106` = 2106L,
`2135` = 2135L, `2181` = 2181L, `2206` = 2206L, `2227` = 2227L,
`2238` = 2238L, `2273` = 2273L, `2293` = 2293L, `2325` = 2325L,
`2366` = 2366L, `2391` = 2391L, `2436` = 2436L, `2461` = 2461L,
`2483` = 2483L, `2493` = 2493L), class = "omit"), row.names = c(1L,
2L, 3L, 4L, 5L, 7L), class = "data.frame")
I have built 9 regression models per forecast horizon (t+1, t+5 and t+22) and I am using the predict function to make my forecasts. I have coded this in an R loop, where I also try to assign each forecast to a matrix. My code is the following:
EUR/GBP_RBV`+data.estimateI am trying to calculate realized volatility forecasts using a rolling window forecast. My aim is to use the first 500 observations to forecast the 501st observations, then shift the window forward one step using observations 2 to 501 to predict the 502nd observation. I want this to repeat until I have a complete pseudo out-of-sample forecast.
My df contains 2411 observations of 23 variables, here is small example:
Date
EUR/GBP_RV t+1
EUR/GBP_RV
EUR/GBP_RV_5
EUR/GBP_RV_22
2012-02-13
0.004019947
0.004467109
0.004995980
0.005150602
2012-02-14
0.004077322
0.004019947
0.004704742
0.005099209
2012-02-15
0.004666244
0.004077322
0.004564522
0.005020790
2012-02-16
0.004582351
0.004666244
0.004532930
0.005011078
2012-02-17
0.003951071
0.004582351
0.004362595
0.004999634
2012-02-21
0.005549329
0.004824547
0.004467109
0.004954358
The head of the df can be reproduced with
structure(list(Date = structure(c(15383, 15384, 15385, 15386,
15387, 15391), class = "Date"), `EUR/GBP_RV t+1,t+22` = c(0.00437808494654599,
0.00439764887779732, 0.00441997330738947, 0.00437799055732722,
0.00435021150904479, 0.00434881306458859), `EUR/GBP_RGV t+1,t+22` = c(0.00310674728131117,
0.00311502965608506, 0.00313756204195853, 0.00312923997431178,
0.00310846773074243, 0.00309755540903969), `EUR/GBP_RBV t+1,t+22` = c(0.00304961980133602,
0.00306866297401415, 0.00307794319983677, 0.00302801249035602,
0.00300946121851254, 0.00302272755554915), `EUR/GBP_RV t+1,t+5` = c(0.00425938711995146,
0.00442030721926592, 0.00471470868108043, 0.00487869292442023,
0.00476849421943949, 0.0046067439660438), `EUR/GBP_RGV t+1,t+5` = c(0.00287718093809447,
0.00311308998902836, 0.00344398536439729, 0.00376911066284235,
0.00377425759242542, 0.00353909902900148), `EUR/GBP_RBV t+1,t+5` = c(0.00313771439501486,
0.00310626895475871, 0.0031789431316576, 0.00305962424370556,
0.00288671182187571, 0.00291630955829613), `EUR/GBP_RV t+1` = c(0.00401994700051122,
0.00407732180013827, 0.00466624428620966, 0.00458235106134663,
0.00395107145155152, 0.00554932910921084), `EUR/GBP_RGV t+1` = c(0.00280067842079775,
0.00275522601341373, 0.00296142025653418, 0.00320716195737542,
0.00266141804235125, 0.00440970289025837), `EUR/GBP_RBV t+1` = c(0.00288377777753365,
0.00300554199386584, 0.00360608177982326, 0.00327292734850446,
0.0029202430753471, 0.00336891287836027), `EUR/GBP_RV` = c(0.00446710941914797,
0.00401994700051122, 0.00407732180013827, 0.00466624428620966,
0.00458235106134663, 0.00482454749708351), `EUR/GBP_RV_5` = c(0.00499598016427624,
0.00470474196716823, 0.00456452150727461, 0.00453292965488229,
0.00436259471347075, 0.00442030721926592), `EUR/GBP_RV_22` = c(0.00515060219897263,
0.00509920878086075, 0.00502079002092667, 0.00501107755050095,
0.00499963428727425, 0.00495435807685843), `EUR/GBP_RBV` = c(0.00324667045338159,
0.00288377777753365, 0.00300554199386584, 0.00360608177982326,
0.00327292734850446, 0.00272655057625291), `EUR/GBP_RBV_5` = c(0.0034985439252634,
0.00318731350301598, 0.00319529774619179, 0.0032799330165155,
0.00320299987062176, 0.00310626895475871), `EUR/GBP_RBV_22` = c(0.0036581887941976,
0.00362298829344015, 0.00355498498935768, 0.0035465419934449,
0.00355752455210586, 0.00351669973034298), `EUR/GBP_RGV` = c(0.00306825643155514,
0.00280067842079775, 0.00275522601341373, 0.00296142025653418,
0.00320716195737542, 0.00398022367546721), `EUR/GBP_RGV_5` = c(0.00353290218424469,
0.00345194162523714, 0.00325362896209417, 0.00312087362386985,
0.00295854861593525, 0.00311308998902836), `EUR/GBP_RGV_22` = c(0.00359974659692405,
0.00356342531619103, 0.00352224165959556, 0.00351722666683608,
0.00349184335907274, 0.00346394410318992), `EUR/GBP_TotalCount` = structure(c(-0.179518680545716,
-0.0757259172924681, 0.333514120677483, 0.759064450015801, -0.419724789788948,
-0.360414639358521), .Dim = c(6L, 1L)), `EUR/GBP_BloombergCount` = structure(c(-0.701694550941621,
-0.669811381311996, -0.574161872423118, -0.644304845608295, -0.784590791978649,
-0.631551577756444), .Dim = c(6L, 1L)), `EUR/GBP_SocialMediaCount` = structure(c(-1.68861759789696,
-1.66829994393287, -1.5910928588693, -1.59515638966212, -1.6967446594826,
-1.63172816679749), .Dim = c(6L, 1L)), `EUR/GBP_NewsCount` = structure(c(0.76560533722738,
0.879161625683434, 1.33717198912285, 1.90306082659552, 0.487392430510049,
0.487392430510049), .Dim = c(6L, 1L))), na.action = structure(c(`6` = 6L,
`38` = 38L, `74` = 74L, `101` = 101L, `140` = 140L, `165` = 165L,
`189` = 189L, `197` = 197L, `236` = 236L, `256` = 256L, `323` = 323L,
`351` = 351L, `393` = 393L, `423` = 423L, `442` = 442L, `455` = 455L,
`490` = 490L, `510` = 510L, `551` = 551L, `576` = 576L, `605` = 605L,
`646` = 646L, `676` = 676L, `696` = 696L, `708` = 708L, `742` = 742L,
`762` = 762L, `793` = 793L, `829` = 829L, `858` = 858L, `904` = 904L,
`929` = 929L, `950` = 950L, `961` = 961L, `996` = 996L, `1016` = 1016L,
`1089` = 1089L, `1114` = 1114L, `1159` = 1159L, `1184` = 1184L,
`1207` = 1207L, `1216` = 1216L, `1238` = 1238L, `1243` = 1243L,
`1253` = 1253L, `1278` = 1278L, `1315` = 1315L, `1346` = 1346L,
`1372` = 1372L, `1416` = 1416L, `1441` = 1441L, `1473` = 1473L,
`1532` = 1532L, `1599` = 1599L, `1626` = 1626L, `1669` = 1669L,
`1694` = 1694L, `1718` = 1718L, `1726` = 1726L, `1766` = 1766L,
`1786` = 1786L, `1827` = 1827L, `1853` = 1853L, `1881` = 1881L,
`1922` = 1922L, `1952` = 1952L, `1971` = 1971L, `1984` = 1984L,
`2019` = 2019L, `2039` = 2039L, `2075` = 2075L, `2106` = 2106L,
`2135` = 2135L, `2181` = 2181L, `2206` = 2206L, `2227` = 2227L,
`2238` = 2238L, `2273` = 2273L, `2293` = 2293L, `2325` = 2325L,
`2366` = 2366L, `2391` = 2391L, `2436` = 2436L, `2461` = 2461L,
`2483` = 2483L, `2493` = 2493L), class = "omit"), row.names = c(1L,
2L, 3L, 4L, 5L, 7L), class = "data.frame")
I have built 9 regression models per forecast horizon (t+1, t+5 and t+22) and I am using the predict function to make my forecasts. I have coded this in an R loop, where I also try to assign each forecast to a matrix. My code is the following:
EUR/GBP_RBV_5`+data.estimateI am trying to calculate realized volatility forecasts using a rolling window forecast. My aim is to use the first 500 observations to forecast the 501st observations, then shift the window forward one step using observations 2 to 501 to predict the 502nd observation. I want this to repeat until I have a complete pseudo out-of-sample forecast.
My df contains 2411 observations of 23 variables, here is small example:
Date
EUR/GBP_RV t+1
EUR/GBP_RV
EUR/GBP_RV_5
EUR/GBP_RV_22
2012-02-13
0.004019947
0.004467109
0.004995980
0.005150602
2012-02-14
0.004077322
0.004019947
0.004704742
0.005099209
2012-02-15
0.004666244
0.004077322
0.004564522
0.005020790
2012-02-16
0.004582351
0.004666244
0.004532930
0.005011078
2012-02-17
0.003951071
0.004582351
0.004362595
0.004999634
2012-02-21
0.005549329
0.004824547
0.004467109
0.004954358
The head of the df can be reproduced with
structure(list(Date = structure(c(15383, 15384, 15385, 15386,
15387, 15391), class = "Date"), `EUR/GBP_RV t+1,t+22` = c(0.00437808494654599,
0.00439764887779732, 0.00441997330738947, 0.00437799055732722,
0.00435021150904479, 0.00434881306458859), `EUR/GBP_RGV t+1,t+22` = c(0.00310674728131117,
0.00311502965608506, 0.00313756204195853, 0.00312923997431178,
0.00310846773074243, 0.00309755540903969), `EUR/GBP_RBV t+1,t+22` = c(0.00304961980133602,
0.00306866297401415, 0.00307794319983677, 0.00302801249035602,
0.00300946121851254, 0.00302272755554915), `EUR/GBP_RV t+1,t+5` = c(0.00425938711995146,
0.00442030721926592, 0.00471470868108043, 0.00487869292442023,
0.00476849421943949, 0.0046067439660438), `EUR/GBP_RGV t+1,t+5` = c(0.00287718093809447,
0.00311308998902836, 0.00344398536439729, 0.00376911066284235,
0.00377425759242542, 0.00353909902900148), `EUR/GBP_RBV t+1,t+5` = c(0.00313771439501486,
0.00310626895475871, 0.0031789431316576, 0.00305962424370556,
0.00288671182187571, 0.00291630955829613), `EUR/GBP_RV t+1` = c(0.00401994700051122,
0.00407732180013827, 0.00466624428620966, 0.00458235106134663,
0.00395107145155152, 0.00554932910921084), `EUR/GBP_RGV t+1` = c(0.00280067842079775,
0.00275522601341373, 0.00296142025653418, 0.00320716195737542,
0.00266141804235125, 0.00440970289025837), `EUR/GBP_RBV t+1` = c(0.00288377777753365,
0.00300554199386584, 0.00360608177982326, 0.00327292734850446,
0.0029202430753471, 0.00336891287836027), `EUR/GBP_RV` = c(0.00446710941914797,
0.00401994700051122, 0.00407732180013827, 0.00466624428620966,
0.00458235106134663, 0.00482454749708351), `EUR/GBP_RV_5` = c(0.00499598016427624,
0.00470474196716823, 0.00456452150727461, 0.00453292965488229,
0.00436259471347075, 0.00442030721926592), `EUR/GBP_RV_22` = c(0.00515060219897263,
0.00509920878086075, 0.00502079002092667, 0.00501107755050095,
0.00499963428727425, 0.00495435807685843), `EUR/GBP_RBV` = c(0.00324667045338159,
0.00288377777753365, 0.00300554199386584, 0.00360608177982326,
0.00327292734850446, 0.00272655057625291), `EUR/GBP_RBV_5` = c(0.0034985439252634,
0.00318731350301598, 0.00319529774619179, 0.0032799330165155,
0.00320299987062176, 0.00310626895475871), `EUR/GBP_RBV_22` = c(0.0036581887941976,
0.00362298829344015, 0.00355498498935768, 0.0035465419934449,
0.00355752455210586, 0.00351669973034298), `EUR/GBP_RGV` = c(0.00306825643155514,
0.00280067842079775, 0.00275522601341373, 0.00296142025653418,
0.00320716195737542, 0.00398022367546721), `EUR/GBP_RGV_5` = c(0.00353290218424469,
0.00345194162523714, 0.00325362896209417, 0.00312087362386985,
0.00295854861593525, 0.00311308998902836), `EUR/GBP_RGV_22` = c(0.00359974659692405,
0.00356342531619103, 0.00352224165959556, 0.00351722666683608,
0.00349184335907274, 0.00346394410318992), `EUR/GBP_TotalCount` = structure(c(-0.179518680545716,
-0.0757259172924681, 0.333514120677483, 0.759064450015801, -0.419724789788948,
-0.360414639358521), .Dim = c(6L, 1L)), `EUR/GBP_BloombergCount` = structure(c(-0.701694550941621,
-0.669811381311996, -0.574161872423118, -0.644304845608295, -0.784590791978649,
-0.631551577756444), .Dim = c(6L, 1L)), `EUR/GBP_SocialMediaCount` = structure(c(-1.68861759789696,
-1.66829994393287, -1.5910928588693, -1.59515638966212, -1.6967446594826,
-1.63172816679749), .Dim = c(6L, 1L)), `EUR/GBP_NewsCount` = structure(c(0.76560533722738,
0.879161625683434, 1.33717198912285, 1.90306082659552, 0.487392430510049,
0.487392430510049), .Dim = c(6L, 1L))), na.action = structure(c(`6` = 6L,
`38` = 38L, `74` = 74L, `101` = 101L, `140` = 140L, `165` = 165L,
`189` = 189L, `197` = 197L, `236` = 236L, `256` = 256L, `323` = 323L,
`351` = 351L, `393` = 393L, `423` = 423L, `442` = 442L, `455` = 455L,
`490` = 490L, `510` = 510L, `551` = 551L, `576` = 576L, `605` = 605L,
`646` = 646L, `676` = 676L, `696` = 696L, `708` = 708L, `742` = 742L,
`762` = 762L, `793` = 793L, `829` = 829L, `858` = 858L, `904` = 904L,
`929` = 929L, `950` = 950L, `961` = 961L, `996` = 996L, `1016` = 1016L,
`1089` = 1089L, `1114` = 1114L, `1159` = 1159L, `1184` = 1184L,
`1207` = 1207L, `1216` = 1216L, `1238` = 1238L, `1243` = 1243L,
`1253` = 1253L, `1278` = 1278L, `1315` = 1315L, `1346` = 1346L,
`1372` = 1372L, `1416` = 1416L, `1441` = 1441L, `1473` = 1473L,
`1532` = 1532L, `1599` = 1599L, `1626` = 1626L, `1669` = 1669L,
`1694` = 1694L, `1718` = 1718L, `1726` = 1726L, `1766` = 1766L,
`1786` = 1786L, `1827` = 1827L, `1853` = 1853L, `1881` = 1881L,
`1922` = 1922L, `1952` = 1952L, `1971` = 1971L, `1984` = 1984L,
`2019` = 2019L, `2039` = 2039L, `2075` = 2075L, `2106` = 2106L,
`2135` = 2135L, `2181` = 2181L, `2206` = 2206L, `2227` = 2227L,
`2238` = 2238L, `2273` = 2273L, `2293` = 2293L, `2325` = 2325L,
`2366` = 2366L, `2391` = 2391L, `2436` = 2436L, `2461` = 2461L,
`2483` = 2483L, `2493` = 2493L), class = "omit"), row.names = c(1L,
2L, 3L, 4L, 5L, 7L), class = "data.frame")
I have built 9 regression models per forecast horizon (t+1, t+5 and t+22) and I am using the predict function to make my forecasts. I have coded this in an R loop, where I also try to assign each forecast to a matrix. My code is the following:
EUR/GBP_RBV_22`+data.estimateI am trying to calculate realized volatility forecasts using a rolling window forecast. My aim is to use the first 500 observations to forecast the 501st observations, then shift the window forward one step using observations 2 to 501 to predict the 502nd observation. I want this to repeat until I have a complete pseudo out-of-sample forecast.
My df contains 2411 observations of 23 variables, here is small example:
Date
EUR/GBP_RV t+1
EUR/GBP_RV
EUR/GBP_RV_5
EUR/GBP_RV_22
2012-02-13
0.004019947
0.004467109
0.004995980
0.005150602
2012-02-14
0.004077322
0.004019947
0.004704742
0.005099209
2012-02-15
0.004666244
0.004077322
0.004564522
0.005020790
2012-02-16
0.004582351
0.004666244
0.004532930
0.005011078
2012-02-17
0.003951071
0.004582351
0.004362595
0.004999634
2012-02-21
0.005549329
0.004824547
0.004467109
0.004954358
The head of the df can be reproduced with
structure(list(Date = structure(c(15383, 15384, 15385, 15386,
15387, 15391), class = "Date"), `EUR/GBP_RV t+1,t+22` = c(0.00437808494654599,
0.00439764887779732, 0.00441997330738947, 0.00437799055732722,
0.00435021150904479, 0.00434881306458859), `EUR/GBP_RGV t+1,t+22` = c(0.00310674728131117,
0.00311502965608506, 0.00313756204195853, 0.00312923997431178,
0.00310846773074243, 0.00309755540903969), `EUR/GBP_RBV t+1,t+22` = c(0.00304961980133602,
0.00306866297401415, 0.00307794319983677, 0.00302801249035602,
0.00300946121851254, 0.00302272755554915), `EUR/GBP_RV t+1,t+5` = c(0.00425938711995146,
0.00442030721926592, 0.00471470868108043, 0.00487869292442023,
0.00476849421943949, 0.0046067439660438), `EUR/GBP_RGV t+1,t+5` = c(0.00287718093809447,
0.00311308998902836, 0.00344398536439729, 0.00376911066284235,
0.00377425759242542, 0.00353909902900148), `EUR/GBP_RBV t+1,t+5` = c(0.00313771439501486,
0.00310626895475871, 0.0031789431316576, 0.00305962424370556,
0.00288671182187571, 0.00291630955829613), `EUR/GBP_RV t+1` = c(0.00401994700051122,
0.00407732180013827, 0.00466624428620966, 0.00458235106134663,
0.00395107145155152, 0.00554932910921084), `EUR/GBP_RGV t+1` = c(0.00280067842079775,
0.00275522601341373, 0.00296142025653418, 0.00320716195737542,
0.00266141804235125, 0.00440970289025837), `EUR/GBP_RBV t+1` = c(0.00288377777753365,
0.00300554199386584, 0.00360608177982326, 0.00327292734850446,
0.0029202430753471, 0.00336891287836027), `EUR/GBP_RV` = c(0.00446710941914797,
0.00401994700051122, 0.00407732180013827, 0.00466624428620966,
0.00458235106134663, 0.00482454749708351), `EUR/GBP_RV_5` = c(0.00499598016427624,
0.00470474196716823, 0.00456452150727461, 0.00453292965488229,
0.00436259471347075, 0.00442030721926592), `EUR/GBP_RV_22` = c(0.00515060219897263,
0.00509920878086075, 0.00502079002092667, 0.00501107755050095,
0.00499963428727425, 0.00495435807685843), `EUR/GBP_RBV` = c(0.00324667045338159,
0.00288377777753365, 0.00300554199386584, 0.00360608177982326,
0.00327292734850446, 0.00272655057625291), `EUR/GBP_RBV_5` = c(0.0034985439252634,
0.00318731350301598, 0.00319529774619179, 0.0032799330165155,
0.00320299987062176, 0.00310626895475871), `EUR/GBP_RBV_22` = c(0.0036581887941976,
0.00362298829344015, 0.00355498498935768, 0.0035465419934449,
0.00355752455210586, 0.00351669973034298), `EUR/GBP_RGV` = c(0.00306825643155514,
0.00280067842079775, 0.00275522601341373, 0.00296142025653418,
0.00320716195737542, 0.00398022367546721), `EUR/GBP_RGV_5` = c(0.00353290218424469,
0.00345194162523714, 0.00325362896209417, 0.00312087362386985,
0.00295854861593525, 0.00311308998902836), `EUR/GBP_RGV_22` = c(0.00359974659692405,
0.00356342531619103, 0.00352224165959556, 0.00351722666683608,
0.00349184335907274, 0.00346394410318992), `EUR/GBP_TotalCount` = structure(c(-0.179518680545716,
-0.0757259172924681, 0.333514120677483, 0.759064450015801, -0.419724789788948,
-0.360414639358521), .Dim = c(6L, 1L)), `EUR/GBP_BloombergCount` = structure(c(-0.701694550941621,
-0.669811381311996, -0.574161872423118, -0.644304845608295, -0.784590791978649,
-0.631551577756444), .Dim = c(6L, 1L)), `EUR/GBP_SocialMediaCount` = structure(c(-1.68861759789696,
-1.66829994393287, -1.5910928588693, -1.59515638966212, -1.6967446594826,
-1.63172816679749), .Dim = c(6L, 1L)), `EUR/GBP_NewsCount` = structure(c(0.76560533722738,
0.879161625683434, 1.33717198912285, 1.90306082659552, 0.487392430510049,
0.487392430510049), .Dim = c(6L, 1L))), na.action = structure(c(`6` = 6L,
`38` = 38L, `74` = 74L, `101` = 101L, `140` = 140L, `165` = 165L,
`189` = 189L, `197` = 197L, `236` = 236L, `256` = 256L, `323` = 323L,
`351` = 351L, `393` = 393L, `423` = 423L, `442` = 442L, `455` = 455L,
`490` = 490L, `510` = 510L, `551` = 551L, `576` = 576L, `605` = 605L,
`646` = 646L, `676` = 676L, `696` = 696L, `708` = 708L, `742` = 742L,
`762` = 762L, `793` = 793L, `829` = 829L, `858` = 858L, `904` = 904L,
`929` = 929L, `950` = 950L, `961` = 961L, `996` = 996L, `1016` = 1016L,
`1089` = 1089L, `1114` = 1114L, `1159` = 1159L, `1184` = 1184L,
`1207` = 1207L, `1216` = 1216L, `1238` = 1238L, `1243` = 1243L,
`1253` = 1253L, `1278` = 1278L, `1315` = 1315L, `1346` = 1346L,
`1372` = 1372L, `1416` = 1416L, `1441` = 1441L, `1473` = 1473L,
`1532` = 1532L, `1599` = 1599L, `1626` = 1626L, `1669` = 1669L,
`1694` = 1694L, `1718` = 1718L, `1726` = 1726L, `1766` = 1766L,
`1786` = 1786L, `1827` = 1827L, `1853` = 1853L, `1881` = 1881L,
`1922` = 1922L, `1952` = 1952L, `1971` = 1971L, `1984` = 1984L,
`2019` = 2019L, `2039` = 2039L, `2075` = 2075L, `2106` = 2106L,
`2135` = 2135L, `2181` = 2181L, `2206` = 2206L, `2227` = 2227L,
`2238` = 2238L, `2273` = 2273L, `2293` = 2293L, `2325` = 2325L,
`2366` = 2366L, `2391` = 2391L, `2436` = 2436L, `2461` = 2461L,
`2483` = 2483L, `2493` = 2493L), class = "omit"), row.names = c(1L,
2L, 3L, 4L, 5L, 7L), class = "data.frame")
I have built 9 regression models per forecast horizon (t+1, t+5 and t+22) and I am using the predict function to make my forecasts. I have coded this in an R loop, where I also try to assign each forecast to a matrix. My code is the following:
EUR/GBP_TotalCount`)
EURGBP_HAR_RVG_train <- lm(data.estimateI am trying to calculate realized volatility forecasts using a rolling window forecast. My aim is to use the first 500 observations to forecast the 501st observations, then shift the window forward one step using observations 2 to 501 to predict the 502nd observation. I want this to repeat until I have a complete pseudo out-of-sample forecast.
My df contains 2411 observations of 23 variables, here is small example:
Date
EUR/GBP_RV t+1
EUR/GBP_RV
EUR/GBP_RV_5
EUR/GBP_RV_22
2012-02-13
0.004019947
0.004467109
0.004995980
0.005150602
2012-02-14
0.004077322
0.004019947
0.004704742
0.005099209
2012-02-15
0.004666244
0.004077322
0.004564522
0.005020790
2012-02-16
0.004582351
0.004666244
0.004532930
0.005011078
2012-02-17
0.003951071
0.004582351
0.004362595
0.004999634
2012-02-21
0.005549329
0.004824547
0.004467109
0.004954358
The head of the df can be reproduced with
structure(list(Date = structure(c(15383, 15384, 15385, 15386,
15387, 15391), class = "Date"), `EUR/GBP_RV t+1,t+22` = c(0.00437808494654599,
0.00439764887779732, 0.00441997330738947, 0.00437799055732722,
0.00435021150904479, 0.00434881306458859), `EUR/GBP_RGV t+1,t+22` = c(0.00310674728131117,
0.00311502965608506, 0.00313756204195853, 0.00312923997431178,
0.00310846773074243, 0.00309755540903969), `EUR/GBP_RBV t+1,t+22` = c(0.00304961980133602,
0.00306866297401415, 0.00307794319983677, 0.00302801249035602,
0.00300946121851254, 0.00302272755554915), `EUR/GBP_RV t+1,t+5` = c(0.00425938711995146,
0.00442030721926592, 0.00471470868108043, 0.00487869292442023,
0.00476849421943949, 0.0046067439660438), `EUR/GBP_RGV t+1,t+5` = c(0.00287718093809447,
0.00311308998902836, 0.00344398536439729, 0.00376911066284235,
0.00377425759242542, 0.00353909902900148), `EUR/GBP_RBV t+1,t+5` = c(0.00313771439501486,
0.00310626895475871, 0.0031789431316576, 0.00305962424370556,
0.00288671182187571, 0.00291630955829613), `EUR/GBP_RV t+1` = c(0.00401994700051122,
0.00407732180013827, 0.00466624428620966, 0.00458235106134663,
0.00395107145155152, 0.00554932910921084), `EUR/GBP_RGV t+1` = c(0.00280067842079775,
0.00275522601341373, 0.00296142025653418, 0.00320716195737542,
0.00266141804235125, 0.00440970289025837), `EUR/GBP_RBV t+1` = c(0.00288377777753365,
0.00300554199386584, 0.00360608177982326, 0.00327292734850446,
0.0029202430753471, 0.00336891287836027), `EUR/GBP_RV` = c(0.00446710941914797,
0.00401994700051122, 0.00407732180013827, 0.00466624428620966,
0.00458235106134663, 0.00482454749708351), `EUR/GBP_RV_5` = c(0.00499598016427624,
0.00470474196716823, 0.00456452150727461, 0.00453292965488229,
0.00436259471347075, 0.00442030721926592), `EUR/GBP_RV_22` = c(0.00515060219897263,
0.00509920878086075, 0.00502079002092667, 0.00501107755050095,
0.00499963428727425, 0.00495435807685843), `EUR/GBP_RBV` = c(0.00324667045338159,
0.00288377777753365, 0.00300554199386584, 0.00360608177982326,
0.00327292734850446, 0.00272655057625291), `EUR/GBP_RBV_5` = c(0.0034985439252634,
0.00318731350301598, 0.00319529774619179, 0.0032799330165155,
0.00320299987062176, 0.00310626895475871), `EUR/GBP_RBV_22` = c(0.0036581887941976,
0.00362298829344015, 0.00355498498935768, 0.0035465419934449,
0.00355752455210586, 0.00351669973034298), `EUR/GBP_RGV` = c(0.00306825643155514,
0.00280067842079775, 0.00275522601341373, 0.00296142025653418,
0.00320716195737542, 0.00398022367546721), `EUR/GBP_RGV_5` = c(0.00353290218424469,
0.00345194162523714, 0.00325362896209417, 0.00312087362386985,
0.00295854861593525, 0.00311308998902836), `EUR/GBP_RGV_22` = c(0.00359974659692405,
0.00356342531619103, 0.00352224165959556, 0.00351722666683608,
0.00349184335907274, 0.00346394410318992), `EUR/GBP_TotalCount` = structure(c(-0.179518680545716,
-0.0757259172924681, 0.333514120677483, 0.759064450015801, -0.419724789788948,
-0.360414639358521), .Dim = c(6L, 1L)), `EUR/GBP_BloombergCount` = structure(c(-0.701694550941621,
-0.669811381311996, -0.574161872423118, -0.644304845608295, -0.784590791978649,
-0.631551577756444), .Dim = c(6L, 1L)), `EUR/GBP_SocialMediaCount` = structure(c(-1.68861759789696,
-1.66829994393287, -1.5910928588693, -1.59515638966212, -1.6967446594826,
-1.63172816679749), .Dim = c(6L, 1L)), `EUR/GBP_NewsCount` = structure(c(0.76560533722738,
0.879161625683434, 1.33717198912285, 1.90306082659552, 0.487392430510049,
0.487392430510049), .Dim = c(6L, 1L))), na.action = structure(c(`6` = 6L,
`38` = 38L, `74` = 74L, `101` = 101L, `140` = 140L, `165` = 165L,
`189` = 189L, `197` = 197L, `236` = 236L, `256` = 256L, `323` = 323L,
`351` = 351L, `393` = 393L, `423` = 423L, `442` = 442L, `455` = 455L,
`490` = 490L, `510` = 510L, `551` = 551L, `576` = 576L, `605` = 605L,
`646` = 646L, `676` = 676L, `696` = 696L, `708` = 708L, `742` = 742L,
`762` = 762L, `793` = 793L, `829` = 829L, `858` = 858L, `904` = 904L,
`929` = 929L, `950` = 950L, `961` = 961L, `996` = 996L, `1016` = 1016L,
`1089` = 1089L, `1114` = 1114L, `1159` = 1159L, `1184` = 1184L,
`1207` = 1207L, `1216` = 1216L, `1238` = 1238L, `1243` = 1243L,
`1253` = 1253L, `1278` = 1278L, `1315` = 1315L, `1346` = 1346L,
`1372` = 1372L, `1416` = 1416L, `1441` = 1441L, `1473` = 1473L,
`1532` = 1532L, `1599` = 1599L, `1626` = 1626L, `1669` = 1669L,
`1694` = 1694L, `1718` = 1718L, `1726` = 1726L, `1766` = 1766L,
`1786` = 1786L, `1827` = 1827L, `1853` = 1853L, `1881` = 1881L,
`1922` = 1922L, `1952` = 1952L, `1971` = 1971L, `1984` = 1984L,
`2019` = 2019L, `2039` = 2039L, `2075` = 2075L, `2106` = 2106L,
`2135` = 2135L, `2181` = 2181L, `2206` = 2206L, `2227` = 2227L,
`2238` = 2238L, `2273` = 2273L, `2293` = 2293L, `2325` = 2325L,
`2366` = 2366L, `2391` = 2391L, `2436` = 2436L, `2461` = 2461L,
`2483` = 2483L, `2493` = 2493L), class = "omit"), row.names = c(1L,
2L, 3L, 4L, 5L, 7L), class = "data.frame")
I have built 9 regression models per forecast horizon (t+1, t+5 and t+22) and I am using the predict function to make my forecasts. I have coded this in an R loop, where I also try to assign each forecast to a matrix. My code is the following:
EUR/GBP_RGV t+1`~data.estimateI am trying to calculate realized volatility forecasts using a rolling window forecast. My aim is to use the first 500 observations to forecast the 501st observations, then shift the window forward one step using observations 2 to 501 to predict the 502nd observation. I want this to repeat until I have a complete pseudo out-of-sample forecast.
My df contains 2411 observations of 23 variables, here is small example:
Date
EUR/GBP_RV t+1
EUR/GBP_RV
EUR/GBP_RV_5
EUR/GBP_RV_22
2012-02-13
0.004019947
0.004467109
0.004995980
0.005150602
2012-02-14
0.004077322
0.004019947
0.004704742
0.005099209
2012-02-15
0.004666244
0.004077322
0.004564522
0.005020790
2012-02-16
0.004582351
0.004666244
0.004532930
0.005011078
2012-02-17
0.003951071
0.004582351
0.004362595
0.004999634
2012-02-21
0.005549329
0.004824547
0.004467109
0.004954358
The head of the df can be reproduced with
structure(list(Date = structure(c(15383, 15384, 15385, 15386,
15387, 15391), class = "Date"), `EUR/GBP_RV t+1,t+22` = c(0.00437808494654599,
0.00439764887779732, 0.00441997330738947, 0.00437799055732722,
0.00435021150904479, 0.00434881306458859), `EUR/GBP_RGV t+1,t+22` = c(0.00310674728131117,
0.00311502965608506, 0.00313756204195853, 0.00312923997431178,
0.00310846773074243, 0.00309755540903969), `EUR/GBP_RBV t+1,t+22` = c(0.00304961980133602,
0.00306866297401415, 0.00307794319983677, 0.00302801249035602,
0.00300946121851254, 0.00302272755554915), `EUR/GBP_RV t+1,t+5` = c(0.00425938711995146,
0.00442030721926592, 0.00471470868108043, 0.00487869292442023,
0.00476849421943949, 0.0046067439660438), `EUR/GBP_RGV t+1,t+5` = c(0.00287718093809447,
0.00311308998902836, 0.00344398536439729, 0.00376911066284235,
0.00377425759242542, 0.00353909902900148), `EUR/GBP_RBV t+1,t+5` = c(0.00313771439501486,
0.00310626895475871, 0.0031789431316576, 0.00305962424370556,
0.00288671182187571, 0.00291630955829613), `EUR/GBP_RV t+1` = c(0.00401994700051122,
0.00407732180013827, 0.00466624428620966, 0.00458235106134663,
0.00395107145155152, 0.00554932910921084), `EUR/GBP_RGV t+1` = c(0.00280067842079775,
0.00275522601341373, 0.00296142025653418, 0.00320716195737542,
0.00266141804235125, 0.00440970289025837), `EUR/GBP_RBV t+1` = c(0.00288377777753365,
0.00300554199386584, 0.00360608177982326, 0.00327292734850446,
0.0029202430753471, 0.00336891287836027), `EUR/GBP_RV` = c(0.00446710941914797,
0.00401994700051122, 0.00407732180013827, 0.00466624428620966,
0.00458235106134663, 0.00482454749708351), `EUR/GBP_RV_5` = c(0.00499598016427624,
0.00470474196716823, 0.00456452150727461, 0.00453292965488229,
0.00436259471347075, 0.00442030721926592), `EUR/GBP_RV_22` = c(0.00515060219897263,
0.00509920878086075, 0.00502079002092667, 0.00501107755050095,
0.00499963428727425, 0.00495435807685843), `EUR/GBP_RBV` = c(0.00324667045338159,
0.00288377777753365, 0.00300554199386584, 0.00360608177982326,
0.00327292734850446, 0.00272655057625291), `EUR/GBP_RBV_5` = c(0.0034985439252634,
0.00318731350301598, 0.00319529774619179, 0.0032799330165155,
0.00320299987062176, 0.00310626895475871), `EUR/GBP_RBV_22` = c(0.0036581887941976,
0.00362298829344015, 0.00355498498935768, 0.0035465419934449,
0.00355752455210586, 0.00351669973034298), `EUR/GBP_RGV` = c(0.00306825643155514,
0.00280067842079775, 0.00275522601341373, 0.00296142025653418,
0.00320716195737542, 0.00398022367546721), `EUR/GBP_RGV_5` = c(0.00353290218424469,
0.00345194162523714, 0.00325362896209417, 0.00312087362386985,
0.00295854861593525, 0.00311308998902836), `EUR/GBP_RGV_22` = c(0.00359974659692405,
0.00356342531619103, 0.00352224165959556, 0.00351722666683608,
0.00349184335907274, 0.00346394410318992), `EUR/GBP_TotalCount` = structure(c(-0.179518680545716,
-0.0757259172924681, 0.333514120677483, 0.759064450015801, -0.419724789788948,
-0.360414639358521), .Dim = c(6L, 1L)), `EUR/GBP_BloombergCount` = structure(c(-0.701694550941621,
-0.669811381311996, -0.574161872423118, -0.644304845608295, -0.784590791978649,
-0.631551577756444), .Dim = c(6L, 1L)), `EUR/GBP_SocialMediaCount` = structure(c(-1.68861759789696,
-1.66829994393287, -1.5910928588693, -1.59515638966212, -1.6967446594826,
-1.63172816679749), .Dim = c(6L, 1L)), `EUR/GBP_NewsCount` = structure(c(0.76560533722738,
0.879161625683434, 1.33717198912285, 1.90306082659552, 0.487392430510049,
0.487392430510049), .Dim = c(6L, 1L))), na.action = structure(c(`6` = 6L,
`38` = 38L, `74` = 74L, `101` = 101L, `140` = 140L, `165` = 165L,
`189` = 189L, `197` = 197L, `236` = 236L, `256` = 256L, `323` = 323L,
`351` = 351L, `393` = 393L, `423` = 423L, `442` = 442L, `455` = 455L,
`490` = 490L, `510` = 510L, `551` = 551L, `576` = 576L, `605` = 605L,
`646` = 646L, `676` = 676L, `696` = 696L, `708` = 708L, `742` = 742L,
`762` = 762L, `793` = 793L, `829` = 829L, `858` = 858L, `904` = 904L,
`929` = 929L, `950` = 950L, `961` = 961L, `996` = 996L, `1016` = 1016L,
`1089` = 1089L, `1114` = 1114L, `1159` = 1159L, `1184` = 1184L,
`1207` = 1207L, `1216` = 1216L, `1238` = 1238L, `1243` = 1243L,
`1253` = 1253L, `1278` = 1278L, `1315` = 1315L, `1346` = 1346L,
`1372` = 1372L, `1416` = 1416L, `1441` = 1441L, `1473` = 1473L,
`1532` = 1532L, `1599` = 1599L, `1626` = 1626L, `1669` = 1669L,
`1694` = 1694L, `1718` = 1718L, `1726` = 1726L, `1766` = 1766L,
`1786` = 1786L, `1827` = 1827L, `1853` = 1853L, `1881` = 1881L,
`1922` = 1922L, `1952` = 1952L, `1971` = 1971L, `1984` = 1984L,
`2019` = 2019L, `2039` = 2039L, `2075` = 2075L, `2106` = 2106L,
`2135` = 2135L, `2181` = 2181L, `2206` = 2206L, `2227` = 2227L,
`2238` = 2238L, `2273` = 2273L, `2293` = 2293L, `2325` = 2325L,
`2366` = 2366L, `2391` = 2391L, `2436` = 2436L, `2461` = 2461L,
`2483` = 2483L, `2493` = 2493L), class = "omit"), row.names = c(1L,
2L, 3L, 4L, 5L, 7L), class = "data.frame")
I have built 9 regression models per forecast horizon (t+1, t+5 and t+22) and I am using the predict function to make my forecasts. I have coded this in an R loop, where I also try to assign each forecast to a matrix. My code is the following:
EUR/GBP_RGV`+data.estimateI am trying to calculate realized volatility forecasts using a rolling window forecast. My aim is to use the first 500 observations to forecast the 501st observations, then shift the window forward one step using observations 2 to 501 to predict the 502nd observation. I want this to repeat until I have a complete pseudo out-of-sample forecast.
My df contains 2411 observations of 23 variables, here is small example:
Date
EUR/GBP_RV t+1
EUR/GBP_RV
EUR/GBP_RV_5
EUR/GBP_RV_22
2012-02-13
0.004019947
0.004467109
0.004995980
0.005150602
2012-02-14
0.004077322
0.004019947
0.004704742
0.005099209
2012-02-15
0.004666244
0.004077322
0.004564522
0.005020790
2012-02-16
0.004582351
0.004666244
0.004532930
0.005011078
2012-02-17
0.003951071
0.004582351
0.004362595
0.004999634
2012-02-21
0.005549329
0.004824547
0.004467109
0.004954358
The head of the df can be reproduced with
structure(list(Date = structure(c(15383, 15384, 15385, 15386,
15387, 15391), class = "Date"), `EUR/GBP_RV t+1,t+22` = c(0.00437808494654599,
0.00439764887779732, 0.00441997330738947, 0.00437799055732722,
0.00435021150904479, 0.00434881306458859), `EUR/GBP_RGV t+1,t+22` = c(0.00310674728131117,
0.00311502965608506, 0.00313756204195853, 0.00312923997431178,
0.00310846773074243, 0.00309755540903969), `EUR/GBP_RBV t+1,t+22` = c(0.00304961980133602,
0.00306866297401415, 0.00307794319983677, 0.00302801249035602,
0.00300946121851254, 0.00302272755554915), `EUR/GBP_RV t+1,t+5` = c(0.00425938711995146,
0.00442030721926592, 0.00471470868108043, 0.00487869292442023,
0.00476849421943949, 0.0046067439660438), `EUR/GBP_RGV t+1,t+5` = c(0.00287718093809447,
0.00311308998902836, 0.00344398536439729, 0.00376911066284235,
0.00377425759242542, 0.00353909902900148), `EUR/GBP_RBV t+1,t+5` = c(0.00313771439501486,
0.00310626895475871, 0.0031789431316576, 0.00305962424370556,
0.00288671182187571, 0.00291630955829613), `EUR/GBP_RV t+1` = c(0.00401994700051122,
0.00407732180013827, 0.00466624428620966, 0.00458235106134663,
0.00395107145155152, 0.00554932910921084), `EUR/GBP_RGV t+1` = c(0.00280067842079775,
0.00275522601341373, 0.00296142025653418, 0.00320716195737542,
0.00266141804235125, 0.00440970289025837), `EUR/GBP_RBV t+1` = c(0.00288377777753365,
0.00300554199386584, 0.00360608177982326, 0.00327292734850446,
0.0029202430753471, 0.00336891287836027), `EUR/GBP_RV` = c(0.00446710941914797,
0.00401994700051122, 0.00407732180013827, 0.00466624428620966,
0.00458235106134663, 0.00482454749708351), `EUR/GBP_RV_5` = c(0.00499598016427624,
0.00470474196716823, 0.00456452150727461, 0.00453292965488229,
0.00436259471347075, 0.00442030721926592), `EUR/GBP_RV_22` = c(0.00515060219897263,
0.00509920878086075, 0.00502079002092667, 0.00501107755050095,
0.00499963428727425, 0.00495435807685843), `EUR/GBP_RBV` = c(0.00324667045338159,
0.00288377777753365, 0.00300554199386584, 0.00360608177982326,
0.00327292734850446, 0.00272655057625291), `EUR/GBP_RBV_5` = c(0.0034985439252634,
0.00318731350301598, 0.00319529774619179, 0.0032799330165155,
0.00320299987062176, 0.00310626895475871), `EUR/GBP_RBV_22` = c(0.0036581887941976,
0.00362298829344015, 0.00355498498935768, 0.0035465419934449,
0.00355752455210586, 0.00351669973034298), `EUR/GBP_RGV` = c(0.00306825643155514,
0.00280067842079775, 0.00275522601341373, 0.00296142025653418,
0.00320716195737542, 0.00398022367546721), `EUR/GBP_RGV_5` = c(0.00353290218424469,
0.00345194162523714, 0.00325362896209417, 0.00312087362386985,
0.00295854861593525, 0.00311308998902836), `EUR/GBP_RGV_22` = c(0.00359974659692405,
0.00356342531619103, 0.00352224165959556, 0.00351722666683608,
0.00349184335907274, 0.00346394410318992), `EUR/GBP_TotalCount` = structure(c(-0.179518680545716,
-0.0757259172924681, 0.333514120677483, 0.759064450015801, -0.419724789788948,
-0.360414639358521), .Dim = c(6L, 1L)), `EUR/GBP_BloombergCount` = structure(c(-0.701694550941621,
-0.669811381311996, -0.574161872423118, -0.644304845608295, -0.784590791978649,
-0.631551577756444), .Dim = c(6L, 1L)), `EUR/GBP_SocialMediaCount` = structure(c(-1.68861759789696,
-1.66829994393287, -1.5910928588693, -1.59515638966212, -1.6967446594826,
-1.63172816679749), .Dim = c(6L, 1L)), `EUR/GBP_NewsCount` = structure(c(0.76560533722738,
0.879161625683434, 1.33717198912285, 1.90306082659552, 0.487392430510049,
0.487392430510049), .Dim = c(6L, 1L))), na.action = structure(c(`6` = 6L,
`38` = 38L, `74` = 74L, `101` = 101L, `140` = 140L, `165` = 165L,
`189` = 189L, `197` = 197L, `236` = 236L, `256` = 256L, `323` = 323L,
`351` = 351L, `393` = 393L, `423` = 423L, `442` = 442L, `455` = 455L,
`490` = 490L, `510` = 510L, `551` = 551L, `576` = 576L, `605` = 605L,
`646` = 646L, `676` = 676L, `696` = 696L, `708` = 708L, `742` = 742L,
`762` = 762L, `793` = 793L, `829` = 829L, `858` = 858L, `904` = 904L,
`929` = 929L, `950` = 950L, `961` = 961L, `996` = 996L, `1016` = 1016L,
`1089` = 1089L, `1114` = 1114L, `1159` = 1159L, `1184` = 1184L,
`1207` = 1207L, `1216` = 1216L, `1238` = 1238L, `1243` = 1243L,
`1253` = 1253L, `1278` = 1278L, `1315` = 1315L, `1346` = 1346L,
`1372` = 1372L, `1416` = 1416L, `1441` = 1441L, `1473` = 1473L,
`1532` = 1532L, `1599` = 1599L, `1626` = 1626L, `1669` = 1669L,
`1694` = 1694L, `1718` = 1718L, `1726` = 1726L, `1766` = 1766L,
`1786` = 1786L, `1827` = 1827L, `1853` = 1853L, `1881` = 1881L,
`1922` = 1922L, `1952` = 1952L, `1971` = 1971L, `1984` = 1984L,
`2019` = 2019L, `2039` = 2039L, `2075` = 2075L, `2106` = 2106L,
`2135` = 2135L, `2181` = 2181L, `2206` = 2206L, `2227` = 2227L,
`2238` = 2238L, `2273` = 2273L, `2293` = 2293L, `2325` = 2325L,
`2366` = 2366L, `2391` = 2391L, `2436` = 2436L, `2461` = 2461L,
`2483` = 2483L, `2493` = 2493L), class = "omit"), row.names = c(1L,
2L, 3L, 4L, 5L, 7L), class = "data.frame")
I have built 9 regression models per forecast horizon (t+1, t+5 and t+22) and I am using the predict function to make my forecasts. I have coded this in an R loop, where I also try to assign each forecast to a matrix. My code is the following:
EUR/GBP_RGV_5`+data.estimateI am trying to calculate realized volatility forecasts using a rolling window forecast. My aim is to use the first 500 observations to forecast the 501st observations, then shift the window forward one step using observations 2 to 501 to predict the 502nd observation. I want this to repeat until I have a complete pseudo out-of-sample forecast.
My df contains 2411 observations of 23 variables, here is small example:
Date
EUR/GBP_RV t+1
EUR/GBP_RV
EUR/GBP_RV_5
EUR/GBP_RV_22
2012-02-13
0.004019947
0.004467109
0.004995980
0.005150602
2012-02-14
0.004077322
0.004019947
0.004704742
0.005099209
2012-02-15
0.004666244
0.004077322
0.004564522
0.005020790
2012-02-16
0.004582351
0.004666244
0.004532930
0.005011078
2012-02-17
0.003951071
0.004582351
0.004362595
0.004999634
2012-02-21
0.005549329
0.004824547
0.004467109
0.004954358
The head of the df can be reproduced with
structure(list(Date = structure(c(15383, 15384, 15385, 15386,
15387, 15391), class = "Date"), `EUR/GBP_RV t+1,t+22` = c(0.00437808494654599,
0.00439764887779732, 0.00441997330738947, 0.00437799055732722,
0.00435021150904479, 0.00434881306458859), `EUR/GBP_RGV t+1,t+22` = c(0.00310674728131117,
0.00311502965608506, 0.00313756204195853, 0.00312923997431178,
0.00310846773074243, 0.00309755540903969), `EUR/GBP_RBV t+1,t+22` = c(0.00304961980133602,
0.00306866297401415, 0.00307794319983677, 0.00302801249035602,
0.00300946121851254, 0.00302272755554915), `EUR/GBP_RV t+1,t+5` = c(0.00425938711995146,
0.00442030721926592, 0.00471470868108043, 0.00487869292442023,
0.00476849421943949, 0.0046067439660438), `EUR/GBP_RGV t+1,t+5` = c(0.00287718093809447,
0.00311308998902836, 0.00344398536439729, 0.00376911066284235,
0.00377425759242542, 0.00353909902900148), `EUR/GBP_RBV t+1,t+5` = c(0.00313771439501486,
0.00310626895475871, 0.0031789431316576, 0.00305962424370556,
0.00288671182187571, 0.00291630955829613), `EUR/GBP_RV t+1` = c(0.00401994700051122,
0.00407732180013827, 0.00466624428620966, 0.00458235106134663,
0.00395107145155152, 0.00554932910921084), `EUR/GBP_RGV t+1` = c(0.00280067842079775,
0.00275522601341373, 0.00296142025653418, 0.00320716195737542,
0.00266141804235125, 0.00440970289025837), `EUR/GBP_RBV t+1` = c(0.00288377777753365,
0.00300554199386584, 0.00360608177982326, 0.00327292734850446,
0.0029202430753471, 0.00336891287836027), `EUR/GBP_RV` = c(0.00446710941914797,
0.00401994700051122, 0.00407732180013827, 0.00466624428620966,
0.00458235106134663, 0.00482454749708351), `EUR/GBP_RV_5` = c(0.00499598016427624,
0.00470474196716823, 0.00456452150727461, 0.00453292965488229,
0.00436259471347075, 0.00442030721926592), `EUR/GBP_RV_22` = c(0.00515060219897263,
0.00509920878086075, 0.00502079002092667, 0.00501107755050095,
0.00499963428727425, 0.00495435807685843), `EUR/GBP_RBV` = c(0.00324667045338159,
0.00288377777753365, 0.00300554199386584, 0.00360608177982326,
0.00327292734850446, 0.00272655057625291), `EUR/GBP_RBV_5` = c(0.0034985439252634,
0.00318731350301598, 0.00319529774619179, 0.0032799330165155,
0.00320299987062176, 0.00310626895475871), `EUR/GBP_RBV_22` = c(0.0036581887941976,
0.00362298829344015, 0.00355498498935768, 0.0035465419934449,
0.00355752455210586, 0.00351669973034298), `EUR/GBP_RGV` = c(0.00306825643155514,
0.00280067842079775, 0.00275522601341373, 0.00296142025653418,
0.00320716195737542, 0.00398022367546721), `EUR/GBP_RGV_5` = c(0.00353290218424469,
0.00345194162523714, 0.00325362896209417, 0.00312087362386985,
0.00295854861593525, 0.00311308998902836), `EUR/GBP_RGV_22` = c(0.00359974659692405,
0.00356342531619103, 0.00352224165959556, 0.00351722666683608,
0.00349184335907274, 0.00346394410318992), `EUR/GBP_TotalCount` = structure(c(-0.179518680545716,
-0.0757259172924681, 0.333514120677483, 0.759064450015801, -0.419724789788948,
-0.360414639358521), .Dim = c(6L, 1L)), `EUR/GBP_BloombergCount` = structure(c(-0.701694550941621,
-0.669811381311996, -0.574161872423118, -0.644304845608295, -0.784590791978649,
-0.631551577756444), .Dim = c(6L, 1L)), `EUR/GBP_SocialMediaCount` = structure(c(-1.68861759789696,
-1.66829994393287, -1.5910928588693, -1.59515638966212, -1.6967446594826,
-1.63172816679749), .Dim = c(6L, 1L)), `EUR/GBP_NewsCount` = structure(c(0.76560533722738,
0.879161625683434, 1.33717198912285, 1.90306082659552, 0.487392430510049,
0.487392430510049), .Dim = c(6L, 1L))), na.action = structure(c(`6` = 6L,
`38` = 38L, `74` = 74L, `101` = 101L, `140` = 140L, `165` = 165L,
`189` = 189L, `197` = 197L, `236` = 236L, `256` = 256L, `323` = 323L,
`351` = 351L, `393` = 393L, `423` = 423L, `442` = 442L, `455` = 455L,
`490` = 490L, `510` = 510L, `551` = 551L, `576` = 576L, `605` = 605L,
`646` = 646L, `676` = 676L, `696` = 696L, `708` = 708L, `742` = 742L,
`762` = 762L, `793` = 793L, `829` = 829L, `858` = 858L, `904` = 904L,
`929` = 929L, `950` = 950L, `961` = 961L, `996` = 996L, `1016` = 1016L,
`1089` = 1089L, `1114` = 1114L, `1159` = 1159L, `1184` = 1184L,
`1207` = 1207L, `1216` = 1216L, `1238` = 1238L, `1243` = 1243L,
`1253` = 1253L, `1278` = 1278L, `1315` = 1315L, `1346` = 1346L,
`1372` = 1372L, `1416` = 1416L, `1441` = 1441L, `1473` = 1473L,
`1532` = 1532L, `1599` = 1599L, `1626` = 1626L, `1669` = 1669L,
`1694` = 1694L, `1718` = 1718L, `1726` = 1726L, `1766` = 1766L,
`1786` = 1786L, `1827` = 1827L, `1853` = 1853L, `1881` = 1881L,
`1922` = 1922L, `1952` = 1952L, `1971` = 1971L, `1984` = 1984L,
`2019` = 2019L, `2039` = 2039L, `2075` = 2075L, `2106` = 2106L,
`2135` = 2135L, `2181` = 2181L, `2206` = 2206L, `2227` = 2227L,
`2238` = 2238L, `2273` = 2273L, `2293` = 2293L, `2325` = 2325L,
`2366` = 2366L, `2391` = 2391L, `2436` = 2436L, `2461` = 2461L,
`2483` = 2483L, `2493` = 2493L), class = "omit"), row.names = c(1L,
2L, 3L, 4L, 5L, 7L), class = "data.frame")
I have built 9 regression models per forecast horizon (t+1, t+5 and t+22) and I am using the predict function to make my forecasts. I have coded this in an R loop, where I also try to assign each forecast to a matrix. My code is the following:
EUR/GBP_RGV_22`)
EURGBP_HAR_RVG_NT_train <- lm(data.estimateI am trying to calculate realized volatility forecasts using a rolling window forecast. My aim is to use the first 500 observations to forecast the 501st observations, then shift the window forward one step using observations 2 to 501 to predict the 502nd observation. I want this to repeat until I have a complete pseudo out-of-sample forecast.
My df contains 2411 observations of 23 variables, here is small example:
Date
EUR/GBP_RV t+1
EUR/GBP_RV
EUR/GBP_RV_5
EUR/GBP_RV_22
2012-02-13
0.004019947
0.004467109
0.004995980
0.005150602
2012-02-14
0.004077322
0.004019947
0.004704742
0.005099209
2012-02-15
0.004666244
0.004077322
0.004564522
0.005020790
2012-02-16
0.004582351
0.004666244
0.004532930
0.005011078
2012-02-17
0.003951071
0.004582351
0.004362595
0.004999634
2012-02-21
0.005549329
0.004824547
0.004467109
0.004954358
The head of the df can be reproduced with
structure(list(Date = structure(c(15383, 15384, 15385, 15386,
15387, 15391), class = "Date"), `EUR/GBP_RV t+1,t+22` = c(0.00437808494654599,
0.00439764887779732, 0.00441997330738947, 0.00437799055732722,
0.00435021150904479, 0.00434881306458859), `EUR/GBP_RGV t+1,t+22` = c(0.00310674728131117,
0.00311502965608506, 0.00313756204195853, 0.00312923997431178,
0.00310846773074243, 0.00309755540903969), `EUR/GBP_RBV t+1,t+22` = c(0.00304961980133602,
0.00306866297401415, 0.00307794319983677, 0.00302801249035602,
0.00300946121851254, 0.00302272755554915), `EUR/GBP_RV t+1,t+5` = c(0.00425938711995146,
0.00442030721926592, 0.00471470868108043, 0.00487869292442023,
0.00476849421943949, 0.0046067439660438), `EUR/GBP_RGV t+1,t+5` = c(0.00287718093809447,
0.00311308998902836, 0.00344398536439729, 0.00376911066284235,
0.00377425759242542, 0.00353909902900148), `EUR/GBP_RBV t+1,t+5` = c(0.00313771439501486,
0.00310626895475871, 0.0031789431316576, 0.00305962424370556,
0.00288671182187571, 0.00291630955829613), `EUR/GBP_RV t+1` = c(0.00401994700051122,
0.00407732180013827, 0.00466624428620966, 0.00458235106134663,
0.00395107145155152, 0.00554932910921084), `EUR/GBP_RGV t+1` = c(0.00280067842079775,
0.00275522601341373, 0.00296142025653418, 0.00320716195737542,
0.00266141804235125, 0.00440970289025837), `EUR/GBP_RBV t+1` = c(0.00288377777753365,
0.00300554199386584, 0.00360608177982326, 0.00327292734850446,
0.0029202430753471, 0.00336891287836027), `EUR/GBP_RV` = c(0.00446710941914797,
0.00401994700051122, 0.00407732180013827, 0.00466624428620966,
0.00458235106134663, 0.00482454749708351), `EUR/GBP_RV_5` = c(0.00499598016427624,
0.00470474196716823, 0.00456452150727461, 0.00453292965488229,
0.00436259471347075, 0.00442030721926592), `EUR/GBP_RV_22` = c(0.00515060219897263,
0.00509920878086075, 0.00502079002092667, 0.00501107755050095,
0.00499963428727425, 0.00495435807685843), `EUR/GBP_RBV` = c(0.00324667045338159,
0.00288377777753365, 0.00300554199386584, 0.00360608177982326,
0.00327292734850446, 0.00272655057625291), `EUR/GBP_RBV_5` = c(0.0034985439252634,
0.00318731350301598, 0.00319529774619179, 0.0032799330165155,
0.00320299987062176, 0.00310626895475871), `EUR/GBP_RBV_22` = c(0.0036581887941976,
0.00362298829344015, 0.00355498498935768, 0.0035465419934449,
0.00355752455210586, 0.00351669973034298), `EUR/GBP_RGV` = c(0.00306825643155514,
0.00280067842079775, 0.00275522601341373, 0.00296142025653418,
0.00320716195737542, 0.00398022367546721), `EUR/GBP_RGV_5` = c(0.00353290218424469,
0.00345194162523714, 0.00325362896209417, 0.00312087362386985,
0.00295854861593525, 0.00311308998902836), `EUR/GBP_RGV_22` = c(0.00359974659692405,
0.00356342531619103, 0.00352224165959556, 0.00351722666683608,
0.00349184335907274, 0.00346394410318992), `EUR/GBP_TotalCount` = structure(c(-0.179518680545716,
-0.0757259172924681, 0.333514120677483, 0.759064450015801, -0.419724789788948,
-0.360414639358521), .Dim = c(6L, 1L)), `EUR/GBP_BloombergCount` = structure(c(-0.701694550941621,
-0.669811381311996, -0.574161872423118, -0.644304845608295, -0.784590791978649,
-0.631551577756444), .Dim = c(6L, 1L)), `EUR/GBP_SocialMediaCount` = structure(c(-1.68861759789696,
-1.66829994393287, -1.5910928588693, -1.59515638966212, -1.6967446594826,
-1.63172816679749), .Dim = c(6L, 1L)), `EUR/GBP_NewsCount` = structure(c(0.76560533722738,
0.879161625683434, 1.33717198912285, 1.90306082659552, 0.487392430510049,
0.487392430510049), .Dim = c(6L, 1L))), na.action = structure(c(`6` = 6L,
`38` = 38L, `74` = 74L, `101` = 101L, `140` = 140L, `165` = 165L,
`189` = 189L, `197` = 197L, `236` = 236L, `256` = 256L, `323` = 323L,
`351` = 351L, `393` = 393L, `423` = 423L, `442` = 442L, `455` = 455L,
`490` = 490L, `510` = 510L, `551` = 551L, `576` = 576L, `605` = 605L,
`646` = 646L, `676` = 676L, `696` = 696L, `708` = 708L, `742` = 742L,
`762` = 762L, `793` = 793L, `829` = 829L, `858` = 858L, `904` = 904L,
`929` = 929L, `950` = 950L, `961` = 961L, `996` = 996L, `1016` = 1016L,
`1089` = 1089L, `1114` = 1114L, `1159` = 1159L, `1184` = 1184L,
`1207` = 1207L, `1216` = 1216L, `1238` = 1238L, `1243` = 1243L,
`1253` = 1253L, `1278` = 1278L, `1315` = 1315L, `1346` = 1346L,
`1372` = 1372L, `1416` = 1416L, `1441` = 1441L, `1473` = 1473L,
`1532` = 1532L, `1599` = 1599L, `1626` = 1626L, `1669` = 1669L,
`1694` = 1694L, `1718` = 1718L, `1726` = 1726L, `1766` = 1766L,
`1786` = 1786L, `1827` = 1827L, `1853` = 1853L, `1881` = 1881L,
`1922` = 1922L, `1952` = 1952L, `1971` = 1971L, `1984` = 1984L,
`2019` = 2019L, `2039` = 2039L, `2075` = 2075L, `2106` = 2106L,
`2135` = 2135L, `2181` = 2181L, `2206` = 2206L, `2227` = 2227L,
`2238` = 2238L, `2273` = 2273L, `2293` = 2293L, `2325` = 2325L,
`2366` = 2366L, `2391` = 2391L, `2436` = 2436L, `2461` = 2461L,
`2483` = 2483L, `2493` = 2493L), class = "omit"), row.names = c(1L,
2L, 3L, 4L, 5L, 7L), class = "data.frame")
I have built 9 regression models per forecast horizon (t+1, t+5 and t+22) and I am using the predict function to make my forecasts. I have coded this in an R loop, where I also try to assign each forecast to a matrix. My code is the following:
EUR/GBP_RGV t+1`~data.estimateI am trying to calculate realized volatility forecasts using a rolling window forecast. My aim is to use the first 500 observations to forecast the 501st observations, then shift the window forward one step using observations 2 to 501 to predict the 502nd observation. I want this to repeat until I have a complete pseudo out-of-sample forecast.
My df contains 2411 observations of 23 variables, here is small example:
Date
EUR/GBP_RV t+1
EUR/GBP_RV
EUR/GBP_RV_5
EUR/GBP_RV_22
2012-02-13
0.004019947
0.004467109
0.004995980
0.005150602
2012-02-14
0.004077322
0.004019947
0.004704742
0.005099209
2012-02-15
0.004666244
0.004077322
0.004564522
0.005020790
2012-02-16
0.004582351
0.004666244
0.004532930
0.005011078
2012-02-17
0.003951071
0.004582351
0.004362595
0.004999634
2012-02-21
0.005549329
0.004824547
0.004467109
0.004954358
The head of the df can be reproduced with
structure(list(Date = structure(c(15383, 15384, 15385, 15386,
15387, 15391), class = "Date"), `EUR/GBP_RV t+1,t+22` = c(0.00437808494654599,
0.00439764887779732, 0.00441997330738947, 0.00437799055732722,
0.00435021150904479, 0.00434881306458859), `EUR/GBP_RGV t+1,t+22` = c(0.00310674728131117,
0.00311502965608506, 0.00313756204195853, 0.00312923997431178,
0.00310846773074243, 0.00309755540903969), `EUR/GBP_RBV t+1,t+22` = c(0.00304961980133602,
0.00306866297401415, 0.00307794319983677, 0.00302801249035602,
0.00300946121851254, 0.00302272755554915), `EUR/GBP_RV t+1,t+5` = c(0.00425938711995146,
0.00442030721926592, 0.00471470868108043, 0.00487869292442023,
0.00476849421943949, 0.0046067439660438), `EUR/GBP_RGV t+1,t+5` = c(0.00287718093809447,
0.00311308998902836, 0.00344398536439729, 0.00376911066284235,
0.00377425759242542, 0.00353909902900148), `EUR/GBP_RBV t+1,t+5` = c(0.00313771439501486,
0.00310626895475871, 0.0031789431316576, 0.00305962424370556,
0.00288671182187571, 0.00291630955829613), `EUR/GBP_RV t+1` = c(0.00401994700051122,
0.00407732180013827, 0.00466624428620966, 0.00458235106134663,
0.00395107145155152, 0.00554932910921084), `EUR/GBP_RGV t+1` = c(0.00280067842079775,
0.00275522601341373, 0.00296142025653418, 0.00320716195737542,
0.00266141804235125, 0.00440970289025837), `EUR/GBP_RBV t+1` = c(0.00288377777753365,
0.00300554199386584, 0.00360608177982326, 0.00327292734850446,
0.0029202430753471, 0.00336891287836027), `EUR/GBP_RV` = c(0.00446710941914797,
0.00401994700051122, 0.00407732180013827, 0.00466624428620966,
0.00458235106134663, 0.00482454749708351), `EUR/GBP_RV_5` = c(0.00499598016427624,
0.00470474196716823, 0.00456452150727461, 0.00453292965488229,
0.00436259471347075, 0.00442030721926592), `EUR/GBP_RV_22` = c(0.00515060219897263,
0.00509920878086075, 0.00502079002092667, 0.00501107755050095,
0.00499963428727425, 0.00495435807685843), `EUR/GBP_RBV` = c(0.00324667045338159,
0.00288377777753365, 0.00300554199386584, 0.00360608177982326,
0.00327292734850446, 0.00272655057625291), `EUR/GBP_RBV_5` = c(0.0034985439252634,
0.00318731350301598, 0.00319529774619179, 0.0032799330165155,
0.00320299987062176, 0.00310626895475871), `EUR/GBP_RBV_22` = c(0.0036581887941976,
0.00362298829344015, 0.00355498498935768, 0.0035465419934449,
0.00355752455210586, 0.00351669973034298), `EUR/GBP_RGV` = c(0.00306825643155514,
0.00280067842079775, 0.00275522601341373, 0.00296142025653418,
0.00320716195737542, 0.00398022367546721), `EUR/GBP_RGV_5` = c(0.00353290218424469,
0.00345194162523714, 0.00325362896209417, 0.00312087362386985,
0.00295854861593525, 0.00311308998902836), `EUR/GBP_RGV_22` = c(0.00359974659692405,
0.00356342531619103, 0.00352224165959556, 0.00351722666683608,
0.00349184335907274, 0.00346394410318992), `EUR/GBP_TotalCount` = structure(c(-0.179518680545716,
-0.0757259172924681, 0.333514120677483, 0.759064450015801, -0.419724789788948,
-0.360414639358521), .Dim = c(6L, 1L)), `EUR/GBP_BloombergCount` = structure(c(-0.701694550941621,
-0.669811381311996, -0.574161872423118, -0.644304845608295, -0.784590791978649,
-0.631551577756444), .Dim = c(6L, 1L)), `EUR/GBP_SocialMediaCount` = structure(c(-1.68861759789696,
-1.66829994393287, -1.5910928588693, -1.59515638966212, -1.6967446594826,
-1.63172816679749), .Dim = c(6L, 1L)), `EUR/GBP_NewsCount` = structure(c(0.76560533722738,
0.879161625683434, 1.33717198912285, 1.90306082659552, 0.487392430510049,
0.487392430510049), .Dim = c(6L, 1L))), na.action = structure(c(`6` = 6L,
`38` = 38L, `74` = 74L, `101` = 101L, `140` = 140L, `165` = 165L,
`189` = 189L, `197` = 197L, `236` = 236L, `256` = 256L, `323` = 323L,
`351` = 351L, `393` = 393L, `423` = 423L, `442` = 442L, `455` = 455L,
`490` = 490L, `510` = 510L, `551` = 551L, `576` = 576L, `605` = 605L,
`646` = 646L, `676` = 676L, `696` = 696L, `708` = 708L, `742` = 742L,
`762` = 762L, `793` = 793L, `829` = 829L, `858` = 858L, `904` = 904L,
`929` = 929L, `950` = 950L, `961` = 961L, `996` = 996L, `1016` = 1016L,
`1089` = 1089L, `1114` = 1114L, `1159` = 1159L, `1184` = 1184L,
`1207` = 1207L, `1216` = 1216L, `1238` = 1238L, `1243` = 1243L,
`1253` = 1253L, `1278` = 1278L, `1315` = 1315L, `1346` = 1346L,
`1372` = 1372L, `1416` = 1416L, `1441` = 1441L, `1473` = 1473L,
`1532` = 1532L, `1599` = 1599L, `1626` = 1626L, `1669` = 1669L,
`1694` = 1694L, `1718` = 1718L, `1726` = 1726L, `1766` = 1766L,
`1786` = 1786L, `1827` = 1827L, `1853` = 1853L, `1881` = 1881L,
`1922` = 1922L, `1952` = 1952L, `1971` = 1971L, `1984` = 1984L,
`2019` = 2019L, `2039` = 2039L, `2075` = 2075L, `2106` = 2106L,
`2135` = 2135L, `2181` = 2181L, `2206` = 2206L, `2227` = 2227L,
`2238` = 2238L, `2273` = 2273L, `2293` = 2293L, `2325` = 2325L,
`2366` = 2366L, `2391` = 2391L, `2436` = 2436L, `2461` = 2461L,
`2483` = 2483L, `2493` = 2493L), class = "omit"), row.names = c(1L,
2L, 3L, 4L, 5L, 7L), class = "data.frame")
I have built 9 regression models per forecast horizon (t+1, t+5 and t+22) and I am using the predict function to make my forecasts. I have coded this in an R loop, where I also try to assign each forecast to a matrix. My code is the following:
EUR/GBP_RGV`+data.estimateI am trying to calculate realized volatility forecasts using a rolling window forecast. My aim is to use the first 500 observations to forecast the 501st observations, then shift the window forward one step using observations 2 to 501 to predict the 502nd observation. I want this to repeat until I have a complete pseudo out-of-sample forecast.
My df contains 2411 observations of 23 variables, here is small example:
Date
EUR/GBP_RV t+1
EUR/GBP_RV
EUR/GBP_RV_5
EUR/GBP_RV_22
2012-02-13
0.004019947
0.004467109
0.004995980
0.005150602
2012-02-14
0.004077322
0.004019947
0.004704742
0.005099209
2012-02-15
0.004666244
0.004077322
0.004564522
0.005020790
2012-02-16
0.004582351
0.004666244
0.004532930
0.005011078
2012-02-17
0.003951071
0.004582351
0.004362595
0.004999634
2012-02-21
0.005549329
0.004824547
0.004467109
0.004954358
The head of the df can be reproduced with
structure(list(Date = structure(c(15383, 15384, 15385, 15386,
15387, 15391), class = "Date"), `EUR/GBP_RV t+1,t+22` = c(0.00437808494654599,
0.00439764887779732, 0.00441997330738947, 0.00437799055732722,
0.00435021150904479, 0.00434881306458859), `EUR/GBP_RGV t+1,t+22` = c(0.00310674728131117,
0.00311502965608506, 0.00313756204195853, 0.00312923997431178,
0.00310846773074243, 0.00309755540903969), `EUR/GBP_RBV t+1,t+22` = c(0.00304961980133602,
0.00306866297401415, 0.00307794319983677, 0.00302801249035602,
0.00300946121851254, 0.00302272755554915), `EUR/GBP_RV t+1,t+5` = c(0.00425938711995146,
0.00442030721926592, 0.00471470868108043, 0.00487869292442023,
0.00476849421943949, 0.0046067439660438), `EUR/GBP_RGV t+1,t+5` = c(0.00287718093809447,
0.00311308998902836, 0.00344398536439729, 0.00376911066284235,
0.00377425759242542, 0.00353909902900148), `EUR/GBP_RBV t+1,t+5` = c(0.00313771439501486,
0.00310626895475871, 0.0031789431316576, 0.00305962424370556,
0.00288671182187571, 0.00291630955829613), `EUR/GBP_RV t+1` = c(0.00401994700051122,
0.00407732180013827, 0.00466624428620966, 0.00458235106134663,
0.00395107145155152, 0.00554932910921084), `EUR/GBP_RGV t+1` = c(0.00280067842079775,
0.00275522601341373, 0.00296142025653418, 0.00320716195737542,
0.00266141804235125, 0.00440970289025837), `EUR/GBP_RBV t+1` = c(0.00288377777753365,
0.00300554199386584, 0.00360608177982326, 0.00327292734850446,
0.0029202430753471, 0.00336891287836027), `EUR/GBP_RV` = c(0.00446710941914797,
0.00401994700051122, 0.00407732180013827, 0.00466624428620966,
0.00458235106134663, 0.00482454749708351), `EUR/GBP_RV_5` = c(0.00499598016427624,
0.00470474196716823, 0.00456452150727461, 0.00453292965488229,
0.00436259471347075, 0.00442030721926592), `EUR/GBP_RV_22` = c(0.00515060219897263,
0.00509920878086075, 0.00502079002092667, 0.00501107755050095,
0.00499963428727425, 0.00495435807685843), `EUR/GBP_RBV` = c(0.00324667045338159,
0.00288377777753365, 0.00300554199386584, 0.00360608177982326,
0.00327292734850446, 0.00272655057625291), `EUR/GBP_RBV_5` = c(0.0034985439252634,
0.00318731350301598, 0.00319529774619179, 0.0032799330165155,
0.00320299987062176, 0.00310626895475871), `EUR/GBP_RBV_22` = c(0.0036581887941976,
0.00362298829344015, 0.00355498498935768, 0.0035465419934449,
0.00355752455210586, 0.00351669973034298), `EUR/GBP_RGV` = c(0.00306825643155514,
0.00280067842079775, 0.00275522601341373, 0.00296142025653418,
0.00320716195737542, 0.00398022367546721), `EUR/GBP_RGV_5` = c(0.00353290218424469,
0.00345194162523714, 0.00325362896209417, 0.00312087362386985,
0.00295854861593525, 0.00311308998902836), `EUR/GBP_RGV_22` = c(0.00359974659692405,
0.00356342531619103, 0.00352224165959556, 0.00351722666683608,
0.00349184335907274, 0.00346394410318992), `EUR/GBP_TotalCount` = structure(c(-0.179518680545716,
-0.0757259172924681, 0.333514120677483, 0.759064450015801, -0.419724789788948,
-0.360414639358521), .Dim = c(6L, 1L)), `EUR/GBP_BloombergCount` = structure(c(-0.701694550941621,
-0.669811381311996, -0.574161872423118, -0.644304845608295, -0.784590791978649,
-0.631551577756444), .Dim = c(6L, 1L)), `EUR/GBP_SocialMediaCount` = structure(c(-1.68861759789696,
-1.66829994393287, -1.5910928588693, -1.59515638966212, -1.6967446594826,
-1.63172816679749), .Dim = c(6L, 1L)), `EUR/GBP_NewsCount` = structure(c(0.76560533722738,
0.879161625683434, 1.33717198912285, 1.90306082659552, 0.487392430510049,
0.487392430510049), .Dim = c(6L, 1L))), na.action = structure(c(`6` = 6L,
`38` = 38L, `74` = 74L, `101` = 101L, `140` = 140L, `165` = 165L,
`189` = 189L, `197` = 197L, `236` = 236L, `256` = 256L, `323` = 323L,
`351` = 351L, `393` = 393L, `423` = 423L, `442` = 442L, `455` = 455L,
`490` = 490L, `510` = 510L, `551` = 551L, `576` = 576L, `605` = 605L,
`646` = 646L, `676` = 676L, `696` = 696L, `708` = 708L, `742` = 742L,
`762` = 762L, `793` = 793L, `829` = 829L, `858` = 858L, `904` = 904L,
`929` = 929L, `950` = 950L, `961` = 961L, `996` = 996L, `1016` = 1016L,
`1089` = 1089L, `1114` = 1114L, `1159` = 1159L, `1184` = 1184L,
`1207` = 1207L, `1216` = 1216L, `1238` = 1238L, `1243` = 1243L,
`1253` = 1253L, `1278` = 1278L, `1315` = 1315L, `1346` = 1346L,
`1372` = 1372L, `1416` = 1416L, `1441` = 1441L, `1473` = 1473L,
`1532` = 1532L, `1599` = 1599L, `1626` = 1626L, `1669` = 1669L,
`1694` = 1694L, `1718` = 1718L, `1726` = 1726L, `1766` = 1766L,
`1786` = 1786L, `1827` = 1827L, `1853` = 1853L, `1881` = 1881L,
`1922` = 1922L, `1952` = 1952L, `1971` = 1971L, `1984` = 1984L,
`2019` = 2019L, `2039` = 2039L, `2075` = 2075L, `2106` = 2106L,
`2135` = 2135L, `2181` = 2181L, `2206` = 2206L, `2227` = 2227L,
`2238` = 2238L, `2273` = 2273L, `2293` = 2293L, `2325` = 2325L,
`2366` = 2366L, `2391` = 2391L, `2436` = 2436L, `2461` = 2461L,
`2483` = 2483L, `2493` = 2493L), class = "omit"), row.names = c(1L,
2L, 3L, 4L, 5L, 7L), class = "data.frame")
I have built 9 regression models per forecast horizon (t+1, t+5 and t+22) and I am using the predict function to make my forecasts. I have coded this in an R loop, where I also try to assign each forecast to a matrix. My code is the following:
EUR/GBP_RGV_5`+data.estimateI am trying to calculate realized volatility forecasts using a rolling window forecast. My aim is to use the first 500 observations to forecast the 501st observations, then shift the window forward one step using observations 2 to 501 to predict the 502nd observation. I want this to repeat until I have a complete pseudo out-of-sample forecast.
My df contains 2411 observations of 23 variables, here is small example:
Date
EUR/GBP_RV t+1
EUR/GBP_RV
EUR/GBP_RV_5
EUR/GBP_RV_22
2012-02-13
0.004019947
0.004467109
0.004995980
0.005150602
2012-02-14
0.004077322
0.004019947
0.004704742
0.005099209
2012-02-15
0.004666244
0.004077322
0.004564522
0.005020790
2012-02-16
0.004582351
0.004666244
0.004532930
0.005011078
2012-02-17
0.003951071
0.004582351
0.004362595
0.004999634
2012-02-21
0.005549329
0.004824547
0.004467109
0.004954358
The head of the df can be reproduced with
structure(list(Date = structure(c(15383, 15384, 15385, 15386,
15387, 15391), class = "Date"), `EUR/GBP_RV t+1,t+22` = c(0.00437808494654599,
0.00439764887779732, 0.00441997330738947, 0.00437799055732722,
0.00435021150904479, 0.00434881306458859), `EUR/GBP_RGV t+1,t+22` = c(0.00310674728131117,
0.00311502965608506, 0.00313756204195853, 0.00312923997431178,
0.00310846773074243, 0.00309755540903969), `EUR/GBP_RBV t+1,t+22` = c(0.00304961980133602,
0.00306866297401415, 0.00307794319983677, 0.00302801249035602,
0.00300946121851254, 0.00302272755554915), `EUR/GBP_RV t+1,t+5` = c(0.00425938711995146,
0.00442030721926592, 0.00471470868108043, 0.00487869292442023,
0.00476849421943949, 0.0046067439660438), `EUR/GBP_RGV t+1,t+5` = c(0.00287718093809447,
0.00311308998902836, 0.00344398536439729, 0.00376911066284235,
0.00377425759242542, 0.00353909902900148), `EUR/GBP_RBV t+1,t+5` = c(0.00313771439501486,
0.00310626895475871, 0.0031789431316576, 0.00305962424370556,
0.00288671182187571, 0.00291630955829613), `EUR/GBP_RV t+1` = c(0.00401994700051122,
0.00407732180013827, 0.00466624428620966, 0.00458235106134663,
0.00395107145155152, 0.00554932910921084), `EUR/GBP_RGV t+1` = c(0.00280067842079775,
0.00275522601341373, 0.00296142025653418, 0.00320716195737542,
0.00266141804235125, 0.00440970289025837), `EUR/GBP_RBV t+1` = c(0.00288377777753365,
0.00300554199386584, 0.00360608177982326, 0.00327292734850446,
0.0029202430753471, 0.00336891287836027), `EUR/GBP_RV` = c(0.00446710941914797,
0.00401994700051122, 0.00407732180013827, 0.00466624428620966,
0.00458235106134663, 0.00482454749708351), `EUR/GBP_RV_5` = c(0.00499598016427624,
0.00470474196716823, 0.00456452150727461, 0.00453292965488229,
0.00436259471347075, 0.00442030721926592), `EUR/GBP_RV_22` = c(0.00515060219897263,
0.00509920878086075, 0.00502079002092667, 0.00501107755050095,
0.00499963428727425, 0.00495435807685843), `EUR/GBP_RBV` = c(0.00324667045338159,
0.00288377777753365, 0.00300554199386584, 0.00360608177982326,
0.00327292734850446, 0.00272655057625291), `EUR/GBP_RBV_5` = c(0.0034985439252634,
0.00318731350301598, 0.00319529774619179, 0.0032799330165155,
0.00320299987062176, 0.00310626895475871), `EUR/GBP_RBV_22` = c(0.0036581887941976,
0.00362298829344015, 0.00355498498935768, 0.0035465419934449,
0.00355752455210586, 0.00351669973034298), `EUR/GBP_RGV` = c(0.00306825643155514,
0.00280067842079775, 0.00275522601341373, 0.00296142025653418,
0.00320716195737542, 0.00398022367546721), `EUR/GBP_RGV_5` = c(0.00353290218424469,
0.00345194162523714, 0.00325362896209417, 0.00312087362386985,
0.00295854861593525, 0.00311308998902836), `EUR/GBP_RGV_22` = c(0.00359974659692405,
0.00356342531619103, 0.00352224165959556, 0.00351722666683608,
0.00349184335907274, 0.00346394410318992), `EUR/GBP_TotalCount` = structure(c(-0.179518680545716,
-0.0757259172924681, 0.333514120677483, 0.759064450015801, -0.419724789788948,
-0.360414639358521), .Dim = c(6L, 1L)), `EUR/GBP_BloombergCount` = structure(c(-0.701694550941621,
-0.669811381311996, -0.574161872423118, -0.644304845608295, -0.784590791978649,
-0.631551577756444), .Dim = c(6L, 1L)), `EUR/GBP_SocialMediaCount` = structure(c(-1.68861759789696,
-1.66829994393287, -1.5910928588693, -1.59515638966212, -1.6967446594826,
-1.63172816679749), .Dim = c(6L, 1L)), `EUR/GBP_NewsCount` = structure(c(0.76560533722738,
0.879161625683434, 1.33717198912285, 1.90306082659552, 0.487392430510049,
0.487392430510049), .Dim = c(6L, 1L))), na.action = structure(c(`6` = 6L,
`38` = 38L, `74` = 74L, `101` = 101L, `140` = 140L, `165` = 165L,
`189` = 189L, `197` = 197L, `236` = 236L, `256` = 256L, `323` = 323L,
`351` = 351L, `393` = 393L, `423` = 423L, `442` = 442L, `455` = 455L,
`490` = 490L, `510` = 510L, `551` = 551L, `576` = 576L, `605` = 605L,
`646` = 646L, `676` = 676L, `696` = 696L, `708` = 708L, `742` = 742L,
`762` = 762L, `793` = 793L, `829` = 829L, `858` = 858L, `904` = 904L,
`929` = 929L, `950` = 950L, `961` = 961L, `996` = 996L, `1016` = 1016L,
`1089` = 1089L, `1114` = 1114L, `1159` = 1159L, `1184` = 1184L,
`1207` = 1207L, `1216` = 1216L, `1238` = 1238L, `1243` = 1243L,
`1253` = 1253L, `1278` = 1278L, `1315` = 1315L, `1346` = 1346L,
`1372` = 1372L, `1416` = 1416L, `1441` = 1441L, `1473` = 1473L,
`1532` = 1532L, `1599` = 1599L, `1626` = 1626L, `1669` = 1669L,
`1694` = 1694L, `1718` = 1718L, `1726` = 1726L, `1766` = 1766L,
`1786` = 1786L, `1827` = 1827L, `1853` = 1853L, `1881` = 1881L,
`1922` = 1922L, `1952` = 1952L, `1971` = 1971L, `1984` = 1984L,
`2019` = 2019L, `2039` = 2039L, `2075` = 2075L, `2106` = 2106L,
`2135` = 2135L, `2181` = 2181L, `2206` = 2206L, `2227` = 2227L,
`2238` = 2238L, `2273` = 2273L, `2293` = 2293L, `2325` = 2325L,
`2366` = 2366L, `2391` = 2391L, `2436` = 2436L, `2461` = 2461L,
`2483` = 2483L, `2493` = 2493L), class = "omit"), row.names = c(1L,
2L, 3L, 4L, 5L, 7L), class = "data.frame")
I have built 9 regression models per forecast horizon (t+1, t+5 and t+22) and I am using the predict function to make my forecasts. I have coded this in an R loop, where I also try to assign each forecast to a matrix. My code is the following:
EUR/GBP_RGV_22`+data.estimateI am trying to calculate realized volatility forecasts using a rolling window forecast. My aim is to use the first 500 observations to forecast the 501st observations, then shift the window forward one step using observations 2 to 501 to predict the 502nd observation. I want this to repeat until I have a complete pseudo out-of-sample forecast.
My df contains 2411 observations of 23 variables, here is small example:
Date
EUR/GBP_RV t+1
EUR/GBP_RV
EUR/GBP_RV_5
EUR/GBP_RV_22
2012-02-13
0.004019947
0.004467109
0.004995980
0.005150602
2012-02-14
0.004077322
0.004019947
0.004704742
0.005099209
2012-02-15
0.004666244
0.004077322
0.004564522
0.005020790
2012-02-16
0.004582351
0.004666244
0.004532930
0.005011078
2012-02-17
0.003951071
0.004582351
0.004362595
0.004999634
2012-02-21
0.005549329
0.004824547
0.004467109
0.004954358
The head of the df can be reproduced with
structure(list(Date = structure(c(15383, 15384, 15385, 15386,
15387, 15391), class = "Date"), `EUR/GBP_RV t+1,t+22` = c(0.00437808494654599,
0.00439764887779732, 0.00441997330738947, 0.00437799055732722,
0.00435021150904479, 0.00434881306458859), `EUR/GBP_RGV t+1,t+22` = c(0.00310674728131117,
0.00311502965608506, 0.00313756204195853, 0.00312923997431178,
0.00310846773074243, 0.00309755540903969), `EUR/GBP_RBV t+1,t+22` = c(0.00304961980133602,
0.00306866297401415, 0.00307794319983677, 0.00302801249035602,
0.00300946121851254, 0.00302272755554915), `EUR/GBP_RV t+1,t+5` = c(0.00425938711995146,
0.00442030721926592, 0.00471470868108043, 0.00487869292442023,
0.00476849421943949, 0.0046067439660438), `EUR/GBP_RGV t+1,t+5` = c(0.00287718093809447,
0.00311308998902836, 0.00344398536439729, 0.00376911066284235,
0.00377425759242542, 0.00353909902900148), `EUR/GBP_RBV t+1,t+5` = c(0.00313771439501486,
0.00310626895475871, 0.0031789431316576, 0.00305962424370556,
0.00288671182187571, 0.00291630955829613), `EUR/GBP_RV t+1` = c(0.00401994700051122,
0.00407732180013827, 0.00466624428620966, 0.00458235106134663,
0.00395107145155152, 0.00554932910921084), `EUR/GBP_RGV t+1` = c(0.00280067842079775,
0.00275522601341373, 0.00296142025653418, 0.00320716195737542,
0.00266141804235125, 0.00440970289025837), `EUR/GBP_RBV t+1` = c(0.00288377777753365,
0.00300554199386584, 0.00360608177982326, 0.00327292734850446,
0.0029202430753471, 0.00336891287836027), `EUR/GBP_RV` = c(0.00446710941914797,
0.00401994700051122, 0.00407732180013827, 0.00466624428620966,
0.00458235106134663, 0.00482454749708351), `EUR/GBP_RV_5` = c(0.00499598016427624,
0.00470474196716823, 0.00456452150727461, 0.00453292965488229,
0.00436259471347075, 0.00442030721926592), `EUR/GBP_RV_22` = c(0.00515060219897263,
0.00509920878086075, 0.00502079002092667, 0.00501107755050095,
0.00499963428727425, 0.00495435807685843), `EUR/GBP_RBV` = c(0.00324667045338159,
0.00288377777753365, 0.00300554199386584, 0.00360608177982326,
0.00327292734850446, 0.00272655057625291), `EUR/GBP_RBV_5` = c(0.0034985439252634,
0.00318731350301598, 0.00319529774619179, 0.0032799330165155,
0.00320299987062176, 0.00310626895475871), `EUR/GBP_RBV_22` = c(0.0036581887941976,
0.00362298829344015, 0.00355498498935768, 0.0035465419934449,
0.00355752455210586, 0.00351669973034298), `EUR/GBP_RGV` = c(0.00306825643155514,
0.00280067842079775, 0.00275522601341373, 0.00296142025653418,
0.00320716195737542, 0.00398022367546721), `EUR/GBP_RGV_5` = c(0.00353290218424469,
0.00345194162523714, 0.00325362896209417, 0.00312087362386985,
0.00295854861593525, 0.00311308998902836), `EUR/GBP_RGV_22` = c(0.00359974659692405,
0.00356342531619103, 0.00352224165959556, 0.00351722666683608,
0.00349184335907274, 0.00346394410318992), `EUR/GBP_TotalCount` = structure(c(-0.179518680545716,
-0.0757259172924681, 0.333514120677483, 0.759064450015801, -0.419724789788948,
-0.360414639358521), .Dim = c(6L, 1L)), `EUR/GBP_BloombergCount` = structure(c(-0.701694550941621,
-0.669811381311996, -0.574161872423118, -0.644304845608295, -0.784590791978649,
-0.631551577756444), .Dim = c(6L, 1L)), `EUR/GBP_SocialMediaCount` = structure(c(-1.68861759789696,
-1.66829994393287, -1.5910928588693, -1.59515638966212, -1.6967446594826,
-1.63172816679749), .Dim = c(6L, 1L)), `EUR/GBP_NewsCount` = structure(c(0.76560533722738,
0.879161625683434, 1.33717198912285, 1.90306082659552, 0.487392430510049,
0.487392430510049), .Dim = c(6L, 1L))), na.action = structure(c(`6` = 6L,
`38` = 38L, `74` = 74L, `101` = 101L, `140` = 140L, `165` = 165L,
`189` = 189L, `197` = 197L, `236` = 236L, `256` = 256L, `323` = 323L,
`351` = 351L, `393` = 393L, `423` = 423L, `442` = 442L, `455` = 455L,
`490` = 490L, `510` = 510L, `551` = 551L, `576` = 576L, `605` = 605L,
`646` = 646L, `676` = 676L, `696` = 696L, `708` = 708L, `742` = 742L,
`762` = 762L, `793` = 793L, `829` = 829L, `858` = 858L, `904` = 904L,
`929` = 929L, `950` = 950L, `961` = 961L, `996` = 996L, `1016` = 1016L,
`1089` = 1089L, `1114` = 1114L, `1159` = 1159L, `1184` = 1184L,
`1207` = 1207L, `1216` = 1216L, `1238` = 1238L, `1243` = 1243L,
`1253` = 1253L, `1278` = 1278L, `1315` = 1315L, `1346` = 1346L,
`1372` = 1372L, `1416` = 1416L, `1441` = 1441L, `1473` = 1473L,
`1532` = 1532L, `1599` = 1599L, `1626` = 1626L, `1669` = 1669L,
`1694` = 1694L, `1718` = 1718L, `1726` = 1726L, `1766` = 1766L,
`1786` = 1786L, `1827` = 1827L, `1853` = 1853L, `1881` = 1881L,
`1922` = 1922L, `1952` = 1952L, `1971` = 1971L, `1984` = 1984L,
`2019` = 2019L, `2039` = 2039L, `2075` = 2075L, `2106` = 2106L,
`2135` = 2135L, `2181` = 2181L, `2206` = 2206L, `2227` = 2227L,
`2238` = 2238L, `2273` = 2273L, `2293` = 2293L, `2325` = 2325L,
`2366` = 2366L, `2391` = 2391L, `2436` = 2436L, `2461` = 2461L,
`2483` = 2483L, `2493` = 2493L), class = "omit"), row.names = c(1L,
2L, 3L, 4L, 5L, 7L), class = "data.frame")
I have built 9 regression models per forecast horizon (t+1, t+5 and t+22) and I am using the predict function to make my forecasts. I have coded this in an R loop, where I also try to assign each forecast to a matrix. My code is the following:
EUR/GBP_TotalCount`)
EURGBP_HAR_RV_Bloomberg_train <- lm(data.estimateI am trying to calculate realized volatility forecasts using a rolling window forecast. My aim is to use the first 500 observations to forecast the 501st observations, then shift the window forward one step using observations 2 to 501 to predict the 502nd observation. I want this to repeat until I have a complete pseudo out-of-sample forecast.
My df contains 2411 observations of 23 variables, here is small example:
Date
EUR/GBP_RV t+1
EUR/GBP_RV
EUR/GBP_RV_5
EUR/GBP_RV_22
2012-02-13
0.004019947
0.004467109
0.004995980
0.005150602
2012-02-14
0.004077322
0.004019947
0.004704742
0.005099209
2012-02-15
0.004666244
0.004077322
0.004564522
0.005020790
2012-02-16
0.004582351
0.004666244
0.004532930
0.005011078
2012-02-17
0.003951071
0.004582351
0.004362595
0.004999634
2012-02-21
0.005549329
0.004824547
0.004467109
0.004954358
The head of the df can be reproduced with
structure(list(Date = structure(c(15383, 15384, 15385, 15386,
15387, 15391), class = "Date"), `EUR/GBP_RV t+1,t+22` = c(0.00437808494654599,
0.00439764887779732, 0.00441997330738947, 0.00437799055732722,
0.00435021150904479, 0.00434881306458859), `EUR/GBP_RGV t+1,t+22` = c(0.00310674728131117,
0.00311502965608506, 0.00313756204195853, 0.00312923997431178,
0.00310846773074243, 0.00309755540903969), `EUR/GBP_RBV t+1,t+22` = c(0.00304961980133602,
0.00306866297401415, 0.00307794319983677, 0.00302801249035602,
0.00300946121851254, 0.00302272755554915), `EUR/GBP_RV t+1,t+5` = c(0.00425938711995146,
0.00442030721926592, 0.00471470868108043, 0.00487869292442023,
0.00476849421943949, 0.0046067439660438), `EUR/GBP_RGV t+1,t+5` = c(0.00287718093809447,
0.00311308998902836, 0.00344398536439729, 0.00376911066284235,
0.00377425759242542, 0.00353909902900148), `EUR/GBP_RBV t+1,t+5` = c(0.00313771439501486,
0.00310626895475871, 0.0031789431316576, 0.00305962424370556,
0.00288671182187571, 0.00291630955829613), `EUR/GBP_RV t+1` = c(0.00401994700051122,
0.00407732180013827, 0.00466624428620966, 0.00458235106134663,
0.00395107145155152, 0.00554932910921084), `EUR/GBP_RGV t+1` = c(0.00280067842079775,
0.00275522601341373, 0.00296142025653418, 0.00320716195737542,
0.00266141804235125, 0.00440970289025837), `EUR/GBP_RBV t+1` = c(0.00288377777753365,
0.00300554199386584, 0.00360608177982326, 0.00327292734850446,
0.0029202430753471, 0.00336891287836027), `EUR/GBP_RV` = c(0.00446710941914797,
0.00401994700051122, 0.00407732180013827, 0.00466624428620966,
0.00458235106134663, 0.00482454749708351), `EUR/GBP_RV_5` = c(0.00499598016427624,
0.00470474196716823, 0.00456452150727461, 0.00453292965488229,
0.00436259471347075, 0.00442030721926592), `EUR/GBP_RV_22` = c(0.00515060219897263,
0.00509920878086075, 0.00502079002092667, 0.00501107755050095,
0.00499963428727425, 0.00495435807685843), `EUR/GBP_RBV` = c(0.00324667045338159,
0.00288377777753365, 0.00300554199386584, 0.00360608177982326,
0.00327292734850446, 0.00272655057625291), `EUR/GBP_RBV_5` = c(0.0034985439252634,
0.00318731350301598, 0.00319529774619179, 0.0032799330165155,
0.00320299987062176, 0.00310626895475871), `EUR/GBP_RBV_22` = c(0.0036581887941976,
0.00362298829344015, 0.00355498498935768, 0.0035465419934449,
0.00355752455210586, 0.00351669973034298), `EUR/GBP_RGV` = c(0.00306825643155514,
0.00280067842079775, 0.00275522601341373, 0.00296142025653418,
0.00320716195737542, 0.00398022367546721), `EUR/GBP_RGV_5` = c(0.00353290218424469,
0.00345194162523714, 0.00325362896209417, 0.00312087362386985,
0.00295854861593525, 0.00311308998902836), `EUR/GBP_RGV_22` = c(0.00359974659692405,
0.00356342531619103, 0.00352224165959556, 0.00351722666683608,
0.00349184335907274, 0.00346394410318992), `EUR/GBP_TotalCount` = structure(c(-0.179518680545716,
-0.0757259172924681, 0.333514120677483, 0.759064450015801, -0.419724789788948,
-0.360414639358521), .Dim = c(6L, 1L)), `EUR/GBP_BloombergCount` = structure(c(-0.701694550941621,
-0.669811381311996, -0.574161872423118, -0.644304845608295, -0.784590791978649,
-0.631551577756444), .Dim = c(6L, 1L)), `EUR/GBP_SocialMediaCount` = structure(c(-1.68861759789696,
-1.66829994393287, -1.5910928588693, -1.59515638966212, -1.6967446594826,
-1.63172816679749), .Dim = c(6L, 1L)), `EUR/GBP_NewsCount` = structure(c(0.76560533722738,
0.879161625683434, 1.33717198912285, 1.90306082659552, 0.487392430510049,
0.487392430510049), .Dim = c(6L, 1L))), na.action = structure(c(`6` = 6L,
`38` = 38L, `74` = 74L, `101` = 101L, `140` = 140L, `165` = 165L,
`189` = 189L, `197` = 197L, `236` = 236L, `256` = 256L, `323` = 323L,
`351` = 351L, `393` = 393L, `423` = 423L, `442` = 442L, `455` = 455L,
`490` = 490L, `510` = 510L, `551` = 551L, `576` = 576L, `605` = 605L,
`646` = 646L, `676` = 676L, `696` = 696L, `708` = 708L, `742` = 742L,
`762` = 762L, `793` = 793L, `829` = 829L, `858` = 858L, `904` = 904L,
`929` = 929L, `950` = 950L, `961` = 961L, `996` = 996L, `1016` = 1016L,
`1089` = 1089L, `1114` = 1114L, `1159` = 1159L, `1184` = 1184L,
`1207` = 1207L, `1216` = 1216L, `1238` = 1238L, `1243` = 1243L,
`1253` = 1253L, `1278` = 1278L, `1315` = 1315L, `1346` = 1346L,
`1372` = 1372L, `1416` = 1416L, `1441` = 1441L, `1473` = 1473L,
`1532` = 1532L, `1599` = 1599L, `1626` = 1626L, `1669` = 1669L,
`1694` = 1694L, `1718` = 1718L, `1726` = 1726L, `1766` = 1766L,
`1786` = 1786L, `1827` = 1827L, `1853` = 1853L, `1881` = 1881L,
`1922` = 1922L, `1952` = 1952L, `1971` = 1971L, `1984` = 1984L,
`2019` = 2019L, `2039` = 2039L, `2075` = 2075L, `2106` = 2106L,
`2135` = 2135L, `2181` = 2181L, `2206` = 2206L, `2227` = 2227L,
`2238` = 2238L, `2273` = 2273L, `2293` = 2293L, `2325` = 2325L,
`2366` = 2366L, `2391` = 2391L, `2436` = 2436L, `2461` = 2461L,
`2483` = 2483L, `2493` = 2493L), class = "omit"), row.names = c(1L,
2L, 3L, 4L, 5L, 7L), class = "data.frame")
I have built 9 regression models per forecast horizon (t+1, t+5 and t+22) and I am using the predict function to make my forecasts. I have coded this in an R loop, where I also try to assign each forecast to a matrix. My code is the following:
EUR/GBP_RV t+1`~data.estimateI am trying to calculate realized volatility forecasts using a rolling window forecast. My aim is to use the first 500 observations to forecast the 501st observations, then shift the window forward one step using observations 2 to 501 to predict the 502nd observation. I want this to repeat until I have a complete pseudo out-of-sample forecast.
My df contains 2411 observations of 23 variables, here is small example:
Date
EUR/GBP_RV t+1
EUR/GBP_RV
EUR/GBP_RV_5
EUR/GBP_RV_22
2012-02-13
0.004019947
0.004467109
0.004995980
0.005150602
2012-02-14
0.004077322
0.004019947
0.004704742
0.005099209
2012-02-15
0.004666244
0.004077322
0.004564522
0.005020790
2012-02-16
0.004582351
0.004666244
0.004532930
0.005011078
2012-02-17
0.003951071
0.004582351
0.004362595
0.004999634
2012-02-21
0.005549329
0.004824547
0.004467109
0.004954358
The head of the df can be reproduced with
structure(list(Date = structure(c(15383, 15384, 15385, 15386,
15387, 15391), class = "Date"), `EUR/GBP_RV t+1,t+22` = c(0.00437808494654599,
0.00439764887779732, 0.00441997330738947, 0.00437799055732722,
0.00435021150904479, 0.00434881306458859), `EUR/GBP_RGV t+1,t+22` = c(0.00310674728131117,
0.00311502965608506, 0.00313756204195853, 0.00312923997431178,
0.00310846773074243, 0.00309755540903969), `EUR/GBP_RBV t+1,t+22` = c(0.00304961980133602,
0.00306866297401415, 0.00307794319983677, 0.00302801249035602,
0.00300946121851254, 0.00302272755554915), `EUR/GBP_RV t+1,t+5` = c(0.00425938711995146,
0.00442030721926592, 0.00471470868108043, 0.00487869292442023,
0.00476849421943949, 0.0046067439660438), `EUR/GBP_RGV t+1,t+5` = c(0.00287718093809447,
0.00311308998902836, 0.00344398536439729, 0.00376911066284235,
0.00377425759242542, 0.00353909902900148), `EUR/GBP_RBV t+1,t+5` = c(0.00313771439501486,
0.00310626895475871, 0.0031789431316576, 0.00305962424370556,
0.00288671182187571, 0.00291630955829613), `EUR/GBP_RV t+1` = c(0.00401994700051122,
0.00407732180013827, 0.00466624428620966, 0.00458235106134663,
0.00395107145155152, 0.00554932910921084), `EUR/GBP_RGV t+1` = c(0.00280067842079775,
0.00275522601341373, 0.00296142025653418, 0.00320716195737542,
0.00266141804235125, 0.00440970289025837), `EUR/GBP_RBV t+1` = c(0.00288377777753365,
0.00300554199386584, 0.00360608177982326, 0.00327292734850446,
0.0029202430753471, 0.00336891287836027), `EUR/GBP_RV` = c(0.00446710941914797,
0.00401994700051122, 0.00407732180013827, 0.00466624428620966,
0.00458235106134663, 0.00482454749708351), `EUR/GBP_RV_5` = c(0.00499598016427624,
0.00470474196716823, 0.00456452150727461, 0.00453292965488229,
0.00436259471347075, 0.00442030721926592), `EUR/GBP_RV_22` = c(0.00515060219897263,
0.00509920878086075, 0.00502079002092667, 0.00501107755050095,
0.00499963428727425, 0.00495435807685843), `EUR/GBP_RBV` = c(0.00324667045338159,
0.00288377777753365, 0.00300554199386584, 0.00360608177982326,
0.00327292734850446, 0.00272655057625291), `EUR/GBP_RBV_5` = c(0.0034985439252634,
0.00318731350301598, 0.00319529774619179, 0.0032799330165155,
0.00320299987062176, 0.00310626895475871), `EUR/GBP_RBV_22` = c(0.0036581887941976,
0.00362298829344015, 0.00355498498935768, 0.0035465419934449,
0.00355752455210586, 0.00351669973034298), `EUR/GBP_RGV` = c(0.00306825643155514,
0.00280067842079775, 0.00275522601341373, 0.00296142025653418,
0.00320716195737542, 0.00398022367546721), `EUR/GBP_RGV_5` = c(0.00353290218424469,
0.00345194162523714, 0.00325362896209417, 0.00312087362386985,
0.00295854861593525, 0.00311308998902836), `EUR/GBP_RGV_22` = c(0.00359974659692405,
0.00356342531619103, 0.00352224165959556, 0.00351722666683608,
0.00349184335907274, 0.00346394410318992), `EUR/GBP_TotalCount` = structure(c(-0.179518680545716,
-0.0757259172924681, 0.333514120677483, 0.759064450015801, -0.419724789788948,
-0.360414639358521), .Dim = c(6L, 1L)), `EUR/GBP_BloombergCount` = structure(c(-0.701694550941621,
-0.669811381311996, -0.574161872423118, -0.644304845608295, -0.784590791978649,
-0.631551577756444), .Dim = c(6L, 1L)), `EUR/GBP_SocialMediaCount` = structure(c(-1.68861759789696,
-1.66829994393287, -1.5910928588693, -1.59515638966212, -1.6967446594826,
-1.63172816679749), .Dim = c(6L, 1L)), `EUR/GBP_NewsCount` = structure(c(0.76560533722738,
0.879161625683434, 1.33717198912285, 1.90306082659552, 0.487392430510049,
0.487392430510049), .Dim = c(6L, 1L))), na.action = structure(c(`6` = 6L,
`38` = 38L, `74` = 74L, `101` = 101L, `140` = 140L, `165` = 165L,
`189` = 189L, `197` = 197L, `236` = 236L, `256` = 256L, `323` = 323L,
`351` = 351L, `393` = 393L, `423` = 423L, `442` = 442L, `455` = 455L,
`490` = 490L, `510` = 510L, `551` = 551L, `576` = 576L, `605` = 605L,
`646` = 646L, `676` = 676L, `696` = 696L, `708` = 708L, `742` = 742L,
`762` = 762L, `793` = 793L, `829` = 829L, `858` = 858L, `904` = 904L,
`929` = 929L, `950` = 950L, `961` = 961L, `996` = 996L, `1016` = 1016L,
`1089` = 1089L, `1114` = 1114L, `1159` = 1159L, `1184` = 1184L,
`1207` = 1207L, `1216` = 1216L, `1238` = 1238L, `1243` = 1243L,
`1253` = 1253L, `1278` = 1278L, `1315` = 1315L, `1346` = 1346L,
`1372` = 1372L, `1416` = 1416L, `1441` = 1441L, `1473` = 1473L,
`1532` = 1532L, `1599` = 1599L, `1626` = 1626L, `1669` = 1669L,
`1694` = 1694L, `1718` = 1718L, `1726` = 1726L, `1766` = 1766L,
`1786` = 1786L, `1827` = 1827L, `1853` = 1853L, `1881` = 1881L,
`1922` = 1922L, `1952` = 1952L, `1971` = 1971L, `1984` = 1984L,
`2019` = 2019L, `2039` = 2039L, `2075` = 2075L, `2106` = 2106L,
`2135` = 2135L, `2181` = 2181L, `2206` = 2206L, `2227` = 2227L,
`2238` = 2238L, `2273` = 2273L, `2293` = 2293L, `2325` = 2325L,
`2366` = 2366L, `2391` = 2391L, `2436` = 2436L, `2461` = 2461L,
`2483` = 2483L, `2493` = 2493L), class = "omit"), row.names = c(1L,
2L, 3L, 4L, 5L, 7L), class = "data.frame")
I have built 9 regression models per forecast horizon (t+1, t+5 and t+22) and I am using the predict function to make my forecasts. I have coded this in an R loop, where I also try to assign each forecast to a matrix. My code is the following:
EUR/GBP_RV`+data.estimateI am trying to calculate realized volatility forecasts using a rolling window forecast. My aim is to use the first 500 observations to forecast the 501st observations, then shift the window forward one step using observations 2 to 501 to predict the 502nd observation. I want this to repeat until I have a complete pseudo out-of-sample forecast.
My df contains 2411 observations of 23 variables, here is small example:
Date
EUR/GBP_RV t+1
EUR/GBP_RV
EUR/GBP_RV_5
EUR/GBP_RV_22
2012-02-13
0.004019947
0.004467109
0.004995980
0.005150602
2012-02-14
0.004077322
0.004019947
0.004704742
0.005099209
2012-02-15
0.004666244
0.004077322
0.004564522
0.005020790
2012-02-16
0.004582351
0.004666244
0.004532930
0.005011078
2012-02-17
0.003951071
0.004582351
0.004362595
0.004999634
2012-02-21
0.005549329
0.004824547
0.004467109
0.004954358
The head of the df can be reproduced with
structure(list(Date = structure(c(15383, 15384, 15385, 15386,
15387, 15391), class = "Date"), `EUR/GBP_RV t+1,t+22` = c(0.00437808494654599,
0.00439764887779732, 0.00441997330738947, 0.00437799055732722,
0.00435021150904479, 0.00434881306458859), `EUR/GBP_RGV t+1,t+22` = c(0.00310674728131117,
0.00311502965608506, 0.00313756204195853, 0.00312923997431178,
0.00310846773074243, 0.00309755540903969), `EUR/GBP_RBV t+1,t+22` = c(0.00304961980133602,
0.00306866297401415, 0.00307794319983677, 0.00302801249035602,
0.00300946121851254, 0.00302272755554915), `EUR/GBP_RV t+1,t+5` = c(0.00425938711995146,
0.00442030721926592, 0.00471470868108043, 0.00487869292442023,
0.00476849421943949, 0.0046067439660438), `EUR/GBP_RGV t+1,t+5` = c(0.00287718093809447,
0.00311308998902836, 0.00344398536439729, 0.00376911066284235,
0.00377425759242542, 0.00353909902900148), `EUR/GBP_RBV t+1,t+5` = c(0.00313771439501486,
0.00310626895475871, 0.0031789431316576, 0.00305962424370556,
0.00288671182187571, 0.00291630955829613), `EUR/GBP_RV t+1` = c(0.00401994700051122,
0.00407732180013827, 0.00466624428620966, 0.00458235106134663,
0.00395107145155152, 0.00554932910921084), `EUR/GBP_RGV t+1` = c(0.00280067842079775,
0.00275522601341373, 0.00296142025653418, 0.00320716195737542,
0.00266141804235125, 0.00440970289025837), `EUR/GBP_RBV t+1` = c(0.00288377777753365,
0.00300554199386584, 0.00360608177982326, 0.00327292734850446,
0.0029202430753471, 0.00336891287836027), `EUR/GBP_RV` = c(0.00446710941914797,
0.00401994700051122, 0.00407732180013827, 0.00466624428620966,
0.00458235106134663, 0.00482454749708351), `EUR/GBP_RV_5` = c(0.00499598016427624,
0.00470474196716823, 0.00456452150727461, 0.00453292965488229,
0.00436259471347075, 0.00442030721926592), `EUR/GBP_RV_22` = c(0.00515060219897263,
0.00509920878086075, 0.00502079002092667, 0.00501107755050095,
0.00499963428727425, 0.00495435807685843), `EUR/GBP_RBV` = c(0.00324667045338159,
0.00288377777753365, 0.00300554199386584, 0.00360608177982326,
0.00327292734850446, 0.00272655057625291), `EUR/GBP_RBV_5` = c(0.0034985439252634,
0.00318731350301598, 0.00319529774619179, 0.0032799330165155,
0.00320299987062176, 0.00310626895475871), `EUR/GBP_RBV_22` = c(0.0036581887941976,
0.00362298829344015, 0.00355498498935768, 0.0035465419934449,
0.00355752455210586, 0.00351669973034298), `EUR/GBP_RGV` = c(0.00306825643155514,
0.00280067842079775, 0.00275522601341373, 0.00296142025653418,
0.00320716195737542, 0.00398022367546721), `EUR/GBP_RGV_5` = c(0.00353290218424469,
0.00345194162523714, 0.00325362896209417, 0.00312087362386985,
0.00295854861593525, 0.00311308998902836), `EUR/GBP_RGV_22` = c(0.00359974659692405,
0.00356342531619103, 0.00352224165959556, 0.00351722666683608,
0.00349184335907274, 0.00346394410318992), `EUR/GBP_TotalCount` = structure(c(-0.179518680545716,
-0.0757259172924681, 0.333514120677483, 0.759064450015801, -0.419724789788948,
-0.360414639358521), .Dim = c(6L, 1L)), `EUR/GBP_BloombergCount` = structure(c(-0.701694550941621,
-0.669811381311996, -0.574161872423118, -0.644304845608295, -0.784590791978649,
-0.631551577756444), .Dim = c(6L, 1L)), `EUR/GBP_SocialMediaCount` = structure(c(-1.68861759789696,
-1.66829994393287, -1.5910928588693, -1.59515638966212, -1.6967446594826,
-1.63172816679749), .Dim = c(6L, 1L)), `EUR/GBP_NewsCount` = structure(c(0.76560533722738,
0.879161625683434, 1.33717198912285, 1.90306082659552, 0.487392430510049,
0.487392430510049), .Dim = c(6L, 1L))), na.action = structure(c(`6` = 6L,
`38` = 38L, `74` = 74L, `101` = 101L, `140` = 140L, `165` = 165L,
`189` = 189L, `197` = 197L, `236` = 236L, `256` = 256L, `323` = 323L,
`351` = 351L, `393` = 393L, `423` = 423L, `442` = 442L, `455` = 455L,
`490` = 490L, `510` = 510L, `551` = 551L, `576` = 576L, `605` = 605L,
`646` = 646L, `676` = 676L, `696` = 696L, `708` = 708L, `742` = 742L,
`762` = 762L, `793` = 793L, `829` = 829L, `858` = 858L, `904` = 904L,
`929` = 929L, `950` = 950L, `961` = 961L, `996` = 996L, `1016` = 1016L,
`1089` = 1089L, `1114` = 1114L, `1159` = 1159L, `1184` = 1184L,
`1207` = 1207L, `1216` = 1216L, `1238` = 1238L, `1243` = 1243L,
`1253` = 1253L, `1278` = 1278L, `1315` = 1315L, `1346` = 1346L,
`1372` = 1372L, `1416` = 1416L, `1441` = 1441L, `1473` = 1473L,
`1532` = 1532L, `1599` = 1599L, `1626` = 1626L, `1669` = 1669L,
`1694` = 1694L, `1718` = 1718L, `1726` = 1726L, `1766` = 1766L,
`1786` = 1786L, `1827` = 1827L, `1853` = 1853L, `1881` = 1881L,
`1922` = 1922L, `1952` = 1952L, `1971` = 1971L, `1984` = 1984L,
`2019` = 2019L, `2039` = 2039L, `2075` = 2075L, `2106` = 2106L,
`2135` = 2135L, `2181` = 2181L, `2206` = 2206L, `2227` = 2227L,
`2238` = 2238L, `2273` = 2273L, `2293` = 2293L, `2325` = 2325L,
`2366` = 2366L, `2391` = 2391L, `2436` = 2436L, `2461` = 2461L,
`2483` = 2483L, `2493` = 2493L), class = "omit"), row.names = c(1L,
2L, 3L, 4L, 5L, 7L), class = "data.frame")
I have built 9 regression models per forecast horizon (t+1, t+5 and t+22) and I am using the predict function to make my forecasts. I have coded this in an R loop, where I also try to assign each forecast to a matrix. My code is the following:
EUR/GBP_RV_5`+data.estimateI am trying to calculate realized volatility forecasts using a rolling window forecast. My aim is to use the first 500 observations to forecast the 501st observations, then shift the window forward one step using observations 2 to 501 to predict the 502nd observation. I want this to repeat until I have a complete pseudo out-of-sample forecast.
My df contains 2411 observations of 23 variables, here is small example:
Date
EUR/GBP_RV t+1
EUR/GBP_RV
EUR/GBP_RV_5
EUR/GBP_RV_22
2012-02-13
0.004019947
0.004467109
0.004995980
0.005150602
2012-02-14
0.004077322
0.004019947
0.004704742
0.005099209
2012-02-15
0.004666244
0.004077322
0.004564522
0.005020790
2012-02-16
0.004582351
0.004666244
0.004532930
0.005011078
2012-02-17
0.003951071
0.004582351
0.004362595
0.004999634
2012-02-21
0.005549329
0.004824547
0.004467109
0.004954358
The head of the df can be reproduced with
structure(list(Date = structure(c(15383, 15384, 15385, 15386,
15387, 15391), class = "Date"), `EUR/GBP_RV t+1,t+22` = c(0.00437808494654599,
0.00439764887779732, 0.00441997330738947, 0.00437799055732722,
0.00435021150904479, 0.00434881306458859), `EUR/GBP_RGV t+1,t+22` = c(0.00310674728131117,
0.00311502965608506, 0.00313756204195853, 0.00312923997431178,
0.00310846773074243, 0.00309755540903969), `EUR/GBP_RBV t+1,t+22` = c(0.00304961980133602,
0.00306866297401415, 0.00307794319983677, 0.00302801249035602,
0.00300946121851254, 0.00302272755554915), `EUR/GBP_RV t+1,t+5` = c(0.00425938711995146,
0.00442030721926592, 0.00471470868108043, 0.00487869292442023,
0.00476849421943949, 0.0046067439660438), `EUR/GBP_RGV t+1,t+5` = c(0.00287718093809447,
0.00311308998902836, 0.00344398536439729, 0.00376911066284235,
0.00377425759242542, 0.00353909902900148), `EUR/GBP_RBV t+1,t+5` = c(0.00313771439501486,
0.00310626895475871, 0.0031789431316576, 0.00305962424370556,
0.00288671182187571, 0.00291630955829613), `EUR/GBP_RV t+1` = c(0.00401994700051122,
0.00407732180013827, 0.00466624428620966, 0.00458235106134663,
0.00395107145155152, 0.00554932910921084), `EUR/GBP_RGV t+1` = c(0.00280067842079775,
0.00275522601341373, 0.00296142025653418, 0.00320716195737542,
0.00266141804235125, 0.00440970289025837), `EUR/GBP_RBV t+1` = c(0.00288377777753365,
0.00300554199386584, 0.00360608177982326, 0.00327292734850446,
0.0029202430753471, 0.00336891287836027), `EUR/GBP_RV` = c(0.00446710941914797,
0.00401994700051122, 0.00407732180013827, 0.00466624428620966,
0.00458235106134663, 0.00482454749708351), `EUR/GBP_RV_5` = c(0.00499598016427624,
0.00470474196716823, 0.00456452150727461, 0.00453292965488229,
0.00436259471347075, 0.00442030721926592), `EUR/GBP_RV_22` = c(0.00515060219897263,
0.00509920878086075, 0.00502079002092667, 0.00501107755050095,
0.00499963428727425, 0.00495435807685843), `EUR/GBP_RBV` = c(0.00324667045338159,
0.00288377777753365, 0.00300554199386584, 0.00360608177982326,
0.00327292734850446, 0.00272655057625291), `EUR/GBP_RBV_5` = c(0.0034985439252634,
0.00318731350301598, 0.00319529774619179, 0.0032799330165155,
0.00320299987062176, 0.00310626895475871), `EUR/GBP_RBV_22` = c(0.0036581887941976,
0.00362298829344015, 0.00355498498935768, 0.0035465419934449,
0.00355752455210586, 0.00351669973034298), `EUR/GBP_RGV` = c(0.00306825643155514,
0.00280067842079775, 0.00275522601341373, 0.00296142025653418,
0.00320716195737542, 0.00398022367546721), `EUR/GBP_RGV_5` = c(0.00353290218424469,
0.00345194162523714, 0.00325362896209417, 0.00312087362386985,
0.00295854861593525, 0.00311308998902836), `EUR/GBP_RGV_22` = c(0.00359974659692405,
0.00356342531619103, 0.00352224165959556, 0.00351722666683608,
0.00349184335907274, 0.00346394410318992), `EUR/GBP_TotalCount` = structure(c(-0.179518680545716,
-0.0757259172924681, 0.333514120677483, 0.759064450015801, -0.419724789788948,
-0.360414639358521), .Dim = c(6L, 1L)), `EUR/GBP_BloombergCount` = structure(c(-0.701694550941621,
-0.669811381311996, -0.574161872423118, -0.644304845608295, -0.784590791978649,
-0.631551577756444), .Dim = c(6L, 1L)), `EUR/GBP_SocialMediaCount` = structure(c(-1.68861759789696,
-1.66829994393287, -1.5910928588693, -1.59515638966212, -1.6967446594826,
-1.63172816679749), .Dim = c(6L, 1L)), `EUR/GBP_NewsCount` = structure(c(0.76560533722738,
0.879161625683434, 1.33717198912285, 1.90306082659552, 0.487392430510049,
0.487392430510049), .Dim = c(6L, 1L))), na.action = structure(c(`6` = 6L,
`38` = 38L, `74` = 74L, `101` = 101L, `140` = 140L, `165` = 165L,
`189` = 189L, `197` = 197L, `236` = 236L, `256` = 256L, `323` = 323L,
`351` = 351L, `393` = 393L, `423` = 423L, `442` = 442L, `455` = 455L,
`490` = 490L, `510` = 510L, `551` = 551L, `576` = 576L, `605` = 605L,
`646` = 646L, `676` = 676L, `696` = 696L, `708` = 708L, `742` = 742L,
`762` = 762L, `793` = 793L, `829` = 829L, `858` = 858L, `904` = 904L,
`929` = 929L, `950` = 950L, `961` = 961L, `996` = 996L, `1016` = 1016L,
`1089` = 1089L, `1114` = 1114L, `1159` = 1159L, `1184` = 1184L,
`1207` = 1207L, `1216` = 1216L, `1238` = 1238L, `1243` = 1243L,
`1253` = 1253L, `1278` = 1278L, `1315` = 1315L, `1346` = 1346L,
`1372` = 1372L, `1416` = 1416L, `1441` = 1441L, `1473` = 1473L,
`1532` = 1532L, `1599` = 1599L, `1626` = 1626L, `1669` = 1669L,
`1694` = 1694L, `1718` = 1718L, `1726` = 1726L, `1766` = 1766L,
`1786` = 1786L, `1827` = 1827L, `1853` = 1853L, `1881` = 1881L,
`1922` = 1922L, `1952` = 1952L, `1971` = 1971L, `1984` = 1984L,
`2019` = 2019L, `2039` = 2039L, `2075` = 2075L, `2106` = 2106L,
`2135` = 2135L, `2181` = 2181L, `2206` = 2206L, `2227` = 2227L,
`2238` = 2238L, `2273` = 2273L, `2293` = 2293L, `2325` = 2325L,
`2366` = 2366L, `2391` = 2391L, `2436` = 2436L, `2461` = 2461L,
`2483` = 2483L, `2493` = 2493L), class = "omit"), row.names = c(1L,
2L, 3L, 4L, 5L, 7L), class = "data.frame")
I have built 9 regression models per forecast horizon (t+1, t+5 and t+22) and I am using the predict function to make my forecasts. I have coded this in an R loop, where I also try to assign each forecast to a matrix. My code is the following:
EUR/GBP_RV_22`+data.estimateI am trying to calculate realized volatility forecasts using a rolling window forecast. My aim is to use the first 500 observations to forecast the 501st observations, then shift the window forward one step using observations 2 to 501 to predict the 502nd observation. I want this to repeat until I have a complete pseudo out-of-sample forecast.
My df contains 2411 observations of 23 variables, here is small example:
Date
EUR/GBP_RV t+1
EUR/GBP_RV
EUR/GBP_RV_5
EUR/GBP_RV_22
2012-02-13
0.004019947
0.004467109
0.004995980
0.005150602
2012-02-14
0.004077322
0.004019947
0.004704742
0.005099209
2012-02-15
0.004666244
0.004077322
0.004564522
0.005020790
2012-02-16
0.004582351
0.004666244
0.004532930
0.005011078
2012-02-17
0.003951071
0.004582351
0.004362595
0.004999634
2012-02-21
0.005549329
0.004824547
0.004467109
0.004954358
The head of the df can be reproduced with
structure(list(Date = structure(c(15383, 15384, 15385, 15386,
15387, 15391), class = "Date"), `EUR/GBP_RV t+1,t+22` = c(0.00437808494654599,
0.00439764887779732, 0.00441997330738947, 0.00437799055732722,
0.00435021150904479, 0.00434881306458859), `EUR/GBP_RGV t+1,t+22` = c(0.00310674728131117,
0.00311502965608506, 0.00313756204195853, 0.00312923997431178,
0.00310846773074243, 0.00309755540903969), `EUR/GBP_RBV t+1,t+22` = c(0.00304961980133602,
0.00306866297401415, 0.00307794319983677, 0.00302801249035602,
0.00300946121851254, 0.00302272755554915), `EUR/GBP_RV t+1,t+5` = c(0.00425938711995146,
0.00442030721926592, 0.00471470868108043, 0.00487869292442023,
0.00476849421943949, 0.0046067439660438), `EUR/GBP_RGV t+1,t+5` = c(0.00287718093809447,
0.00311308998902836, 0.00344398536439729, 0.00376911066284235,
0.00377425759242542, 0.00353909902900148), `EUR/GBP_RBV t+1,t+5` = c(0.00313771439501486,
0.00310626895475871, 0.0031789431316576, 0.00305962424370556,
0.00288671182187571, 0.00291630955829613), `EUR/GBP_RV t+1` = c(0.00401994700051122,
0.00407732180013827, 0.00466624428620966, 0.00458235106134663,
0.00395107145155152, 0.00554932910921084), `EUR/GBP_RGV t+1` = c(0.00280067842079775,
0.00275522601341373, 0.00296142025653418, 0.00320716195737542,
0.00266141804235125, 0.00440970289025837), `EUR/GBP_RBV t+1` = c(0.00288377777753365,
0.00300554199386584, 0.00360608177982326, 0.00327292734850446,
0.0029202430753471, 0.00336891287836027), `EUR/GBP_RV` = c(0.00446710941914797,
0.00401994700051122, 0.00407732180013827, 0.00466624428620966,
0.00458235106134663, 0.00482454749708351), `EUR/GBP_RV_5` = c(0.00499598016427624,
0.00470474196716823, 0.00456452150727461, 0.00453292965488229,
0.00436259471347075, 0.00442030721926592), `EUR/GBP_RV_22` = c(0.00515060219897263,
0.00509920878086075, 0.00502079002092667, 0.00501107755050095,
0.00499963428727425, 0.00495435807685843), `EUR/GBP_RBV` = c(0.00324667045338159,
0.00288377777753365, 0.00300554199386584, 0.00360608177982326,
0.00327292734850446, 0.00272655057625291), `EUR/GBP_RBV_5` = c(0.0034985439252634,
0.00318731350301598, 0.00319529774619179, 0.0032799330165155,
0.00320299987062176, 0.00310626895475871), `EUR/GBP_RBV_22` = c(0.0036581887941976,
0.00362298829344015, 0.00355498498935768, 0.0035465419934449,
0.00355752455210586, 0.00351669973034298), `EUR/GBP_RGV` = c(0.00306825643155514,
0.00280067842079775, 0.00275522601341373, 0.00296142025653418,
0.00320716195737542, 0.00398022367546721), `EUR/GBP_RGV_5` = c(0.00353290218424469,
0.00345194162523714, 0.00325362896209417, 0.00312087362386985,
0.00295854861593525, 0.00311308998902836), `EUR/GBP_RGV_22` = c(0.00359974659692405,
0.00356342531619103, 0.00352224165959556, 0.00351722666683608,
0.00349184335907274, 0.00346394410318992), `EUR/GBP_TotalCount` = structure(c(-0.179518680545716,
-0.0757259172924681, 0.333514120677483, 0.759064450015801, -0.419724789788948,
-0.360414639358521), .Dim = c(6L, 1L)), `EUR/GBP_BloombergCount` = structure(c(-0.701694550941621,
-0.669811381311996, -0.574161872423118, -0.644304845608295, -0.784590791978649,
-0.631551577756444), .Dim = c(6L, 1L)), `EUR/GBP_SocialMediaCount` = structure(c(-1.68861759789696,
-1.66829994393287, -1.5910928588693, -1.59515638966212, -1.6967446594826,
-1.63172816679749), .Dim = c(6L, 1L)), `EUR/GBP_NewsCount` = structure(c(0.76560533722738,
0.879161625683434, 1.33717198912285, 1.90306082659552, 0.487392430510049,
0.487392430510049), .Dim = c(6L, 1L))), na.action = structure(c(`6` = 6L,
`38` = 38L, `74` = 74L, `101` = 101L, `140` = 140L, `165` = 165L,
`189` = 189L, `197` = 197L, `236` = 236L, `256` = 256L, `323` = 323L,
`351` = 351L, `393` = 393L, `423` = 423L, `442` = 442L, `455` = 455L,
`490` = 490L, `510` = 510L, `551` = 551L, `576` = 576L, `605` = 605L,
`646` = 646L, `676` = 676L, `696` = 696L, `708` = 708L, `742` = 742L,
`762` = 762L, `793` = 793L, `829` = 829L, `858` = 858L, `904` = 904L,
`929` = 929L, `950` = 950L, `961` = 961L, `996` = 996L, `1016` = 1016L,
`1089` = 1089L, `1114` = 1114L, `1159` = 1159L, `1184` = 1184L,
`1207` = 1207L, `1216` = 1216L, `1238` = 1238L, `1243` = 1243L,
`1253` = 1253L, `1278` = 1278L, `1315` = 1315L, `1346` = 1346L,
`1372` = 1372L, `1416` = 1416L, `1441` = 1441L, `1473` = 1473L,
`1532` = 1532L, `1599` = 1599L, `1626` = 1626L, `1669` = 1669L,
`1694` = 1694L, `1718` = 1718L, `1726` = 1726L, `1766` = 1766L,
`1786` = 1786L, `1827` = 1827L, `1853` = 1853L, `1881` = 1881L,
`1922` = 1922L, `1952` = 1952L, `1971` = 1971L, `1984` = 1984L,
`2019` = 2019L, `2039` = 2039L, `2075` = 2075L, `2106` = 2106L,
`2135` = 2135L, `2181` = 2181L, `2206` = 2206L, `2227` = 2227L,
`2238` = 2238L, `2273` = 2273L, `2293` = 2293L, `2325` = 2325L,
`2366` = 2366L, `2391` = 2391L, `2436` = 2436L, `2461` = 2461L,
`2483` = 2483L, `2493` = 2493L), class = "omit"), row.names = c(1L,
2L, 3L, 4L, 5L, 7L), class = "data.frame")
I have built 9 regression models per forecast horizon (t+1, t+5 and t+22) and I am using the predict function to make my forecasts. I have coded this in an R loop, where I also try to assign each forecast to a matrix. My code is the following:
EUR/GBP_BloombergCount`)
EURGBP_HAR_RV_SocialMedia_train <- lm(data.estimateI am trying to calculate realized volatility forecasts using a rolling window forecast. My aim is to use the first 500 observations to forecast the 501st observations, then shift the window forward one step using observations 2 to 501 to predict the 502nd observation. I want this to repeat until I have a complete pseudo out-of-sample forecast.
My df contains 2411 observations of 23 variables, here is small example:
Date
EUR/GBP_RV t+1
EUR/GBP_RV
EUR/GBP_RV_5
EUR/GBP_RV_22
2012-02-13
0.004019947
0.004467109
0.004995980
0.005150602
2012-02-14
0.004077322
0.004019947
0.004704742
0.005099209
2012-02-15
0.004666244
0.004077322
0.004564522
0.005020790
2012-02-16
0.004582351
0.004666244
0.004532930
0.005011078
2012-02-17
0.003951071
0.004582351
0.004362595
0.004999634
2012-02-21
0.005549329
0.004824547
0.004467109
0.004954358
The head of the df can be reproduced with
structure(list(Date = structure(c(15383, 15384, 15385, 15386,
15387, 15391), class = "Date"), `EUR/GBP_RV t+1,t+22` = c(0.00437808494654599,
0.00439764887779732, 0.00441997330738947, 0.00437799055732722,
0.00435021150904479, 0.00434881306458859), `EUR/GBP_RGV t+1,t+22` = c(0.00310674728131117,
0.00311502965608506, 0.00313756204195853, 0.00312923997431178,
0.00310846773074243, 0.00309755540903969), `EUR/GBP_RBV t+1,t+22` = c(0.00304961980133602,
0.00306866297401415, 0.00307794319983677, 0.00302801249035602,
0.00300946121851254, 0.00302272755554915), `EUR/GBP_RV t+1,t+5` = c(0.00425938711995146,
0.00442030721926592, 0.00471470868108043, 0.00487869292442023,
0.00476849421943949, 0.0046067439660438), `EUR/GBP_RGV t+1,t+5` = c(0.00287718093809447,
0.00311308998902836, 0.00344398536439729, 0.00376911066284235,
0.00377425759242542, 0.00353909902900148), `EUR/GBP_RBV t+1,t+5` = c(0.00313771439501486,
0.00310626895475871, 0.0031789431316576, 0.00305962424370556,
0.00288671182187571, 0.00291630955829613), `EUR/GBP_RV t+1` = c(0.00401994700051122,
0.00407732180013827, 0.00466624428620966, 0.00458235106134663,
0.00395107145155152, 0.00554932910921084), `EUR/GBP_RGV t+1` = c(0.00280067842079775,
0.00275522601341373, 0.00296142025653418, 0.00320716195737542,
0.00266141804235125, 0.00440970289025837), `EUR/GBP_RBV t+1` = c(0.00288377777753365,
0.00300554199386584, 0.00360608177982326, 0.00327292734850446,
0.0029202430753471, 0.00336891287836027), `EUR/GBP_RV` = c(0.00446710941914797,
0.00401994700051122, 0.00407732180013827, 0.00466624428620966,
0.00458235106134663, 0.00482454749708351), `EUR/GBP_RV_5` = c(0.00499598016427624,
0.00470474196716823, 0.00456452150727461, 0.00453292965488229,
0.00436259471347075, 0.00442030721926592), `EUR/GBP_RV_22` = c(0.00515060219897263,
0.00509920878086075, 0.00502079002092667, 0.00501107755050095,
0.00499963428727425, 0.00495435807685843), `EUR/GBP_RBV` = c(0.00324667045338159,
0.00288377777753365, 0.00300554199386584, 0.00360608177982326,
0.00327292734850446, 0.00272655057625291), `EUR/GBP_RBV_5` = c(0.0034985439252634,
0.00318731350301598, 0.00319529774619179, 0.0032799330165155,
0.00320299987062176, 0.00310626895475871), `EUR/GBP_RBV_22` = c(0.0036581887941976,
0.00362298829344015, 0.00355498498935768, 0.0035465419934449,
0.00355752455210586, 0.00351669973034298), `EUR/GBP_RGV` = c(0.00306825643155514,
0.00280067842079775, 0.00275522601341373, 0.00296142025653418,
0.00320716195737542, 0.00398022367546721), `EUR/GBP_RGV_5` = c(0.00353290218424469,
0.00345194162523714, 0.00325362896209417, 0.00312087362386985,
0.00295854861593525, 0.00311308998902836), `EUR/GBP_RGV_22` = c(0.00359974659692405,
0.00356342531619103, 0.00352224165959556, 0.00351722666683608,
0.00349184335907274, 0.00346394410318992), `EUR/GBP_TotalCount` = structure(c(-0.179518680545716,
-0.0757259172924681, 0.333514120677483, 0.759064450015801, -0.419724789788948,
-0.360414639358521), .Dim = c(6L, 1L)), `EUR/GBP_BloombergCount` = structure(c(-0.701694550941621,
-0.669811381311996, -0.574161872423118, -0.644304845608295, -0.784590791978649,
-0.631551577756444), .Dim = c(6L, 1L)), `EUR/GBP_SocialMediaCount` = structure(c(-1.68861759789696,
-1.66829994393287, -1.5910928588693, -1.59515638966212, -1.6967446594826,
-1.63172816679749), .Dim = c(6L, 1L)), `EUR/GBP_NewsCount` = structure(c(0.76560533722738,
0.879161625683434, 1.33717198912285, 1.90306082659552, 0.487392430510049,
0.487392430510049), .Dim = c(6L, 1L))), na.action = structure(c(`6` = 6L,
`38` = 38L, `74` = 74L, `101` = 101L, `140` = 140L, `165` = 165L,
`189` = 189L, `197` = 197L, `236` = 236L, `256` = 256L, `323` = 323L,
`351` = 351L, `393` = 393L, `423` = 423L, `442` = 442L, `455` = 455L,
`490` = 490L, `510` = 510L, `551` = 551L, `576` = 576L, `605` = 605L,
`646` = 646L, `676` = 676L, `696` = 696L, `708` = 708L, `742` = 742L,
`762` = 762L, `793` = 793L, `829` = 829L, `858` = 858L, `904` = 904L,
`929` = 929L, `950` = 950L, `961` = 961L, `996` = 996L, `1016` = 1016L,
`1089` = 1089L, `1114` = 1114L, `1159` = 1159L, `1184` = 1184L,
`1207` = 1207L, `1216` = 1216L, `1238` = 1238L, `1243` = 1243L,
`1253` = 1253L, `1278` = 1278L, `1315` = 1315L, `1346` = 1346L,
`1372` = 1372L, `1416` = 1416L, `1441` = 1441L, `1473` = 1473L,
`1532` = 1532L, `1599` = 1599L, `1626` = 1626L, `1669` = 1669L,
`1694` = 1694L, `1718` = 1718L, `1726` = 1726L, `1766` = 1766L,
`1786` = 1786L, `1827` = 1827L, `1853` = 1853L, `1881` = 1881L,
`1922` = 1922L, `1952` = 1952L, `1971` = 1971L, `1984` = 1984L,
`2019` = 2019L, `2039` = 2039L, `2075` = 2075L, `2106` = 2106L,
`2135` = 2135L, `2181` = 2181L, `2206` = 2206L, `2227` = 2227L,
`2238` = 2238L, `2273` = 2273L, `2293` = 2293L, `2325` = 2325L,
`2366` = 2366L, `2391` = 2391L, `2436` = 2436L, `2461` = 2461L,
`2483` = 2483L, `2493` = 2493L), class = "omit"), row.names = c(1L,
2L, 3L, 4L, 5L, 7L), class = "data.frame")
I have built 9 regression models per forecast horizon (t+1, t+5 and t+22) and I am using the predict function to make my forecasts. I have coded this in an R loop, where I also try to assign each forecast to a matrix. My code is the following:
EUR/GBP_RV t+1`~data.estimateI am trying to calculate realized volatility forecasts using a rolling window forecast. My aim is to use the first 500 observations to forecast the 501st observations, then shift the window forward one step using observations 2 to 501 to predict the 502nd observation. I want this to repeat until I have a complete pseudo out-of-sample forecast.
My df contains 2411 observations of 23 variables, here is small example:
Date
EUR/GBP_RV t+1
EUR/GBP_RV
EUR/GBP_RV_5
EUR/GBP_RV_22
2012-02-13
0.004019947
0.004467109
0.004995980
0.005150602
2012-02-14
0.004077322
0.004019947
0.004704742
0.005099209
2012-02-15
0.004666244
0.004077322
0.004564522
0.005020790
2012-02-16
0.004582351
0.004666244
0.004532930
0.005011078
2012-02-17
0.003951071
0.004582351
0.004362595
0.004999634
2012-02-21
0.005549329
0.004824547
0.004467109
0.004954358
The head of the df can be reproduced with
structure(list(Date = structure(c(15383, 15384, 15385, 15386,
15387, 15391), class = "Date"), `EUR/GBP_RV t+1,t+22` = c(0.00437808494654599,
0.00439764887779732, 0.00441997330738947, 0.00437799055732722,
0.00435021150904479, 0.00434881306458859), `EUR/GBP_RGV t+1,t+22` = c(0.00310674728131117,
0.00311502965608506, 0.00313756204195853, 0.00312923997431178,
0.00310846773074243, 0.00309755540903969), `EUR/GBP_RBV t+1,t+22` = c(0.00304961980133602,
0.00306866297401415, 0.00307794319983677, 0.00302801249035602,
0.00300946121851254, 0.00302272755554915), `EUR/GBP_RV t+1,t+5` = c(0.00425938711995146,
0.00442030721926592, 0.00471470868108043, 0.00487869292442023,
0.00476849421943949, 0.0046067439660438), `EUR/GBP_RGV t+1,t+5` = c(0.00287718093809447,
0.00311308998902836, 0.00344398536439729, 0.00376911066284235,
0.00377425759242542, 0.00353909902900148), `EUR/GBP_RBV t+1,t+5` = c(0.00313771439501486,
0.00310626895475871, 0.0031789431316576, 0.00305962424370556,
0.00288671182187571, 0.00291630955829613), `EUR/GBP_RV t+1` = c(0.00401994700051122,
0.00407732180013827, 0.00466624428620966, 0.00458235106134663,
0.00395107145155152, 0.00554932910921084), `EUR/GBP_RGV t+1` = c(0.00280067842079775,
0.00275522601341373, 0.00296142025653418, 0.00320716195737542,
0.00266141804235125, 0.00440970289025837), `EUR/GBP_RBV t+1` = c(0.00288377777753365,
0.00300554199386584, 0.00360608177982326, 0.00327292734850446,
0.0029202430753471, 0.00336891287836027), `EUR/GBP_RV` = c(0.00446710941914797,
0.00401994700051122, 0.00407732180013827, 0.00466624428620966,
0.00458235106134663, 0.00482454749708351), `EUR/GBP_RV_5` = c(0.00499598016427624,
0.00470474196716823, 0.00456452150727461, 0.00453292965488229,
0.00436259471347075, 0.00442030721926592), `EUR/GBP_RV_22` = c(0.00515060219897263,
0.00509920878086075, 0.00502079002092667, 0.00501107755050095,
0.00499963428727425, 0.00495435807685843), `EUR/GBP_RBV` = c(0.00324667045338159,
0.00288377777753365, 0.00300554199386584, 0.00360608177982326,
0.00327292734850446, 0.00272655057625291), `EUR/GBP_RBV_5` = c(0.0034985439252634,
0.00318731350301598, 0.00319529774619179, 0.0032799330165155,
0.00320299987062176, 0.00310626895475871), `EUR/GBP_RBV_22` = c(0.0036581887941976,
0.00362298829344015, 0.00355498498935768, 0.0035465419934449,
0.00355752455210586, 0.00351669973034298), `EUR/GBP_RGV` = c(0.00306825643155514,
0.00280067842079775, 0.00275522601341373, 0.00296142025653418,
0.00320716195737542, 0.00398022367546721), `EUR/GBP_RGV_5` = c(0.00353290218424469,
0.00345194162523714, 0.00325362896209417, 0.00312087362386985,
0.00295854861593525, 0.00311308998902836), `EUR/GBP_RGV_22` = c(0.00359974659692405,
0.00356342531619103, 0.00352224165959556, 0.00351722666683608,
0.00349184335907274, 0.00346394410318992), `EUR/GBP_TotalCount` = structure(c(-0.179518680545716,
-0.0757259172924681, 0.333514120677483, 0.759064450015801, -0.419724789788948,
-0.360414639358521), .Dim = c(6L, 1L)), `EUR/GBP_BloombergCount` = structure(c(-0.701694550941621,
-0.669811381311996, -0.574161872423118, -0.644304845608295, -0.784590791978649,
-0.631551577756444), .Dim = c(6L, 1L)), `EUR/GBP_SocialMediaCount` = structure(c(-1.68861759789696,
-1.66829994393287, -1.5910928588693, -1.59515638966212, -1.6967446594826,
-1.63172816679749), .Dim = c(6L, 1L)), `EUR/GBP_NewsCount` = structure(c(0.76560533722738,
0.879161625683434, 1.33717198912285, 1.90306082659552, 0.487392430510049,
0.487392430510049), .Dim = c(6L, 1L))), na.action = structure(c(`6` = 6L,
`38` = 38L, `74` = 74L, `101` = 101L, `140` = 140L, `165` = 165L,
`189` = 189L, `197` = 197L, `236` = 236L, `256` = 256L, `323` = 323L,
`351` = 351L, `393` = 393L, `423` = 423L, `442` = 442L, `455` = 455L,
`490` = 490L, `510` = 510L, `551` = 551L, `576` = 576L, `605` = 605L,
`646` = 646L, `676` = 676L, `696` = 696L, `708` = 708L, `742` = 742L,
`762` = 762L, `793` = 793L, `829` = 829L, `858` = 858L, `904` = 904L,
`929` = 929L, `950` = 950L, `961` = 961L, `996` = 996L, `1016` = 1016L,
`1089` = 1089L, `1114` = 1114L, `1159` = 1159L, `1184` = 1184L,
`1207` = 1207L, `1216` = 1216L, `1238` = 1238L, `1243` = 1243L,
`1253` = 1253L, `1278` = 1278L, `1315` = 1315L, `1346` = 1346L,
`1372` = 1372L, `1416` = 1416L, `1441` = 1441L, `1473` = 1473L,
`1532` = 1532L, `1599` = 1599L, `1626` = 1626L, `1669` = 1669L,
`1694` = 1694L, `1718` = 1718L, `1726` = 1726L, `1766` = 1766L,
`1786` = 1786L, `1827` = 1827L, `1853` = 1853L, `1881` = 1881L,
`1922` = 1922L, `1952` = 1952L, `1971` = 1971L, `1984` = 1984L,
`2019` = 2019L, `2039` = 2039L, `2075` = 2075L, `2106` = 2106L,
`2135` = 2135L, `2181` = 2181L, `2206` = 2206L, `2227` = 2227L,
`2238` = 2238L, `2273` = 2273L, `2293` = 2293L, `2325` = 2325L,
`2366` = 2366L, `2391` = 2391L, `2436` = 2436L, `2461` = 2461L,
`2483` = 2483L, `2493` = 2493L), class = "omit"), row.names = c(1L,
2L, 3L, 4L, 5L, 7L), class = "data.frame")
I have built 9 regression models per forecast horizon (t+1, t+5 and t+22) and I am using the predict function to make my forecasts. I have coded this in an R loop, where I also try to assign each forecast to a matrix. My code is the following:
EUR/GBP_RV`+data.estimateI am trying to calculate realized volatility forecasts using a rolling window forecast. My aim is to use the first 500 observations to forecast the 501st observations, then shift the window forward one step using observations 2 to 501 to predict the 502nd observation. I want this to repeat until I have a complete pseudo out-of-sample forecast.
My df contains 2411 observations of 23 variables, here is small example:
Date
EUR/GBP_RV t+1
EUR/GBP_RV
EUR/GBP_RV_5
EUR/GBP_RV_22
2012-02-13
0.004019947
0.004467109
0.004995980
0.005150602
2012-02-14
0.004077322
0.004019947
0.004704742
0.005099209
2012-02-15
0.004666244
0.004077322
0.004564522
0.005020790
2012-02-16
0.004582351
0.004666244
0.004532930
0.005011078
2012-02-17
0.003951071
0.004582351
0.004362595
0.004999634
2012-02-21
0.005549329
0.004824547
0.004467109
0.004954358
The head of the df can be reproduced with
structure(list(Date = structure(c(15383, 15384, 15385, 15386,
15387, 15391), class = "Date"), `EUR/GBP_RV t+1,t+22` = c(0.00437808494654599,
0.00439764887779732, 0.00441997330738947, 0.00437799055732722,
0.00435021150904479, 0.00434881306458859), `EUR/GBP_RGV t+1,t+22` = c(0.00310674728131117,
0.00311502965608506, 0.00313756204195853, 0.00312923997431178,
0.00310846773074243, 0.00309755540903969), `EUR/GBP_RBV t+1,t+22` = c(0.00304961980133602,
0.00306866297401415, 0.00307794319983677, 0.00302801249035602,
0.00300946121851254, 0.00302272755554915), `EUR/GBP_RV t+1,t+5` = c(0.00425938711995146,
0.00442030721926592, 0.00471470868108043, 0.00487869292442023,
0.00476849421943949, 0.0046067439660438), `EUR/GBP_RGV t+1,t+5` = c(0.00287718093809447,
0.00311308998902836, 0.00344398536439729, 0.00376911066284235,
0.00377425759242542, 0.00353909902900148), `EUR/GBP_RBV t+1,t+5` = c(0.00313771439501486,
0.00310626895475871, 0.0031789431316576, 0.00305962424370556,
0.00288671182187571, 0.00291630955829613), `EUR/GBP_RV t+1` = c(0.00401994700051122,
0.00407732180013827, 0.00466624428620966, 0.00458235106134663,
0.00395107145155152, 0.00554932910921084), `EUR/GBP_RGV t+1` = c(0.00280067842079775,
0.00275522601341373, 0.00296142025653418, 0.00320716195737542,
0.00266141804235125, 0.00440970289025837), `EUR/GBP_RBV t+1` = c(0.00288377777753365,
0.00300554199386584, 0.00360608177982326, 0.00327292734850446,
0.0029202430753471, 0.00336891287836027), `EUR/GBP_RV` = c(0.00446710941914797,
0.00401994700051122, 0.00407732180013827, 0.00466624428620966,
0.00458235106134663, 0.00482454749708351), `EUR/GBP_RV_5` = c(0.00499598016427624,
0.00470474196716823, 0.00456452150727461, 0.00453292965488229,
0.00436259471347075, 0.00442030721926592), `EUR/GBP_RV_22` = c(0.00515060219897263,
0.00509920878086075, 0.00502079002092667, 0.00501107755050095,
0.00499963428727425, 0.00495435807685843), `EUR/GBP_RBV` = c(0.00324667045338159,
0.00288377777753365, 0.00300554199386584, 0.00360608177982326,
0.00327292734850446, 0.00272655057625291), `EUR/GBP_RBV_5` = c(0.0034985439252634,
0.00318731350301598, 0.00319529774619179, 0.0032799330165155,
0.00320299987062176, 0.00310626895475871), `EUR/GBP_RBV_22` = c(0.0036581887941976,
0.00362298829344015, 0.00355498498935768, 0.0035465419934449,
0.00355752455210586, 0.00351669973034298), `EUR/GBP_RGV` = c(0.00306825643155514,
0.00280067842079775, 0.00275522601341373, 0.00296142025653418,
0.00320716195737542, 0.00398022367546721), `EUR/GBP_RGV_5` = c(0.00353290218424469,
0.00345194162523714, 0.00325362896209417, 0.00312087362386985,
0.00295854861593525, 0.00311308998902836), `EUR/GBP_RGV_22` = c(0.00359974659692405,
0.00356342531619103, 0.00352224165959556, 0.00351722666683608,
0.00349184335907274, 0.00346394410318992), `EUR/GBP_TotalCount` = structure(c(-0.179518680545716,
-0.0757259172924681, 0.333514120677483, 0.759064450015801, -0.419724789788948,
-0.360414639358521), .Dim = c(6L, 1L)), `EUR/GBP_BloombergCount` = structure(c(-0.701694550941621,
-0.669811381311996, -0.574161872423118, -0.644304845608295, -0.784590791978649,
-0.631551577756444), .Dim = c(6L, 1L)), `EUR/GBP_SocialMediaCount` = structure(c(-1.68861759789696,
-1.66829994393287, -1.5910928588693, -1.59515638966212, -1.6967446594826,
-1.63172816679749), .Dim = c(6L, 1L)), `EUR/GBP_NewsCount` = structure(c(0.76560533722738,
0.879161625683434, 1.33717198912285, 1.90306082659552, 0.487392430510049,
0.487392430510049), .Dim = c(6L, 1L))), na.action = structure(c(`6` = 6L,
`38` = 38L, `74` = 74L, `101` = 101L, `140` = 140L, `165` = 165L,
`189` = 189L, `197` = 197L, `236` = 236L, `256` = 256L, `323` = 323L,
`351` = 351L, `393` = 393L, `423` = 423L, `442` = 442L, `455` = 455L,
`490` = 490L, `510` = 510L, `551` = 551L, `576` = 576L, `605` = 605L,
`646` = 646L, `676` = 676L, `696` = 696L, `708` = 708L, `742` = 742L,
`762` = 762L, `793` = 793L, `829` = 829L, `858` = 858L, `904` = 904L,
`929` = 929L, `950` = 950L, `961` = 961L, `996` = 996L, `1016` = 1016L,
`1089` = 1089L, `1114` = 1114L, `1159` = 1159L, `1184` = 1184L,
`1207` = 1207L, `1216` = 1216L, `1238` = 1238L, `1243` = 1243L,
`1253` = 1253L, `1278` = 1278L, `1315` = 1315L, `1346` = 1346L,
`1372` = 1372L, `1416` = 1416L, `1441` = 1441L, `1473` = 1473L,
`1532` = 1532L, `1599` = 1599L, `1626` = 1626L, `1669` = 1669L,
`1694` = 1694L, `1718` = 1718L, `1726` = 1726L, `1766` = 1766L,
`1786` = 1786L, `1827` = 1827L, `1853` = 1853L, `1881` = 1881L,
`1922` = 1922L, `1952` = 1952L, `1971` = 1971L, `1984` = 1984L,
`2019` = 2019L, `2039` = 2039L, `2075` = 2075L, `2106` = 2106L,
`2135` = 2135L, `2181` = 2181L, `2206` = 2206L, `2227` = 2227L,
`2238` = 2238L, `2273` = 2273L, `2293` = 2293L, `2325` = 2325L,
`2366` = 2366L, `2391` = 2391L, `2436` = 2436L, `2461` = 2461L,
`2483` = 2483L, `2493` = 2493L), class = "omit"), row.names = c(1L,
2L, 3L, 4L, 5L, 7L), class = "data.frame")
I have built 9 regression models per forecast horizon (t+1, t+5 and t+22) and I am using the predict function to make my forecasts. I have coded this in an R loop, where I also try to assign each forecast to a matrix. My code is the following:
EUR/GBP_RV_5`+data.estimateI am trying to calculate realized volatility forecasts using a rolling window forecast. My aim is to use the first 500 observations to forecast the 501st observations, then shift the window forward one step using observations 2 to 501 to predict the 502nd observation. I want this to repeat until I have a complete pseudo out-of-sample forecast.
My df contains 2411 observations of 23 variables, here is small example:
Date
EUR/GBP_RV t+1
EUR/GBP_RV
EUR/GBP_RV_5
EUR/GBP_RV_22
2012-02-13
0.004019947
0.004467109
0.004995980
0.005150602
2012-02-14
0.004077322
0.004019947
0.004704742
0.005099209
2012-02-15
0.004666244
0.004077322
0.004564522
0.005020790
2012-02-16
0.004582351
0.004666244
0.004532930
0.005011078
2012-02-17
0.003951071
0.004582351
0.004362595
0.004999634
2012-02-21
0.005549329
0.004824547
0.004467109
0.004954358
The head of the df can be reproduced with
structure(list(Date = structure(c(15383, 15384, 15385, 15386,
15387, 15391), class = "Date"), `EUR/GBP_RV t+1,t+22` = c(0.00437808494654599,
0.00439764887779732, 0.00441997330738947, 0.00437799055732722,
0.00435021150904479, 0.00434881306458859), `EUR/GBP_RGV t+1,t+22` = c(0.00310674728131117,
0.00311502965608506, 0.00313756204195853, 0.00312923997431178,
0.00310846773074243, 0.00309755540903969), `EUR/GBP_RBV t+1,t+22` = c(0.00304961980133602,
0.00306866297401415, 0.00307794319983677, 0.00302801249035602,
0.00300946121851254, 0.00302272755554915), `EUR/GBP_RV t+1,t+5` = c(0.00425938711995146,
0.00442030721926592, 0.00471470868108043, 0.00487869292442023,
0.00476849421943949, 0.0046067439660438), `EUR/GBP_RGV t+1,t+5` = c(0.00287718093809447,
0.00311308998902836, 0.00344398536439729, 0.00376911066284235,
0.00377425759242542, 0.00353909902900148), `EUR/GBP_RBV t+1,t+5` = c(0.00313771439501486,
0.00310626895475871, 0.0031789431316576, 0.00305962424370556,
0.00288671182187571, 0.00291630955829613), `EUR/GBP_RV t+1` = c(0.00401994700051122,
0.00407732180013827, 0.00466624428620966, 0.00458235106134663,
0.00395107145155152, 0.00554932910921084), `EUR/GBP_RGV t+1` = c(0.00280067842079775,
0.00275522601341373, 0.00296142025653418, 0.00320716195737542,
0.00266141804235125, 0.00440970289025837), `EUR/GBP_RBV t+1` = c(0.00288377777753365,
0.00300554199386584, 0.00360608177982326, 0.00327292734850446,
0.0029202430753471, 0.00336891287836027), `EUR/GBP_RV` = c(0.00446710941914797,
0.00401994700051122, 0.00407732180013827, 0.00466624428620966,
0.00458235106134663, 0.00482454749708351), `EUR/GBP_RV_5` = c(0.00499598016427624,
0.00470474196716823, 0.00456452150727461, 0.00453292965488229,
0.00436259471347075, 0.00442030721926592), `EUR/GBP_RV_22` = c(0.00515060219897263,
0.00509920878086075, 0.00502079002092667, 0.00501107755050095,
0.00499963428727425, 0.00495435807685843), `EUR/GBP_RBV` = c(0.00324667045338159,
0.00288377777753365, 0.00300554199386584, 0.00360608177982326,
0.00327292734850446, 0.00272655057625291), `EUR/GBP_RBV_5` = c(0.0034985439252634,
0.00318731350301598, 0.00319529774619179, 0.0032799330165155,
0.00320299987062176, 0.00310626895475871), `EUR/GBP_RBV_22` = c(0.0036581887941976,
0.00362298829344015, 0.00355498498935768, 0.0035465419934449,
0.00355752455210586, 0.00351669973034298), `EUR/GBP_RGV` = c(0.00306825643155514,
0.00280067842079775, 0.00275522601341373, 0.00296142025653418,
0.00320716195737542, 0.00398022367546721), `EUR/GBP_RGV_5` = c(0.00353290218424469,
0.00345194162523714, 0.00325362896209417, 0.00312087362386985,
0.00295854861593525, 0.00311308998902836), `EUR/GBP_RGV_22` = c(0.00359974659692405,
0.00356342531619103, 0.00352224165959556, 0.00351722666683608,
0.00349184335907274, 0.00346394410318992), `EUR/GBP_TotalCount` = structure(c(-0.179518680545716,
-0.0757259172924681, 0.333514120677483, 0.759064450015801, -0.419724789788948,
-0.360414639358521), .Dim = c(6L, 1L)), `EUR/GBP_BloombergCount` = structure(c(-0.701694550941621,
-0.669811381311996, -0.574161872423118, -0.644304845608295, -0.784590791978649,
-0.631551577756444), .Dim = c(6L, 1L)), `EUR/GBP_SocialMediaCount` = structure(c(-1.68861759789696,
-1.66829994393287, -1.5910928588693, -1.59515638966212, -1.6967446594826,
-1.63172816679749), .Dim = c(6L, 1L)), `EUR/GBP_NewsCount` = structure(c(0.76560533722738,
0.879161625683434, 1.33717198912285, 1.90306082659552, 0.487392430510049,
0.487392430510049), .Dim = c(6L, 1L))), na.action = structure(c(`6` = 6L,
`38` = 38L, `74` = 74L, `101` = 101L, `140` = 140L, `165` = 165L,
`189` = 189L, `197` = 197L, `236` = 236L, `256` = 256L, `323` = 323L,
`351` = 351L, `393` = 393L, `423` = 423L, `442` = 442L, `455` = 455L,
`490` = 490L, `510` = 510L, `551` = 551L, `576` = 576L, `605` = 605L,
`646` = 646L, `676` = 676L, `696` = 696L, `708` = 708L, `742` = 742L,
`762` = 762L, `793` = 793L, `829` = 829L, `858` = 858L, `904` = 904L,
`929` = 929L, `950` = 950L, `961` = 961L, `996` = 996L, `1016` = 1016L,
`1089` = 1089L, `1114` = 1114L, `1159` = 1159L, `1184` = 1184L,
`1207` = 1207L, `1216` = 1216L, `1238` = 1238L, `1243` = 1243L,
`1253` = 1253L, `1278` = 1278L, `1315` = 1315L, `1346` = 1346L,
`1372` = 1372L, `1416` = 1416L, `1441` = 1441L, `1473` = 1473L,
`1532` = 1532L, `1599` = 1599L, `1626` = 1626L, `1669` = 1669L,
`1694` = 1694L, `1718` = 1718L, `1726` = 1726L, `1766` = 1766L,
`1786` = 1786L, `1827` = 1827L, `1853` = 1853L, `1881` = 1881L,
`1922` = 1922L, `1952` = 1952L, `1971` = 1971L, `1984` = 1984L,
`2019` = 2019L, `2039` = 2039L, `2075` = 2075L, `2106` = 2106L,
`2135` = 2135L, `2181` = 2181L, `2206` = 2206L, `2227` = 2227L,
`2238` = 2238L, `2273` = 2273L, `2293` = 2293L, `2325` = 2325L,
`2366` = 2366L, `2391` = 2391L, `2436` = 2436L, `2461` = 2461L,
`2483` = 2483L, `2493` = 2493L), class = "omit"), row.names = c(1L,
2L, 3L, 4L, 5L, 7L), class = "data.frame")
I have built 9 regression models per forecast horizon (t+1, t+5 and t+22) and I am using the predict function to make my forecasts. I have coded this in an R loop, where I also try to assign each forecast to a matrix. My code is the following:
EUR/GBP_RV_22`+data.estimateI am trying to calculate realized volatility forecasts using a rolling window forecast. My aim is to use the first 500 observations to forecast the 501st observations, then shift the window forward one step using observations 2 to 501 to predict the 502nd observation. I want this to repeat until I have a complete pseudo out-of-sample forecast.
My df contains 2411 observations of 23 variables, here is small example:
Date
EUR/GBP_RV t+1
EUR/GBP_RV
EUR/GBP_RV_5
EUR/GBP_RV_22
2012-02-13
0.004019947
0.004467109
0.004995980
0.005150602
2012-02-14
0.004077322
0.004019947
0.004704742
0.005099209
2012-02-15
0.004666244
0.004077322
0.004564522
0.005020790
2012-02-16
0.004582351
0.004666244
0.004532930
0.005011078
2012-02-17
0.003951071
0.004582351
0.004362595
0.004999634
2012-02-21
0.005549329
0.004824547
0.004467109
0.004954358
The head of the df can be reproduced with
structure(list(Date = structure(c(15383, 15384, 15385, 15386,
15387, 15391), class = "Date"), `EUR/GBP_RV t+1,t+22` = c(0.00437808494654599,
0.00439764887779732, 0.00441997330738947, 0.00437799055732722,
0.00435021150904479, 0.00434881306458859), `EUR/GBP_RGV t+1,t+22` = c(0.00310674728131117,
0.00311502965608506, 0.00313756204195853, 0.00312923997431178,
0.00310846773074243, 0.00309755540903969), `EUR/GBP_RBV t+1,t+22` = c(0.00304961980133602,
0.00306866297401415, 0.00307794319983677, 0.00302801249035602,
0.00300946121851254, 0.00302272755554915), `EUR/GBP_RV t+1,t+5` = c(0.00425938711995146,
0.00442030721926592, 0.00471470868108043, 0.00487869292442023,
0.00476849421943949, 0.0046067439660438), `EUR/GBP_RGV t+1,t+5` = c(0.00287718093809447,
0.00311308998902836, 0.00344398536439729, 0.00376911066284235,
0.00377425759242542, 0.00353909902900148), `EUR/GBP_RBV t+1,t+5` = c(0.00313771439501486,
0.00310626895475871, 0.0031789431316576, 0.00305962424370556,
0.00288671182187571, 0.00291630955829613), `EUR/GBP_RV t+1` = c(0.00401994700051122,
0.00407732180013827, 0.00466624428620966, 0.00458235106134663,
0.00395107145155152, 0.00554932910921084), `EUR/GBP_RGV t+1` = c(0.00280067842079775,
0.00275522601341373, 0.00296142025653418, 0.00320716195737542,
0.00266141804235125, 0.00440970289025837), `EUR/GBP_RBV t+1` = c(0.00288377777753365,
0.00300554199386584, 0.00360608177982326, 0.00327292734850446,
0.0029202430753471, 0.00336891287836027), `EUR/GBP_RV` = c(0.00446710941914797,
0.00401994700051122, 0.00407732180013827, 0.00466624428620966,
0.00458235106134663, 0.00482454749708351), `EUR/GBP_RV_5` = c(0.00499598016427624,
0.00470474196716823, 0.00456452150727461, 0.00453292965488229,
0.00436259471347075, 0.00442030721926592), `EUR/GBP_RV_22` = c(0.00515060219897263,
0.00509920878086075, 0.00502079002092667, 0.00501107755050095,
0.00499963428727425, 0.00495435807685843), `EUR/GBP_RBV` = c(0.00324667045338159,
0.00288377777753365, 0.00300554199386584, 0.00360608177982326,
0.00327292734850446, 0.00272655057625291), `EUR/GBP_RBV_5` = c(0.0034985439252634,
0.00318731350301598, 0.00319529774619179, 0.0032799330165155,
0.00320299987062176, 0.00310626895475871), `EUR/GBP_RBV_22` = c(0.0036581887941976,
0.00362298829344015, 0.00355498498935768, 0.0035465419934449,
0.00355752455210586, 0.00351669973034298), `EUR/GBP_RGV` = c(0.00306825643155514,
0.00280067842079775, 0.00275522601341373, 0.00296142025653418,
0.00320716195737542, 0.00398022367546721), `EUR/GBP_RGV_5` = c(0.00353290218424469,
0.00345194162523714, 0.00325362896209417, 0.00312087362386985,
0.00295854861593525, 0.00311308998902836), `EUR/GBP_RGV_22` = c(0.00359974659692405,
0.00356342531619103, 0.00352224165959556, 0.00351722666683608,
0.00349184335907274, 0.00346394410318992), `EUR/GBP_TotalCount` = structure(c(-0.179518680545716,
-0.0757259172924681, 0.333514120677483, 0.759064450015801, -0.419724789788948,
-0.360414639358521), .Dim = c(6L, 1L)), `EUR/GBP_BloombergCount` = structure(c(-0.701694550941621,
-0.669811381311996, -0.574161872423118, -0.644304845608295, -0.784590791978649,
-0.631551577756444), .Dim = c(6L, 1L)), `EUR/GBP_SocialMediaCount` = structure(c(-1.68861759789696,
-1.66829994393287, -1.5910928588693, -1.59515638966212, -1.6967446594826,
-1.63172816679749), .Dim = c(6L, 1L)), `EUR/GBP_NewsCount` = structure(c(0.76560533722738,
0.879161625683434, 1.33717198912285, 1.90306082659552, 0.487392430510049,
0.487392430510049), .Dim = c(6L, 1L))), na.action = structure(c(`6` = 6L,
`38` = 38L, `74` = 74L, `101` = 101L, `140` = 140L, `165` = 165L,
`189` = 189L, `197` = 197L, `236` = 236L, `256` = 256L, `323` = 323L,
`351` = 351L, `393` = 393L, `423` = 423L, `442` = 442L, `455` = 455L,
`490` = 490L, `510` = 510L, `551` = 551L, `576` = 576L, `605` = 605L,
`646` = 646L, `676` = 676L, `696` = 696L, `708` = 708L, `742` = 742L,
`762` = 762L, `793` = 793L, `829` = 829L, `858` = 858L, `904` = 904L,
`929` = 929L, `950` = 950L, `961` = 961L, `996` = 996L, `1016` = 1016L,
`1089` = 1089L, `1114` = 1114L, `1159` = 1159L, `1184` = 1184L,
`1207` = 1207L, `1216` = 1216L, `1238` = 1238L, `1243` = 1243L,
`1253` = 1253L, `1278` = 1278L, `1315` = 1315L, `1346` = 1346L,
`1372` = 1372L, `1416` = 1416L, `1441` = 1441L, `1473` = 1473L,
`1532` = 1532L, `1599` = 1599L, `1626` = 1626L, `1669` = 1669L,
`1694` = 1694L, `1718` = 1718L, `1726` = 1726L, `1766` = 1766L,
`1786` = 1786L, `1827` = 1827L, `1853` = 1853L, `1881` = 1881L,
`1922` = 1922L, `1952` = 1952L, `1971` = 1971L, `1984` = 1984L,
`2019` = 2019L, `2039` = 2039L, `2075` = 2075L, `2106` = 2106L,
`2135` = 2135L, `2181` = 2181L, `2206` = 2206L, `2227` = 2227L,
`2238` = 2238L, `2273` = 2273L, `2293` = 2293L, `2325` = 2325L,
`2366` = 2366L, `2391` = 2391L, `2436` = 2436L, `2461` = 2461L,
`2483` = 2483L, `2493` = 2493L), class = "omit"), row.names = c(1L,
2L, 3L, 4L, 5L, 7L), class = "data.frame")
I have built 9 regression models per forecast horizon (t+1, t+5 and t+22) and I am using the predict function to make my forecasts. I have coded this in an R loop, where I also try to assign each forecast to a matrix. My code is the following:
EUR/GBP_SocialMediaCount`)
EURGBP_HAR_RV_News_train <- lm(data.estimateI am trying to calculate realized volatility forecasts using a rolling window forecast. My aim is to use the first 500 observations to forecast the 501st observations, then shift the window forward one step using observations 2 to 501 to predict the 502nd observation. I want this to repeat until I have a complete pseudo out-of-sample forecast.
My df contains 2411 observations of 23 variables, here is small example:
Date
EUR/GBP_RV t+1
EUR/GBP_RV
EUR/GBP_RV_5
EUR/GBP_RV_22
2012-02-13
0.004019947
0.004467109
0.004995980
0.005150602
2012-02-14
0.004077322
0.004019947
0.004704742
0.005099209
2012-02-15
0.004666244
0.004077322
0.004564522
0.005020790
2012-02-16
0.004582351
0.004666244
0.004532930
0.005011078
2012-02-17
0.003951071
0.004582351
0.004362595
0.004999634
2012-02-21
0.005549329
0.004824547
0.004467109
0.004954358
The head of the df can be reproduced with
structure(list(Date = structure(c(15383, 15384, 15385, 15386,
15387, 15391), class = "Date"), `EUR/GBP_RV t+1,t+22` = c(0.00437808494654599,
0.00439764887779732, 0.00441997330738947, 0.00437799055732722,
0.00435021150904479, 0.00434881306458859), `EUR/GBP_RGV t+1,t+22` = c(0.00310674728131117,
0.00311502965608506, 0.00313756204195853, 0.00312923997431178,
0.00310846773074243, 0.00309755540903969), `EUR/GBP_RBV t+1,t+22` = c(0.00304961980133602,
0.00306866297401415, 0.00307794319983677, 0.00302801249035602,
0.00300946121851254, 0.00302272755554915), `EUR/GBP_RV t+1,t+5` = c(0.00425938711995146,
0.00442030721926592, 0.00471470868108043, 0.00487869292442023,
0.00476849421943949, 0.0046067439660438), `EUR/GBP_RGV t+1,t+5` = c(0.00287718093809447,
0.00311308998902836, 0.00344398536439729, 0.00376911066284235,
0.00377425759242542, 0.00353909902900148), `EUR/GBP_RBV t+1,t+5` = c(0.00313771439501486,
0.00310626895475871, 0.0031789431316576, 0.00305962424370556,
0.00288671182187571, 0.00291630955829613), `EUR/GBP_RV t+1` = c(0.00401994700051122,
0.00407732180013827, 0.00466624428620966, 0.00458235106134663,
0.00395107145155152, 0.00554932910921084), `EUR/GBP_RGV t+1` = c(0.00280067842079775,
0.00275522601341373, 0.00296142025653418, 0.00320716195737542,
0.00266141804235125, 0.00440970289025837), `EUR/GBP_RBV t+1` = c(0.00288377777753365,
0.00300554199386584, 0.00360608177982326, 0.00327292734850446,
0.0029202430753471, 0.00336891287836027), `EUR/GBP_RV` = c(0.00446710941914797,
0.00401994700051122, 0.00407732180013827, 0.00466624428620966,
0.00458235106134663, 0.00482454749708351), `EUR/GBP_RV_5` = c(0.00499598016427624,
0.00470474196716823, 0.00456452150727461, 0.00453292965488229,
0.00436259471347075, 0.00442030721926592), `EUR/GBP_RV_22` = c(0.00515060219897263,
0.00509920878086075, 0.00502079002092667, 0.00501107755050095,
0.00499963428727425, 0.00495435807685843), `EUR/GBP_RBV` = c(0.00324667045338159,
0.00288377777753365, 0.00300554199386584, 0.00360608177982326,
0.00327292734850446, 0.00272655057625291), `EUR/GBP_RBV_5` = c(0.0034985439252634,
0.00318731350301598, 0.00319529774619179, 0.0032799330165155,
0.00320299987062176, 0.00310626895475871), `EUR/GBP_RBV_22` = c(0.0036581887941976,
0.00362298829344015, 0.00355498498935768, 0.0035465419934449,
0.00355752455210586, 0.00351669973034298), `EUR/GBP_RGV` = c(0.00306825643155514,
0.00280067842079775, 0.00275522601341373, 0.00296142025653418,
0.00320716195737542, 0.00398022367546721), `EUR/GBP_RGV_5` = c(0.00353290218424469,
0.00345194162523714, 0.00325362896209417, 0.00312087362386985,
0.00295854861593525, 0.00311308998902836), `EUR/GBP_RGV_22` = c(0.00359974659692405,
0.00356342531619103, 0.00352224165959556, 0.00351722666683608,
0.00349184335907274, 0.00346394410318992), `EUR/GBP_TotalCount` = structure(c(-0.179518680545716,
-0.0757259172924681, 0.333514120677483, 0.759064450015801, -0.419724789788948,
-0.360414639358521), .Dim = c(6L, 1L)), `EUR/GBP_BloombergCount` = structure(c(-0.701694550941621,
-0.669811381311996, -0.574161872423118, -0.644304845608295, -0.784590791978649,
-0.631551577756444), .Dim = c(6L, 1L)), `EUR/GBP_SocialMediaCount` = structure(c(-1.68861759789696,
-1.66829994393287, -1.5910928588693, -1.59515638966212, -1.6967446594826,
-1.63172816679749), .Dim = c(6L, 1L)), `EUR/GBP_NewsCount` = structure(c(0.76560533722738,
0.879161625683434, 1.33717198912285, 1.90306082659552, 0.487392430510049,
0.487392430510049), .Dim = c(6L, 1L))), na.action = structure(c(`6` = 6L,
`38` = 38L, `74` = 74L, `101` = 101L, `140` = 140L, `165` = 165L,
`189` = 189L, `197` = 197L, `236` = 236L, `256` = 256L, `323` = 323L,
`351` = 351L, `393` = 393L, `423` = 423L, `442` = 442L, `455` = 455L,
`490` = 490L, `510` = 510L, `551` = 551L, `576` = 576L, `605` = 605L,
`646` = 646L, `676` = 676L, `696` = 696L, `708` = 708L, `742` = 742L,
`762` = 762L, `793` = 793L, `829` = 829L, `858` = 858L, `904` = 904L,
`929` = 929L, `950` = 950L, `961` = 961L, `996` = 996L, `1016` = 1016L,
`1089` = 1089L, `1114` = 1114L, `1159` = 1159L, `1184` = 1184L,
`1207` = 1207L, `1216` = 1216L, `1238` = 1238L, `1243` = 1243L,
`1253` = 1253L, `1278` = 1278L, `1315` = 1315L, `1346` = 1346L,
`1372` = 1372L, `1416` = 1416L, `1441` = 1441L, `1473` = 1473L,
`1532` = 1532L, `1599` = 1599L, `1626` = 1626L, `1669` = 1669L,
`1694` = 1694L, `1718` = 1718L, `1726` = 1726L, `1766` = 1766L,
`1786` = 1786L, `1827` = 1827L, `1853` = 1853L, `1881` = 1881L,
`1922` = 1922L, `1952` = 1952L, `1971` = 1971L, `1984` = 1984L,
`2019` = 2019L, `2039` = 2039L, `2075` = 2075L, `2106` = 2106L,
`2135` = 2135L, `2181` = 2181L, `2206` = 2206L, `2227` = 2227L,
`2238` = 2238L, `2273` = 2273L, `2293` = 2293L, `2325` = 2325L,
`2366` = 2366L, `2391` = 2391L, `2436` = 2436L, `2461` = 2461L,
`2483` = 2483L, `2493` = 2493L), class = "omit"), row.names = c(1L,
2L, 3L, 4L, 5L, 7L), class = "data.frame")
I have built 9 regression models per forecast horizon (t+1, t+5 and t+22) and I am using the predict function to make my forecasts. I have coded this in an R loop, where I also try to assign each forecast to a matrix. My code is the following:
EUR/GBP_RV t+1`~data.estimateI am trying to calculate realized volatility forecasts using a rolling window forecast. My aim is to use the first 500 observations to forecast the 501st observations, then shift the window forward one step using observations 2 to 501 to predict the 502nd observation. I want this to repeat until I have a complete pseudo out-of-sample forecast.
My df contains 2411 observations of 23 variables, here is small example:
Date
EUR/GBP_RV t+1
EUR/GBP_RV
EUR/GBP_RV_5
EUR/GBP_RV_22
2012-02-13
0.004019947
0.004467109
0.004995980
0.005150602
2012-02-14
0.004077322
0.004019947
0.004704742
0.005099209
2012-02-15
0.004666244
0.004077322
0.004564522
0.005020790
2012-02-16
0.004582351
0.004666244
0.004532930
0.005011078
2012-02-17
0.003951071
0.004582351
0.004362595
0.004999634
2012-02-21
0.005549329
0.004824547
0.004467109
0.004954358
The head of the df can be reproduced with
structure(list(Date = structure(c(15383, 15384, 15385, 15386,
15387, 15391), class = "Date"), `EUR/GBP_RV t+1,t+22` = c(0.00437808494654599,
0.00439764887779732, 0.00441997330738947, 0.00437799055732722,
0.00435021150904479, 0.00434881306458859), `EUR/GBP_RGV t+1,t+22` = c(0.00310674728131117,
0.00311502965608506, 0.00313756204195853, 0.00312923997431178,
0.00310846773074243, 0.00309755540903969), `EUR/GBP_RBV t+1,t+22` = c(0.00304961980133602,
0.00306866297401415, 0.00307794319983677, 0.00302801249035602,
0.00300946121851254, 0.00302272755554915), `EUR/GBP_RV t+1,t+5` = c(0.00425938711995146,
0.00442030721926592, 0.00471470868108043, 0.00487869292442023,
0.00476849421943949, 0.0046067439660438), `EUR/GBP_RGV t+1,t+5` = c(0.00287718093809447,
0.00311308998902836, 0.00344398536439729, 0.00376911066284235,
0.00377425759242542, 0.00353909902900148), `EUR/GBP_RBV t+1,t+5` = c(0.00313771439501486,
0.00310626895475871, 0.0031789431316576, 0.00305962424370556,
0.00288671182187571, 0.00291630955829613), `EUR/GBP_RV t+1` = c(0.00401994700051122,
0.00407732180013827, 0.00466624428620966, 0.00458235106134663,
0.00395107145155152, 0.00554932910921084), `EUR/GBP_RGV t+1` = c(0.00280067842079775,
0.00275522601341373, 0.00296142025653418, 0.00320716195737542,
0.00266141804235125, 0.00440970289025837), `EUR/GBP_RBV t+1` = c(0.00288377777753365,
0.00300554199386584, 0.00360608177982326, 0.00327292734850446,
0.0029202430753471, 0.00336891287836027), `EUR/GBP_RV` = c(0.00446710941914797,
0.00401994700051122, 0.00407732180013827, 0.00466624428620966,
0.00458235106134663, 0.00482454749708351), `EUR/GBP_RV_5` = c(0.00499598016427624,
0.00470474196716823, 0.00456452150727461, 0.00453292965488229,
0.00436259471347075, 0.00442030721926592), `EUR/GBP_RV_22` = c(0.00515060219897263,
0.00509920878086075, 0.00502079002092667, 0.00501107755050095,
0.00499963428727425, 0.00495435807685843), `EUR/GBP_RBV` = c(0.00324667045338159,
0.00288377777753365, 0.00300554199386584, 0.00360608177982326,
0.00327292734850446, 0.00272655057625291), `EUR/GBP_RBV_5` = c(0.0034985439252634,
0.00318731350301598, 0.00319529774619179, 0.0032799330165155,
0.00320299987062176, 0.00310626895475871), `EUR/GBP_RBV_22` = c(0.0036581887941976,
0.00362298829344015, 0.00355498498935768, 0.0035465419934449,
0.00355752455210586, 0.00351669973034298), `EUR/GBP_RGV` = c(0.00306825643155514,
0.00280067842079775, 0.00275522601341373, 0.00296142025653418,
0.00320716195737542, 0.00398022367546721), `EUR/GBP_RGV_5` = c(0.00353290218424469,
0.00345194162523714, 0.00325362896209417, 0.00312087362386985,
0.00295854861593525, 0.00311308998902836), `EUR/GBP_RGV_22` = c(0.00359974659692405,
0.00356342531619103, 0.00352224165959556, 0.00351722666683608,
0.00349184335907274, 0.00346394410318992), `EUR/GBP_TotalCount` = structure(c(-0.179518680545716,
-0.0757259172924681, 0.333514120677483, 0.759064450015801, -0.419724789788948,
-0.360414639358521), .Dim = c(6L, 1L)), `EUR/GBP_BloombergCount` = structure(c(-0.701694550941621,
-0.669811381311996, -0.574161872423118, -0.644304845608295, -0.784590791978649,
-0.631551577756444), .Dim = c(6L, 1L)), `EUR/GBP_SocialMediaCount` = structure(c(-1.68861759789696,
-1.66829994393287, -1.5910928588693, -1.59515638966212, -1.6967446594826,
-1.63172816679749), .Dim = c(6L, 1L)), `EUR/GBP_NewsCount` = structure(c(0.76560533722738,
0.879161625683434, 1.33717198912285, 1.90306082659552, 0.487392430510049,
0.487392430510049), .Dim = c(6L, 1L))), na.action = structure(c(`6` = 6L,
`38` = 38L, `74` = 74L, `101` = 101L, `140` = 140L, `165` = 165L,
`189` = 189L, `197` = 197L, `236` = 236L, `256` = 256L, `323` = 323L,
`351` = 351L, `393` = 393L, `423` = 423L, `442` = 442L, `455` = 455L,
`490` = 490L, `510` = 510L, `551` = 551L, `576` = 576L, `605` = 605L,
`646` = 646L, `676` = 676L, `696` = 696L, `708` = 708L, `742` = 742L,
`762` = 762L, `793` = 793L, `829` = 829L, `858` = 858L, `904` = 904L,
`929` = 929L, `950` = 950L, `961` = 961L, `996` = 996L, `1016` = 1016L,
`1089` = 1089L, `1114` = 1114L, `1159` = 1159L, `1184` = 1184L,
`1207` = 1207L, `1216` = 1216L, `1238` = 1238L, `1243` = 1243L,
`1253` = 1253L, `1278` = 1278L, `1315` = 1315L, `1346` = 1346L,
`1372` = 1372L, `1416` = 1416L, `1441` = 1441L, `1473` = 1473L,
`1532` = 1532L, `1599` = 1599L, `1626` = 1626L, `1669` = 1669L,
`1694` = 1694L, `1718` = 1718L, `1726` = 1726L, `1766` = 1766L,
`1786` = 1786L, `1827` = 1827L, `1853` = 1853L, `1881` = 1881L,
`1922` = 1922L, `1952` = 1952L, `1971` = 1971L, `1984` = 1984L,
`2019` = 2019L, `2039` = 2039L, `2075` = 2075L, `2106` = 2106L,
`2135` = 2135L, `2181` = 2181L, `2206` = 2206L, `2227` = 2227L,
`2238` = 2238L, `2273` = 2273L, `2293` = 2293L, `2325` = 2325L,
`2366` = 2366L, `2391` = 2391L, `2436` = 2436L, `2461` = 2461L,
`2483` = 2483L, `2493` = 2493L), class = "omit"), row.names = c(1L,
2L, 3L, 4L, 5L, 7L), class = "data.frame")
I have built 9 regression models per forecast horizon (t+1, t+5 and t+22) and I am using the predict function to make my forecasts. I have coded this in an R loop, where I also try to assign each forecast to a matrix. My code is the following:
EUR/GBP_RV`+data.estimateI am trying to calculate realized volatility forecasts using a rolling window forecast. My aim is to use the first 500 observations to forecast the 501st observations, then shift the window forward one step using observations 2 to 501 to predict the 502nd observation. I want this to repeat until I have a complete pseudo out-of-sample forecast.
My df contains 2411 observations of 23 variables, here is small example:
Date
EUR/GBP_RV t+1
EUR/GBP_RV
EUR/GBP_RV_5
EUR/GBP_RV_22
2012-02-13
0.004019947
0.004467109
0.004995980
0.005150602
2012-02-14
0.004077322
0.004019947
0.004704742
0.005099209
2012-02-15
0.004666244
0.004077322
0.004564522
0.005020790
2012-02-16
0.004582351
0.004666244
0.004532930
0.005011078
2012-02-17
0.003951071
0.004582351
0.004362595
0.004999634
2012-02-21
0.005549329
0.004824547
0.004467109
0.004954358
The head of the df can be reproduced with
structure(list(Date = structure(c(15383, 15384, 15385, 15386,
15387, 15391), class = "Date"), `EUR/GBP_RV t+1,t+22` = c(0.00437808494654599,
0.00439764887779732, 0.00441997330738947, 0.00437799055732722,
0.00435021150904479, 0.00434881306458859), `EUR/GBP_RGV t+1,t+22` = c(0.00310674728131117,
0.00311502965608506, 0.00313756204195853, 0.00312923997431178,
0.00310846773074243, 0.00309755540903969), `EUR/GBP_RBV t+1,t+22` = c(0.00304961980133602,
0.00306866297401415, 0.00307794319983677, 0.00302801249035602,
0.00300946121851254, 0.00302272755554915), `EUR/GBP_RV t+1,t+5` = c(0.00425938711995146,
0.00442030721926592, 0.00471470868108043, 0.00487869292442023,
0.00476849421943949, 0.0046067439660438), `EUR/GBP_RGV t+1,t+5` = c(0.00287718093809447,
0.00311308998902836, 0.00344398536439729, 0.00376911066284235,
0.00377425759242542, 0.00353909902900148), `EUR/GBP_RBV t+1,t+5` = c(0.00313771439501486,
0.00310626895475871, 0.0031789431316576, 0.00305962424370556,
0.00288671182187571, 0.00291630955829613), `EUR/GBP_RV t+1` = c(0.00401994700051122,
0.00407732180013827, 0.00466624428620966, 0.00458235106134663,
0.00395107145155152, 0.00554932910921084), `EUR/GBP_RGV t+1` = c(0.00280067842079775,
0.00275522601341373, 0.00296142025653418, 0.00320716195737542,
0.00266141804235125, 0.00440970289025837), `EUR/GBP_RBV t+1` = c(0.00288377777753365,
0.00300554199386584, 0.00360608177982326, 0.00327292734850446,
0.0029202430753471, 0.00336891287836027), `EUR/GBP_RV` = c(0.00446710941914797,
0.00401994700051122, 0.00407732180013827, 0.00466624428620966,
0.00458235106134663, 0.00482454749708351), `EUR/GBP_RV_5` = c(0.00499598016427624,
0.00470474196716823, 0.00456452150727461, 0.00453292965488229,
0.00436259471347075, 0.00442030721926592), `EUR/GBP_RV_22` = c(0.00515060219897263,
0.00509920878086075, 0.00502079002092667, 0.00501107755050095,
0.00499963428727425, 0.00495435807685843), `EUR/GBP_RBV` = c(0.00324667045338159,
0.00288377777753365, 0.00300554199386584, 0.00360608177982326,
0.00327292734850446, 0.00272655057625291), `EUR/GBP_RBV_5` = c(0.0034985439252634,
0.00318731350301598, 0.00319529774619179, 0.0032799330165155,
0.00320299987062176, 0.00310626895475871), `EUR/GBP_RBV_22` = c(0.0036581887941976,
0.00362298829344015, 0.00355498498935768, 0.0035465419934449,
0.00355752455210586, 0.00351669973034298), `EUR/GBP_RGV` = c(0.00306825643155514,
0.00280067842079775, 0.00275522601341373, 0.00296142025653418,
0.00320716195737542, 0.00398022367546721), `EUR/GBP_RGV_5` = c(0.00353290218424469,
0.00345194162523714, 0.00325362896209417, 0.00312087362386985,
0.00295854861593525, 0.00311308998902836), `EUR/GBP_RGV_22` = c(0.00359974659692405,
0.00356342531619103, 0.00352224165959556, 0.00351722666683608,
0.00349184335907274, 0.00346394410318992), `EUR/GBP_TotalCount` = structure(c(-0.179518680545716,
-0.0757259172924681, 0.333514120677483, 0.759064450015801, -0.419724789788948,
-0.360414639358521), .Dim = c(6L, 1L)), `EUR/GBP_BloombergCount` = structure(c(-0.701694550941621,
-0.669811381311996, -0.574161872423118, -0.644304845608295, -0.784590791978649,
-0.631551577756444), .Dim = c(6L, 1L)), `EUR/GBP_SocialMediaCount` = structure(c(-1.68861759789696,
-1.66829994393287, -1.5910928588693, -1.59515638966212, -1.6967446594826,
-1.63172816679749), .Dim = c(6L, 1L)), `EUR/GBP_NewsCount` = structure(c(0.76560533722738,
0.879161625683434, 1.33717198912285, 1.90306082659552, 0.487392430510049,
0.487392430510049), .Dim = c(6L, 1L))), na.action = structure(c(`6` = 6L,
`38` = 38L, `74` = 74L, `101` = 101L, `140` = 140L, `165` = 165L,
`189` = 189L, `197` = 197L, `236` = 236L, `256` = 256L, `323` = 323L,
`351` = 351L, `393` = 393L, `423` = 423L, `442` = 442L, `455` = 455L,
`490` = 490L, `510` = 510L, `551` = 551L, `576` = 576L, `605` = 605L,
`646` = 646L, `676` = 676L, `696` = 696L, `708` = 708L, `742` = 742L,
`762` = 762L, `793` = 793L, `829` = 829L, `858` = 858L, `904` = 904L,
`929` = 929L, `950` = 950L, `961` = 961L, `996` = 996L, `1016` = 1016L,
`1089` = 1089L, `1114` = 1114L, `1159` = 1159L, `1184` = 1184L,
`1207` = 1207L, `1216` = 1216L, `1238` = 1238L, `1243` = 1243L,
`1253` = 1253L, `1278` = 1278L, `1315` = 1315L, `1346` = 1346L,
`1372` = 1372L, `1416` = 1416L, `1441` = 1441L, `1473` = 1473L,
`1532` = 1532L, `1599` = 1599L, `1626` = 1626L, `1669` = 1669L,
`1694` = 1694L, `1718` = 1718L, `1726` = 1726L, `1766` = 1766L,
`1786` = 1786L, `1827` = 1827L, `1853` = 1853L, `1881` = 1881L,
`1922` = 1922L, `1952` = 1952L, `1971` = 1971L, `1984` = 1984L,
`2019` = 2019L, `2039` = 2039L, `2075` = 2075L, `2106` = 2106L,
`2135` = 2135L, `2181` = 2181L, `2206` = 2206L, `2227` = 2227L,
`2238` = 2238L, `2273` = 2273L, `2293` = 2293L, `2325` = 2325L,
`2366` = 2366L, `2391` = 2391L, `2436` = 2436L, `2461` = 2461L,
`2483` = 2483L, `2493` = 2493L), class = "omit"), row.names = c(1L,
2L, 3L, 4L, 5L, 7L), class = "data.frame")
I have built 9 regression models per forecast horizon (t+1, t+5 and t+22) and I am using the predict function to make my forecasts. I have coded this in an R loop, where I also try to assign each forecast to a matrix. My code is the following:
EUR/GBP_RV_5`+data.estimateI am trying to calculate realized volatility forecasts using a rolling window forecast. My aim is to use the first 500 observations to forecast the 501st observations, then shift the window forward one step using observations 2 to 501 to predict the 502nd observation. I want this to repeat until I have a complete pseudo out-of-sample forecast.
My df contains 2411 observations of 23 variables, here is small example:
Date
EUR/GBP_RV t+1
EUR/GBP_RV
EUR/GBP_RV_5
EUR/GBP_RV_22
2012-02-13
0.004019947
0.004467109
0.004995980
0.005150602
2012-02-14
0.004077322
0.004019947
0.004704742
0.005099209
2012-02-15
0.004666244
0.004077322
0.004564522
0.005020790
2012-02-16
0.004582351
0.004666244
0.004532930
0.005011078
2012-02-17
0.003951071
0.004582351
0.004362595
0.004999634
2012-02-21
0.005549329
0.004824547
0.004467109
0.004954358
The head of the df can be reproduced with
structure(list(Date = structure(c(15383, 15384, 15385, 15386,
15387, 15391), class = "Date"), `EUR/GBP_RV t+1,t+22` = c(0.00437808494654599,
0.00439764887779732, 0.00441997330738947, 0.00437799055732722,
0.00435021150904479, 0.00434881306458859), `EUR/GBP_RGV t+1,t+22` = c(0.00310674728131117,
0.00311502965608506, 0.00313756204195853, 0.00312923997431178,
0.00310846773074243, 0.00309755540903969), `EUR/GBP_RBV t+1,t+22` = c(0.00304961980133602,
0.00306866297401415, 0.00307794319983677, 0.00302801249035602,
0.00300946121851254, 0.00302272755554915), `EUR/GBP_RV t+1,t+5` = c(0.00425938711995146,
0.00442030721926592, 0.00471470868108043, 0.00487869292442023,
0.00476849421943949, 0.0046067439660438), `EUR/GBP_RGV t+1,t+5` = c(0.00287718093809447,
0.00311308998902836, 0.00344398536439729, 0.00376911066284235,
0.00377425759242542, 0.00353909902900148), `EUR/GBP_RBV t+1,t+5` = c(0.00313771439501486,
0.00310626895475871, 0.0031789431316576, 0.00305962424370556,
0.00288671182187571, 0.00291630955829613), `EUR/GBP_RV t+1` = c(0.00401994700051122,
0.00407732180013827, 0.00466624428620966, 0.00458235106134663,
0.00395107145155152, 0.00554932910921084), `EUR/GBP_RGV t+1` = c(0.00280067842079775,
0.00275522601341373, 0.00296142025653418, 0.00320716195737542,
0.00266141804235125, 0.00440970289025837), `EUR/GBP_RBV t+1` = c(0.00288377777753365,
0.00300554199386584, 0.00360608177982326, 0.00327292734850446,
0.0029202430753471, 0.00336891287836027), `EUR/GBP_RV` = c(0.00446710941914797,
0.00401994700051122, 0.00407732180013827, 0.00466624428620966,
0.00458235106134663, 0.00482454749708351), `EUR/GBP_RV_5` = c(0.00499598016427624,
0.00470474196716823, 0.00456452150727461, 0.00453292965488229,
0.00436259471347075, 0.00442030721926592), `EUR/GBP_RV_22` = c(0.00515060219897263,
0.00509920878086075, 0.00502079002092667, 0.00501107755050095,
0.00499963428727425, 0.00495435807685843), `EUR/GBP_RBV` = c(0.00324667045338159,
0.00288377777753365, 0.00300554199386584, 0.00360608177982326,
0.00327292734850446, 0.00272655057625291), `EUR/GBP_RBV_5` = c(0.0034985439252634,
0.00318731350301598, 0.00319529774619179, 0.0032799330165155,
0.00320299987062176, 0.00310626895475871), `EUR/GBP_RBV_22` = c(0.0036581887941976,
0.00362298829344015, 0.00355498498935768, 0.0035465419934449,
0.00355752455210586, 0.00351669973034298), `EUR/GBP_RGV` = c(0.00306825643155514,
0.00280067842079775, 0.00275522601341373, 0.00296142025653418,
0.00320716195737542, 0.00398022367546721), `EUR/GBP_RGV_5` = c(0.00353290218424469,
0.00345194162523714, 0.00325362896209417, 0.00312087362386985,
0.00295854861593525, 0.00311308998902836), `EUR/GBP_RGV_22` = c(0.00359974659692405,
0.00356342531619103, 0.00352224165959556, 0.00351722666683608,
0.00349184335907274, 0.00346394410318992), `EUR/GBP_TotalCount` = structure(c(-0.179518680545716,
-0.0757259172924681, 0.333514120677483, 0.759064450015801, -0.419724789788948,
-0.360414639358521), .Dim = c(6L, 1L)), `EUR/GBP_BloombergCount` = structure(c(-0.701694550941621,
-0.669811381311996, -0.574161872423118, -0.644304845608295, -0.784590791978649,
-0.631551577756444), .Dim = c(6L, 1L)), `EUR/GBP_SocialMediaCount` = structure(c(-1.68861759789696,
-1.66829994393287, -1.5910928588693, -1.59515638966212, -1.6967446594826,
-1.63172816679749), .Dim = c(6L, 1L)), `EUR/GBP_NewsCount` = structure(c(0.76560533722738,
0.879161625683434, 1.33717198912285, 1.90306082659552, 0.487392430510049,
0.487392430510049), .Dim = c(6L, 1L))), na.action = structure(c(`6` = 6L,
`38` = 38L, `74` = 74L, `101` = 101L, `140` = 140L, `165` = 165L,
`189` = 189L, `197` = 197L, `236` = 236L, `256` = 256L, `323` = 323L,
`351` = 351L, `393` = 393L, `423` = 423L, `442` = 442L, `455` = 455L,
`490` = 490L, `510` = 510L, `551` = 551L, `576` = 576L, `605` = 605L,
`646` = 646L, `676` = 676L, `696` = 696L, `708` = 708L, `742` = 742L,
`762` = 762L, `793` = 793L, `829` = 829L, `858` = 858L, `904` = 904L,
`929` = 929L, `950` = 950L, `961` = 961L, `996` = 996L, `1016` = 1016L,
`1089` = 1089L, `1114` = 1114L, `1159` = 1159L, `1184` = 1184L,
`1207` = 1207L, `1216` = 1216L, `1238` = 1238L, `1243` = 1243L,
`1253` = 1253L, `1278` = 1278L, `1315` = 1315L, `1346` = 1346L,
`1372` = 1372L, `1416` = 1416L, `1441` = 1441L, `1473` = 1473L,
`1532` = 1532L, `1599` = 1599L, `1626` = 1626L, `1669` = 1669L,
`1694` = 1694L, `1718` = 1718L, `1726` = 1726L, `1766` = 1766L,
`1786` = 1786L, `1827` = 1827L, `1853` = 1853L, `1881` = 1881L,
`1922` = 1922L, `1952` = 1952L, `1971` = 1971L, `1984` = 1984L,
`2019` = 2019L, `2039` = 2039L, `2075` = 2075L, `2106` = 2106L,
`2135` = 2135L, `2181` = 2181L, `2206` = 2206L, `2227` = 2227L,
`2238` = 2238L, `2273` = 2273L, `2293` = 2293L, `2325` = 2325L,
`2366` = 2366L, `2391` = 2391L, `2436` = 2436L, `2461` = 2461L,
`2483` = 2483L, `2493` = 2493L), class = "omit"), row.names = c(1L,
2L, 3L, 4L, 5L, 7L), class = "data.frame")
I have built 9 regression models per forecast horizon (t+1, t+5 and t+22) and I am using the predict function to make my forecasts. I have coded this in an R loop, where I also try to assign each forecast to a matrix. My code is the following:
EUR/GBP_RV_22`+data.estimateI am trying to calculate realized volatility forecasts using a rolling window forecast. My aim is to use the first 500 observations to forecast the 501st observations, then shift the window forward one step using observations 2 to 501 to predict the 502nd observation. I want this to repeat until I have a complete pseudo out-of-sample forecast.
My df contains 2411 observations of 23 variables, here is small example:
Date
EUR/GBP_RV t+1
EUR/GBP_RV
EUR/GBP_RV_5
EUR/GBP_RV_22
2012-02-13
0.004019947
0.004467109
0.004995980
0.005150602
2012-02-14
0.004077322
0.004019947
0.004704742
0.005099209
2012-02-15
0.004666244
0.004077322
0.004564522
0.005020790
2012-02-16
0.004582351
0.004666244
0.004532930
0.005011078
2012-02-17
0.003951071
0.004582351
0.004362595
0.004999634
2012-02-21
0.005549329
0.004824547
0.004467109
0.004954358
The head of the df can be reproduced with
structure(list(Date = structure(c(15383, 15384, 15385, 15386,
15387, 15391), class = "Date"), `EUR/GBP_RV t+1,t+22` = c(0.00437808494654599,
0.00439764887779732, 0.00441997330738947, 0.00437799055732722,
0.00435021150904479, 0.00434881306458859), `EUR/GBP_RGV t+1,t+22` = c(0.00310674728131117,
0.00311502965608506, 0.00313756204195853, 0.00312923997431178,
0.00310846773074243, 0.00309755540903969), `EUR/GBP_RBV t+1,t+22` = c(0.00304961980133602,
0.00306866297401415, 0.00307794319983677, 0.00302801249035602,
0.00300946121851254, 0.00302272755554915), `EUR/GBP_RV t+1,t+5` = c(0.00425938711995146,
0.00442030721926592, 0.00471470868108043, 0.00487869292442023,
0.00476849421943949, 0.0046067439660438), `EUR/GBP_RGV t+1,t+5` = c(0.00287718093809447,
0.00311308998902836, 0.00344398536439729, 0.00376911066284235,
0.00377425759242542, 0.00353909902900148), `EUR/GBP_RBV t+1,t+5` = c(0.00313771439501486,
0.00310626895475871, 0.0031789431316576, 0.00305962424370556,
0.00288671182187571, 0.00291630955829613), `EUR/GBP_RV t+1` = c(0.00401994700051122,
0.00407732180013827, 0.00466624428620966, 0.00458235106134663,
0.00395107145155152, 0.00554932910921084), `EUR/GBP_RGV t+1` = c(0.00280067842079775,
0.00275522601341373, 0.00296142025653418, 0.00320716195737542,
0.00266141804235125, 0.00440970289025837), `EUR/GBP_RBV t+1` = c(0.00288377777753365,
0.00300554199386584, 0.00360608177982326, 0.00327292734850446,
0.0029202430753471, 0.00336891287836027), `EUR/GBP_RV` = c(0.00446710941914797,
0.00401994700051122, 0.00407732180013827, 0.00466624428620966,
0.00458235106134663, 0.00482454749708351), `EUR/GBP_RV_5` = c(0.00499598016427624,
0.00470474196716823, 0.00456452150727461, 0.00453292965488229,
0.00436259471347075, 0.00442030721926592), `EUR/GBP_RV_22` = c(0.00515060219897263,
0.00509920878086075, 0.00502079002092667, 0.00501107755050095,
0.00499963428727425, 0.00495435807685843), `EUR/GBP_RBV` = c(0.00324667045338159,
0.00288377777753365, 0.00300554199386584, 0.00360608177982326,
0.00327292734850446, 0.00272655057625291), `EUR/GBP_RBV_5` = c(0.0034985439252634,
0.00318731350301598, 0.00319529774619179, 0.0032799330165155,
0.00320299987062176, 0.00310626895475871), `EUR/GBP_RBV_22` = c(0.0036581887941976,
0.00362298829344015, 0.00355498498935768, 0.0035465419934449,
0.00355752455210586, 0.00351669973034298), `EUR/GBP_RGV` = c(0.00306825643155514,
0.00280067842079775, 0.00275522601341373, 0.00296142025653418,
0.00320716195737542, 0.00398022367546721), `EUR/GBP_RGV_5` = c(0.00353290218424469,
0.00345194162523714, 0.00325362896209417, 0.00312087362386985,
0.00295854861593525, 0.00311308998902836), `EUR/GBP_RGV_22` = c(0.00359974659692405,
0.00356342531619103, 0.00352224165959556, 0.00351722666683608,
0.00349184335907274, 0.00346394410318992), `EUR/GBP_TotalCount` = structure(c(-0.179518680545716,
-0.0757259172924681, 0.333514120677483, 0.759064450015801, -0.419724789788948,
-0.360414639358521), .Dim = c(6L, 1L)), `EUR/GBP_BloombergCount` = structure(c(-0.701694550941621,
-0.669811381311996, -0.574161872423118, -0.644304845608295, -0.784590791978649,
-0.631551577756444), .Dim = c(6L, 1L)), `EUR/GBP_SocialMediaCount` = structure(c(-1.68861759789696,
-1.66829994393287, -1.5910928588693, -1.59515638966212, -1.6967446594826,
-1.63172816679749), .Dim = c(6L, 1L)), `EUR/GBP_NewsCount` = structure(c(0.76560533722738,
0.879161625683434, 1.33717198912285, 1.90306082659552, 0.487392430510049,
0.487392430510049), .Dim = c(6L, 1L))), na.action = structure(c(`6` = 6L,
`38` = 38L, `74` = 74L, `101` = 101L, `140` = 140L, `165` = 165L,
`189` = 189L, `197` = 197L, `236` = 236L, `256` = 256L, `323` = 323L,
`351` = 351L, `393` = 393L, `423` = 423L, `442` = 442L, `455` = 455L,
`490` = 490L, `510` = 510L, `551` = 551L, `576` = 576L, `605` = 605L,
`646` = 646L, `676` = 676L, `696` = 696L, `708` = 708L, `742` = 742L,
`762` = 762L, `793` = 793L, `829` = 829L, `858` = 858L, `904` = 904L,
`929` = 929L, `950` = 950L, `961` = 961L, `996` = 996L, `1016` = 1016L,
`1089` = 1089L, `1114` = 1114L, `1159` = 1159L, `1184` = 1184L,
`1207` = 1207L, `1216` = 1216L, `1238` = 1238L, `1243` = 1243L,
`1253` = 1253L, `1278` = 1278L, `1315` = 1315L, `1346` = 1346L,
`1372` = 1372L, `1416` = 1416L, `1441` = 1441L, `1473` = 1473L,
`1532` = 1532L, `1599` = 1599L, `1626` = 1626L, `1669` = 1669L,
`1694` = 1694L, `1718` = 1718L, `1726` = 1726L, `1766` = 1766L,
`1786` = 1786L, `1827` = 1827L, `1853` = 1853L, `1881` = 1881L,
`1922` = 1922L, `1952` = 1952L, `1971` = 1971L, `1984` = 1984L,
`2019` = 2019L, `2039` = 2039L, `2075` = 2075L, `2106` = 2106L,
`2135` = 2135L, `2181` = 2181L, `2206` = 2206L, `2227` = 2227L,
`2238` = 2238L, `2273` = 2273L, `2293` = 2293L, `2325` = 2325L,
`2366` = 2366L, `2391` = 2391L, `2436` = 2436L, `2461` = 2461L,
`2483` = 2483L, `2493` = 2493L), class = "omit"), row.names = c(1L,
2L, 3L, 4L, 5L, 7L), class = "data.frame")
I have built 9 regression models per forecast horizon (t+1, t+5 and t+22) and I am using the predict function to make my forecasts. I have coded this in an R loop, where I also try to assign each forecast to a matrix. My code is the following:
EUR/GBP_NewsCount`)
EURGBP_forecast.1[, 1 ] <- predict( EURGBP_HAR_RV_train, newdata=data.forecast )
EURGBP_forecast.1[, 2 ] <- predict( EURGBP_HAR_RV_NT_train, newdata=data.forecast )
EURGBP_forecast.1[, 3 ] <- predict( EURGBP_HAR_RVB_train, newdata=data.forecast )
EURGBP_forecast.1[, 4 ] <- predict( EURGBP_HAR_RVB_NT_train, newdata=data.forecast )
EURGBP_forecast.1[, 5 ] <- predict( EURGBP_HAR_RVG_train, newdata=data.forecast )
EURGBP_forecast.1[, 6 ] <- predict( EURGBP_HAR_RVG_NT_train, newdata=data.forecast )
EURGBP_forecast.1[, 7 ] <- predict( EURGBP_HAR_RV_Bloomberg_train, newdata=data.forecast )
EURGBP_forecast.1[, 8 ] <- predict( EURGBP_HAR_RV_SocialMedia_train, newdata=data.forecast )
EURGBP_forecast.1[, 9 ] <- predict( EURGBP_HAR_RV_News_train, newdata=data.forecast )
EURGBP_actuals.1[ , 1] <- data.forecastI am trying to calculate realized volatility forecasts using a rolling window forecast. My aim is to use the first 500 observations to forecast the 501st observations, then shift the window forward one step using observations 2 to 501 to predict the 502nd observation. I want this to repeat until I have a complete pseudo out-of-sample forecast.
My df contains 2411 observations of 23 variables, here is small example:
Date
EUR/GBP_RV t+1
EUR/GBP_RV
EUR/GBP_RV_5
EUR/GBP_RV_22
2012-02-13
0.004019947
0.004467109
0.004995980
0.005150602
2012-02-14
0.004077322
0.004019947
0.004704742
0.005099209
2012-02-15
0.004666244
0.004077322
0.004564522
0.005020790
2012-02-16
0.004582351
0.004666244
0.004532930
0.005011078
2012-02-17
0.003951071
0.004582351
0.004362595
0.004999634
2012-02-21
0.005549329
0.004824547
0.004467109
0.004954358
The head of the df can be reproduced with
structure(list(Date = structure(c(15383, 15384, 15385, 15386,
15387, 15391), class = "Date"), `EUR/GBP_RV t+1,t+22` = c(0.00437808494654599,
0.00439764887779732, 0.00441997330738947, 0.00437799055732722,
0.00435021150904479, 0.00434881306458859), `EUR/GBP_RGV t+1,t+22` = c(0.00310674728131117,
0.00311502965608506, 0.00313756204195853, 0.00312923997431178,
0.00310846773074243, 0.00309755540903969), `EUR/GBP_RBV t+1,t+22` = c(0.00304961980133602,
0.00306866297401415, 0.00307794319983677, 0.00302801249035602,
0.00300946121851254, 0.00302272755554915), `EUR/GBP_RV t+1,t+5` = c(0.00425938711995146,
0.00442030721926592, 0.00471470868108043, 0.00487869292442023,
0.00476849421943949, 0.0046067439660438), `EUR/GBP_RGV t+1,t+5` = c(0.00287718093809447,
0.00311308998902836, 0.00344398536439729, 0.00376911066284235,
0.00377425759242542, 0.00353909902900148), `EUR/GBP_RBV t+1,t+5` = c(0.00313771439501486,
0.00310626895475871, 0.0031789431316576, 0.00305962424370556,
0.00288671182187571, 0.00291630955829613), `EUR/GBP_RV t+1` = c(0.00401994700051122,
0.00407732180013827, 0.00466624428620966, 0.00458235106134663,
0.00395107145155152, 0.00554932910921084), `EUR/GBP_RGV t+1` = c(0.00280067842079775,
0.00275522601341373, 0.00296142025653418, 0.00320716195737542,
0.00266141804235125, 0.00440970289025837), `EUR/GBP_RBV t+1` = c(0.00288377777753365,
0.00300554199386584, 0.00360608177982326, 0.00327292734850446,
0.0029202430753471, 0.00336891287836027), `EUR/GBP_RV` = c(0.00446710941914797,
0.00401994700051122, 0.00407732180013827, 0.00466624428620966,
0.00458235106134663, 0.00482454749708351), `EUR/GBP_RV_5` = c(0.00499598016427624,
0.00470474196716823, 0.00456452150727461, 0.00453292965488229,
0.00436259471347075, 0.00442030721926592), `EUR/GBP_RV_22` = c(0.00515060219897263,
0.00509920878086075, 0.00502079002092667, 0.00501107755050095,
0.00499963428727425, 0.00495435807685843), `EUR/GBP_RBV` = c(0.00324667045338159,
0.00288377777753365, 0.00300554199386584, 0.00360608177982326,
0.00327292734850446, 0.00272655057625291), `EUR/GBP_RBV_5` = c(0.0034985439252634,
0.00318731350301598, 0.00319529774619179, 0.0032799330165155,
0.00320299987062176, 0.00310626895475871), `EUR/GBP_RBV_22` = c(0.0036581887941976,
0.00362298829344015, 0.00355498498935768, 0.0035465419934449,
0.00355752455210586, 0.00351669973034298), `EUR/GBP_RGV` = c(0.00306825643155514,
0.00280067842079775, 0.00275522601341373, 0.00296142025653418,
0.00320716195737542, 0.00398022367546721), `EUR/GBP_RGV_5` = c(0.00353290218424469,
0.00345194162523714, 0.00325362896209417, 0.00312087362386985,
0.00295854861593525, 0.00311308998902836), `EUR/GBP_RGV_22` = c(0.00359974659692405,
0.00356342531619103, 0.00352224165959556, 0.00351722666683608,
0.00349184335907274, 0.00346394410318992), `EUR/GBP_TotalCount` = structure(c(-0.179518680545716,
-0.0757259172924681, 0.333514120677483, 0.759064450015801, -0.419724789788948,
-0.360414639358521), .Dim = c(6L, 1L)), `EUR/GBP_BloombergCount` = structure(c(-0.701694550941621,
-0.669811381311996, -0.574161872423118, -0.644304845608295, -0.784590791978649,
-0.631551577756444), .Dim = c(6L, 1L)), `EUR/GBP_SocialMediaCount` = structure(c(-1.68861759789696,
-1.66829994393287, -1.5910928588693, -1.59515638966212, -1.6967446594826,
-1.63172816679749), .Dim = c(6L, 1L)), `EUR/GBP_NewsCount` = structure(c(0.76560533722738,
0.879161625683434, 1.33717198912285, 1.90306082659552, 0.487392430510049,
0.487392430510049), .Dim = c(6L, 1L))), na.action = structure(c(`6` = 6L,
`38` = 38L, `74` = 74L, `101` = 101L, `140` = 140L, `165` = 165L,
`189` = 189L, `197` = 197L, `236` = 236L, `256` = 256L, `323` = 323L,
`351` = 351L, `393` = 393L, `423` = 423L, `442` = 442L, `455` = 455L,
`490` = 490L, `510` = 510L, `551` = 551L, `576` = 576L, `605` = 605L,
`646` = 646L, `676` = 676L, `696` = 696L, `708` = 708L, `742` = 742L,
`762` = 762L, `793` = 793L, `829` = 829L, `858` = 858L, `904` = 904L,
`929` = 929L, `950` = 950L, `961` = 961L, `996` = 996L, `1016` = 1016L,
`1089` = 1089L, `1114` = 1114L, `1159` = 1159L, `1184` = 1184L,
`1207` = 1207L, `1216` = 1216L, `1238` = 1238L, `1243` = 1243L,
`1253` = 1253L, `1278` = 1278L, `1315` = 1315L, `1346` = 1346L,
`1372` = 1372L, `1416` = 1416L, `1441` = 1441L, `1473` = 1473L,
`1532` = 1532L, `1599` = 1599L, `1626` = 1626L, `1669` = 1669L,
`1694` = 1694L, `1718` = 1718L, `1726` = 1726L, `1766` = 1766L,
`1786` = 1786L, `1827` = 1827L, `1853` = 1853L, `1881` = 1881L,
`1922` = 1922L, `1952` = 1952L, `1971` = 1971L, `1984` = 1984L,
`2019` = 2019L, `2039` = 2039L, `2075` = 2075L, `2106` = 2106L,
`2135` = 2135L, `2181` = 2181L, `2206` = 2206L, `2227` = 2227L,
`2238` = 2238L, `2273` = 2273L, `2293` = 2293L, `2325` = 2325L,
`2366` = 2366L, `2391` = 2391L, `2436` = 2436L, `2461` = 2461L,
`2483` = 2483L, `2493` = 2493L), class = "omit"), row.names = c(1L,
2L, 3L, 4L, 5L, 7L), class = "data.frame")
I have built 9 regression models per forecast horizon (t+1, t+5 and t+22) and I am using the predict function to make my forecasts. I have coded this in an R loop, where I also try to assign each forecast to a matrix. My code is the following:
EUR/GBP_RV t+1`
# --------------------------------------
# Forecast horizon 5
# --------------------------------------
EURGBP_HAR_RVt5_train <- lm(data.estimateI am trying to calculate realized volatility forecasts using a rolling window forecast. My aim is to use the first 500 observations to forecast the 501st observations, then shift the window forward one step using observations 2 to 501 to predict the 502nd observation. I want this to repeat until I have a complete pseudo out-of-sample forecast.
My df contains 2411 observations of 23 variables, here is small example:
Date
EUR/GBP_RV t+1
EUR/GBP_RV
EUR/GBP_RV_5
EUR/GBP_RV_22
2012-02-13
0.004019947
0.004467109
0.004995980
0.005150602
2012-02-14
0.004077322
0.004019947
0.004704742
0.005099209
2012-02-15
0.004666244
0.004077322
0.004564522
0.005020790
2012-02-16
0.004582351
0.004666244
0.004532930
0.005011078
2012-02-17
0.003951071
0.004582351
0.004362595
0.004999634
2012-02-21
0.005549329
0.004824547
0.004467109
0.004954358
The head of the df can be reproduced with
structure(list(Date = structure(c(15383, 15384, 15385, 15386,
15387, 15391), class = "Date"), `EUR/GBP_RV t+1,t+22` = c(0.00437808494654599,
0.00439764887779732, 0.00441997330738947, 0.00437799055732722,
0.00435021150904479, 0.00434881306458859), `EUR/GBP_RGV t+1,t+22` = c(0.00310674728131117,
0.00311502965608506, 0.00313756204195853, 0.00312923997431178,
0.00310846773074243, 0.00309755540903969), `EUR/GBP_RBV t+1,t+22` = c(0.00304961980133602,
0.00306866297401415, 0.00307794319983677, 0.00302801249035602,
0.00300946121851254, 0.00302272755554915), `EUR/GBP_RV t+1,t+5` = c(0.00425938711995146,
0.00442030721926592, 0.00471470868108043, 0.00487869292442023,
0.00476849421943949, 0.0046067439660438), `EUR/GBP_RGV t+1,t+5` = c(0.00287718093809447,
0.00311308998902836, 0.00344398536439729, 0.00376911066284235,
0.00377425759242542, 0.00353909902900148), `EUR/GBP_RBV t+1,t+5` = c(0.00313771439501486,
0.00310626895475871, 0.0031789431316576, 0.00305962424370556,
0.00288671182187571, 0.00291630955829613), `EUR/GBP_RV t+1` = c(0.00401994700051122,
0.00407732180013827, 0.00466624428620966, 0.00458235106134663,
0.00395107145155152, 0.00554932910921084), `EUR/GBP_RGV t+1` = c(0.00280067842079775,
0.00275522601341373, 0.00296142025653418, 0.00320716195737542,
0.00266141804235125, 0.00440970289025837), `EUR/GBP_RBV t+1` = c(0.00288377777753365,
0.00300554199386584, 0.00360608177982326, 0.00327292734850446,
0.0029202430753471, 0.00336891287836027), `EUR/GBP_RV` = c(0.00446710941914797,
0.00401994700051122, 0.00407732180013827, 0.00466624428620966,
0.00458235106134663, 0.00482454749708351), `EUR/GBP_RV_5` = c(0.00499598016427624,
0.00470474196716823, 0.00456452150727461, 0.00453292965488229,
0.00436259471347075, 0.00442030721926592), `EUR/GBP_RV_22` = c(0.00515060219897263,
0.00509920878086075, 0.00502079002092667, 0.00501107755050095,
0.00499963428727425, 0.00495435807685843), `EUR/GBP_RBV` = c(0.00324667045338159,
0.00288377777753365, 0.00300554199386584, 0.00360608177982326,
0.00327292734850446, 0.00272655057625291), `EUR/GBP_RBV_5` = c(0.0034985439252634,
0.00318731350301598, 0.00319529774619179, 0.0032799330165155,
0.00320299987062176, 0.00310626895475871), `EUR/GBP_RBV_22` = c(0.0036581887941976,
0.00362298829344015, 0.00355498498935768, 0.0035465419934449,
0.00355752455210586, 0.00351669973034298), `EUR/GBP_RGV` = c(0.00306825643155514,
0.00280067842079775, 0.00275522601341373, 0.00296142025653418,
0.00320716195737542, 0.00398022367546721), `EUR/GBP_RGV_5` = c(0.00353290218424469,
0.00345194162523714, 0.00325362896209417, 0.00312087362386985,
0.00295854861593525, 0.00311308998902836), `EUR/GBP_RGV_22` = c(0.00359974659692405,
0.00356342531619103, 0.00352224165959556, 0.00351722666683608,
0.00349184335907274, 0.00346394410318992), `EUR/GBP_TotalCount` = structure(c(-0.179518680545716,
-0.0757259172924681, 0.333514120677483, 0.759064450015801, -0.419724789788948,
-0.360414639358521), .Dim = c(6L, 1L)), `EUR/GBP_BloombergCount` = structure(c(-0.701694550941621,
-0.669811381311996, -0.574161872423118, -0.644304845608295, -0.784590791978649,
-0.631551577756444), .Dim = c(6L, 1L)), `EUR/GBP_SocialMediaCount` = structure(c(-1.68861759789696,
-1.66829994393287, -1.5910928588693, -1.59515638966212, -1.6967446594826,
-1.63172816679749), .Dim = c(6L, 1L)), `EUR/GBP_NewsCount` = structure(c(0.76560533722738,
0.879161625683434, 1.33717198912285, 1.90306082659552, 0.487392430510049,
0.487392430510049), .Dim = c(6L, 1L))), na.action = structure(c(`6` = 6L,
`38` = 38L, `74` = 74L, `101` = 101L, `140` = 140L, `165` = 165L,
`189` = 189L, `197` = 197L, `236` = 236L, `256` = 256L, `323` = 323L,
`351` = 351L, `393` = 393L, `423` = 423L, `442` = 442L, `455` = 455L,
`490` = 490L, `510` = 510L, `551` = 551L, `576` = 576L, `605` = 605L,
`646` = 646L, `676` = 676L, `696` = 696L, `708` = 708L, `742` = 742L,
`762` = 762L, `793` = 793L, `829` = 829L, `858` = 858L, `904` = 904L,
`929` = 929L, `950` = 950L, `961` = 961L, `996` = 996L, `1016` = 1016L,
`1089` = 1089L, `1114` = 1114L, `1159` = 1159L, `1184` = 1184L,
`1207` = 1207L, `1216` = 1216L, `1238` = 1238L, `1243` = 1243L,
`1253` = 1253L, `1278` = 1278L, `1315` = 1315L, `1346` = 1346L,
`1372` = 1372L, `1416` = 1416L, `1441` = 1441L, `1473` = 1473L,
`1532` = 1532L, `1599` = 1599L, `1626` = 1626L, `1669` = 1669L,
`1694` = 1694L, `1718` = 1718L, `1726` = 1726L, `1766` = 1766L,
`1786` = 1786L, `1827` = 1827L, `1853` = 1853L, `1881` = 1881L,
`1922` = 1922L, `1952` = 1952L, `1971` = 1971L, `1984` = 1984L,
`2019` = 2019L, `2039` = 2039L, `2075` = 2075L, `2106` = 2106L,
`2135` = 2135L, `2181` = 2181L, `2206` = 2206L, `2227` = 2227L,
`2238` = 2238L, `2273` = 2273L, `2293` = 2293L, `2325` = 2325L,
`2366` = 2366L, `2391` = 2391L, `2436` = 2436L, `2461` = 2461L,
`2483` = 2483L, `2493` = 2493L), class = "omit"), row.names = c(1L,
2L, 3L, 4L, 5L, 7L), class = "data.frame")
I have built 9 regression models per forecast horizon (t+1, t+5 and t+22) and I am using the predict function to make my forecasts. I have coded this in an R loop, where I also try to assign each forecast to a matrix. My code is the following:
EUR/GBP_RV t+1,t+5`~data.estimateI am trying to calculate realized volatility forecasts using a rolling window forecast. My aim is to use the first 500 observations to forecast the 501st observations, then shift the window forward one step using observations 2 to 501 to predict the 502nd observation. I want this to repeat until I have a complete pseudo out-of-sample forecast.
My df contains 2411 observations of 23 variables, here is small example:
Date
EUR/GBP_RV t+1
EUR/GBP_RV
EUR/GBP_RV_5
EUR/GBP_RV_22
2012-02-13
0.004019947
0.004467109
0.004995980
0.005150602
2012-02-14
0.004077322
0.004019947
0.004704742
0.005099209
2012-02-15
0.004666244
0.004077322
0.004564522
0.005020790
2012-02-16
0.004582351
0.004666244
0.004532930
0.005011078
2012-02-17
0.003951071
0.004582351
0.004362595
0.004999634
2012-02-21
0.005549329
0.004824547
0.004467109
0.004954358
The head of the df can be reproduced with
structure(list(Date = structure(c(15383, 15384, 15385, 15386,
15387, 15391), class = "Date"), `EUR/GBP_RV t+1,t+22` = c(0.00437808494654599,
0.00439764887779732, 0.00441997330738947, 0.00437799055732722,
0.00435021150904479, 0.00434881306458859), `EUR/GBP_RGV t+1,t+22` = c(0.00310674728131117,
0.00311502965608506, 0.00313756204195853, 0.00312923997431178,
0.00310846773074243, 0.00309755540903969), `EUR/GBP_RBV t+1,t+22` = c(0.00304961980133602,
0.00306866297401415, 0.00307794319983677, 0.00302801249035602,
0.00300946121851254, 0.00302272755554915), `EUR/GBP_RV t+1,t+5` = c(0.00425938711995146,
0.00442030721926592, 0.00471470868108043, 0.00487869292442023,
0.00476849421943949, 0.0046067439660438), `EUR/GBP_RGV t+1,t+5` = c(0.00287718093809447,
0.00311308998902836, 0.00344398536439729, 0.00376911066284235,
0.00377425759242542, 0.00353909902900148), `EUR/GBP_RBV t+1,t+5` = c(0.00313771439501486,
0.00310626895475871, 0.0031789431316576, 0.00305962424370556,
0.00288671182187571, 0.00291630955829613), `EUR/GBP_RV t+1` = c(0.00401994700051122,
0.00407732180013827, 0.00466624428620966, 0.00458235106134663,
0.00395107145155152, 0.00554932910921084), `EUR/GBP_RGV t+1` = c(0.00280067842079775,
0.00275522601341373, 0.00296142025653418, 0.00320716195737542,
0.00266141804235125, 0.00440970289025837), `EUR/GBP_RBV t+1` = c(0.00288377777753365,
0.00300554199386584, 0.00360608177982326, 0.00327292734850446,
0.0029202430753471, 0.00336891287836027), `EUR/GBP_RV` = c(0.00446710941914797,
0.00401994700051122, 0.00407732180013827, 0.00466624428620966,
0.00458235106134663, 0.00482454749708351), `EUR/GBP_RV_5` = c(0.00499598016427624,
0.00470474196716823, 0.00456452150727461, 0.00453292965488229,
0.00436259471347075, 0.00442030721926592), `EUR/GBP_RV_22` = c(0.00515060219897263,
0.00509920878086075, 0.00502079002092667, 0.00501107755050095,
0.00499963428727425, 0.00495435807685843), `EUR/GBP_RBV` = c(0.00324667045338159,
0.00288377777753365, 0.00300554199386584, 0.00360608177982326,
0.00327292734850446, 0.00272655057625291), `EUR/GBP_RBV_5` = c(0.0034985439252634,
0.00318731350301598, 0.00319529774619179, 0.0032799330165155,
0.00320299987062176, 0.00310626895475871), `EUR/GBP_RBV_22` = c(0.0036581887941976,
0.00362298829344015, 0.00355498498935768, 0.0035465419934449,
0.00355752455210586, 0.00351669973034298), `EUR/GBP_RGV` = c(0.00306825643155514,
0.00280067842079775, 0.00275522601341373, 0.00296142025653418,
0.00320716195737542, 0.00398022367546721), `EUR/GBP_RGV_5` = c(0.00353290218424469,
0.00345194162523714, 0.00325362896209417, 0.00312087362386985,
0.00295854861593525, 0.00311308998902836), `EUR/GBP_RGV_22` = c(0.00359974659692405,
0.00356342531619103, 0.00352224165959556, 0.00351722666683608,
0.00349184335907274, 0.00346394410318992), `EUR/GBP_TotalCount` = structure(c(-0.179518680545716,
-0.0757259172924681, 0.333514120677483, 0.759064450015801, -0.419724789788948,
-0.360414639358521), .Dim = c(6L, 1L)), `EUR/GBP_BloombergCount` = structure(c(-0.701694550941621,
-0.669811381311996, -0.574161872423118, -0.644304845608295, -0.784590791978649,
-0.631551577756444), .Dim = c(6L, 1L)), `EUR/GBP_SocialMediaCount` = structure(c(-1.68861759789696,
-1.66829994393287, -1.5910928588693, -1.59515638966212, -1.6967446594826,
-1.63172816679749), .Dim = c(6L, 1L)), `EUR/GBP_NewsCount` = structure(c(0.76560533722738,
0.879161625683434, 1.33717198912285, 1.90306082659552, 0.487392430510049,
0.487392430510049), .Dim = c(6L, 1L))), na.action = structure(c(`6` = 6L,
`38` = 38L, `74` = 74L, `101` = 101L, `140` = 140L, `165` = 165L,
`189` = 189L, `197` = 197L, `236` = 236L, `256` = 256L, `323` = 323L,
`351` = 351L, `393` = 393L, `423` = 423L, `442` = 442L, `455` = 455L,
`490` = 490L, `510` = 510L, `551` = 551L, `576` = 576L, `605` = 605L,
`646` = 646L, `676` = 676L, `696` = 696L, `708` = 708L, `742` = 742L,
`762` = 762L, `793` = 793L, `829` = 829L, `858` = 858L, `904` = 904L,
`929` = 929L, `950` = 950L, `961` = 961L, `996` = 996L, `1016` = 1016L,
`1089` = 1089L, `1114` = 1114L, `1159` = 1159L, `1184` = 1184L,
`1207` = 1207L, `1216` = 1216L, `1238` = 1238L, `1243` = 1243L,
`1253` = 1253L, `1278` = 1278L, `1315` = 1315L, `1346` = 1346L,
`1372` = 1372L, `1416` = 1416L, `1441` = 1441L, `1473` = 1473L,
`1532` = 1532L, `1599` = 1599L, `1626` = 1626L, `1669` = 1669L,
`1694` = 1694L, `1718` = 1718L, `1726` = 1726L, `1766` = 1766L,
`1786` = 1786L, `1827` = 1827L, `1853` = 1853L, `1881` = 1881L,
`1922` = 1922L, `1952` = 1952L, `1971` = 1971L, `1984` = 1984L,
`2019` = 2019L, `2039` = 2039L, `2075` = 2075L, `2106` = 2106L,
`2135` = 2135L, `2181` = 2181L, `2206` = 2206L, `2227` = 2227L,
`2238` = 2238L, `2273` = 2273L, `2293` = 2293L, `2325` = 2325L,
`2366` = 2366L, `2391` = 2391L, `2436` = 2436L, `2461` = 2461L,
`2483` = 2483L, `2493` = 2493L), class = "omit"), row.names = c(1L,
2L, 3L, 4L, 5L, 7L), class = "data.frame")
I have built 9 regression models per forecast horizon (t+1, t+5 and t+22) and I am using the predict function to make my forecasts. I have coded this in an R loop, where I also try to assign each forecast to a matrix. My code is the following:
EUR/GBP_RV`+data.estimateI am trying to calculate realized volatility forecasts using a rolling window forecast. My aim is to use the first 500 observations to forecast the 501st observations, then shift the window forward one step using observations 2 to 501 to predict the 502nd observation. I want this to repeat until I have a complete pseudo out-of-sample forecast.
My df contains 2411 observations of 23 variables, here is small example:
Date
EUR/GBP_RV t+1
EUR/GBP_RV
EUR/GBP_RV_5
EUR/GBP_RV_22
2012-02-13
0.004019947
0.004467109
0.004995980
0.005150602
2012-02-14
0.004077322
0.004019947
0.004704742
0.005099209
2012-02-15
0.004666244
0.004077322
0.004564522
0.005020790
2012-02-16
0.004582351
0.004666244
0.004532930
0.005011078
2012-02-17
0.003951071
0.004582351
0.004362595
0.004999634
2012-02-21
0.005549329
0.004824547
0.004467109
0.004954358
The head of the df can be reproduced with
structure(list(Date = structure(c(15383, 15384, 15385, 15386,
15387, 15391), class = "Date"), `EUR/GBP_RV t+1,t+22` = c(0.00437808494654599,
0.00439764887779732, 0.00441997330738947, 0.00437799055732722,
0.00435021150904479, 0.00434881306458859), `EUR/GBP_RGV t+1,t+22` = c(0.00310674728131117,
0.00311502965608506, 0.00313756204195853, 0.00312923997431178,
0.00310846773074243, 0.00309755540903969), `EUR/GBP_RBV t+1,t+22` = c(0.00304961980133602,
0.00306866297401415, 0.00307794319983677, 0.00302801249035602,
0.00300946121851254, 0.00302272755554915), `EUR/GBP_RV t+1,t+5` = c(0.00425938711995146,
0.00442030721926592, 0.00471470868108043, 0.00487869292442023,
0.00476849421943949, 0.0046067439660438), `EUR/GBP_RGV t+1,t+5` = c(0.00287718093809447,
0.00311308998902836, 0.00344398536439729, 0.00376911066284235,
0.00377425759242542, 0.00353909902900148), `EUR/GBP_RBV t+1,t+5` = c(0.00313771439501486,
0.00310626895475871, 0.0031789431316576, 0.00305962424370556,
0.00288671182187571, 0.00291630955829613), `EUR/GBP_RV t+1` = c(0.00401994700051122,
0.00407732180013827, 0.00466624428620966, 0.00458235106134663,
0.00395107145155152, 0.00554932910921084), `EUR/GBP_RGV t+1` = c(0.00280067842079775,
0.00275522601341373, 0.00296142025653418, 0.00320716195737542,
0.00266141804235125, 0.00440970289025837), `EUR/GBP_RBV t+1` = c(0.00288377777753365,
0.00300554199386584, 0.00360608177982326, 0.00327292734850446,
0.0029202430753471, 0.00336891287836027), `EUR/GBP_RV` = c(0.00446710941914797,
0.00401994700051122, 0.00407732180013827, 0.00466624428620966,
0.00458235106134663, 0.00482454749708351), `EUR/GBP_RV_5` = c(0.00499598016427624,
0.00470474196716823, 0.00456452150727461, 0.00453292965488229,
0.00436259471347075, 0.00442030721926592), `EUR/GBP_RV_22` = c(0.00515060219897263,
0.00509920878086075, 0.00502079002092667, 0.00501107755050095,
0.00499963428727425, 0.00495435807685843), `EUR/GBP_RBV` = c(0.00324667045338159,
0.00288377777753365, 0.00300554199386584, 0.00360608177982326,
0.00327292734850446, 0.00272655057625291), `EUR/GBP_RBV_5` = c(0.0034985439252634,
0.00318731350301598, 0.00319529774619179, 0.0032799330165155,
0.00320299987062176, 0.00310626895475871), `EUR/GBP_RBV_22` = c(0.0036581887941976,
0.00362298829344015, 0.00355498498935768, 0.0035465419934449,
0.00355752455210586, 0.00351669973034298), `EUR/GBP_RGV` = c(0.00306825643155514,
0.00280067842079775, 0.00275522601341373, 0.00296142025653418,
0.00320716195737542, 0.00398022367546721), `EUR/GBP_RGV_5` = c(0.00353290218424469,
0.00345194162523714, 0.00325362896209417, 0.00312087362386985,
0.00295854861593525, 0.00311308998902836), `EUR/GBP_RGV_22` = c(0.00359974659692405,
0.00356342531619103, 0.00352224165959556, 0.00351722666683608,
0.00349184335907274, 0.00346394410318992), `EUR/GBP_TotalCount` = structure(c(-0.179518680545716,
-0.0757259172924681, 0.333514120677483, 0.759064450015801, -0.419724789788948,
-0.360414639358521), .Dim = c(6L, 1L)), `EUR/GBP_BloombergCount` = structure(c(-0.701694550941621,
-0.669811381311996, -0.574161872423118, -0.644304845608295, -0.784590791978649,
-0.631551577756444), .Dim = c(6L, 1L)), `EUR/GBP_SocialMediaCount` = structure(c(-1.68861759789696,
-1.66829994393287, -1.5910928588693, -1.59515638966212, -1.6967446594826,
-1.63172816679749), .Dim = c(6L, 1L)), `EUR/GBP_NewsCount` = structure(c(0.76560533722738,
0.879161625683434, 1.33717198912285, 1.90306082659552, 0.487392430510049,
0.487392430510049), .Dim = c(6L, 1L))), na.action = structure(c(`6` = 6L,
`38` = 38L, `74` = 74L, `101` = 101L, `140` = 140L, `165` = 165L,
`189` = 189L, `197` = 197L, `236` = 236L, `256` = 256L, `323` = 323L,
`351` = 351L, `393` = 393L, `423` = 423L, `442` = 442L, `455` = 455L,
`490` = 490L, `510` = 510L, `551` = 551L, `576` = 576L, `605` = 605L,
`646` = 646L, `676` = 676L, `696` = 696L, `708` = 708L, `742` = 742L,
`762` = 762L, `793` = 793L, `829` = 829L, `858` = 858L, `904` = 904L,
`929` = 929L, `950` = 950L, `961` = 961L, `996` = 996L, `1016` = 1016L,
`1089` = 1089L, `1114` = 1114L, `1159` = 1159L, `1184` = 1184L,
`1207` = 1207L, `1216` = 1216L, `1238` = 1238L, `1243` = 1243L,
`1253` = 1253L, `1278` = 1278L, `1315` = 1315L, `1346` = 1346L,
`1372` = 1372L, `1416` = 1416L, `1441` = 1441L, `1473` = 1473L,
`1532` = 1532L, `1599` = 1599L, `1626` = 1626L, `1669` = 1669L,
`1694` = 1694L, `1718` = 1718L, `1726` = 1726L, `1766` = 1766L,
`1786` = 1786L, `1827` = 1827L, `1853` = 1853L, `1881` = 1881L,
`1922` = 1922L, `1952` = 1952L, `1971` = 1971L, `1984` = 1984L,
`2019` = 2019L, `2039` = 2039L, `2075` = 2075L, `2106` = 2106L,
`2135` = 2135L, `2181` = 2181L, `2206` = 2206L, `2227` = 2227L,
`2238` = 2238L, `2273` = 2273L, `2293` = 2293L, `2325` = 2325L,
`2366` = 2366L, `2391` = 2391L, `2436` = 2436L, `2461` = 2461L,
`2483` = 2483L, `2493` = 2493L), class = "omit"), row.names = c(1L,
2L, 3L, 4L, 5L, 7L), class = "data.frame")
I have built 9 regression models per forecast horizon (t+1, t+5 and t+22) and I am using the predict function to make my forecasts. I have coded this in an R loop, where I also try to assign each forecast to a matrix. My code is the following:
EUR/GBP_RV_5`+data.estimateI am trying to calculate realized volatility forecasts using a rolling window forecast. My aim is to use the first 500 observations to forecast the 501st observations, then shift the window forward one step using observations 2 to 501 to predict the 502nd observation. I want this to repeat until I have a complete pseudo out-of-sample forecast.
My df contains 2411 observations of 23 variables, here is small example:
Date
EUR/GBP_RV t+1
EUR/GBP_RV
EUR/GBP_RV_5
EUR/GBP_RV_22
2012-02-13
0.004019947
0.004467109
0.004995980
0.005150602
2012-02-14
0.004077322
0.004019947
0.004704742
0.005099209
2012-02-15
0.004666244
0.004077322
0.004564522
0.005020790
2012-02-16
0.004582351
0.004666244
0.004532930
0.005011078
2012-02-17
0.003951071
0.004582351
0.004362595
0.004999634
2012-02-21
0.005549329
0.004824547
0.004467109
0.004954358
The head of the df can be reproduced with
structure(list(Date = structure(c(15383, 15384, 15385, 15386,
15387, 15391), class = "Date"), `EUR/GBP_RV t+1,t+22` = c(0.00437808494654599,
0.00439764887779732, 0.00441997330738947, 0.00437799055732722,
0.00435021150904479, 0.00434881306458859), `EUR/GBP_RGV t+1,t+22` = c(0.00310674728131117,
0.00311502965608506, 0.00313756204195853, 0.00312923997431178,
0.00310846773074243, 0.00309755540903969), `EUR/GBP_RBV t+1,t+22` = c(0.00304961980133602,
0.00306866297401415, 0.00307794319983677, 0.00302801249035602,
0.00300946121851254, 0.00302272755554915), `EUR/GBP_RV t+1,t+5` = c(0.00425938711995146,
0.00442030721926592, 0.00471470868108043, 0.00487869292442023,
0.00476849421943949, 0.0046067439660438), `EUR/GBP_RGV t+1,t+5` = c(0.00287718093809447,
0.00311308998902836, 0.00344398536439729, 0.00376911066284235,
0.00377425759242542, 0.00353909902900148), `EUR/GBP_RBV t+1,t+5` = c(0.00313771439501486,
0.00310626895475871, 0.0031789431316576, 0.00305962424370556,
0.00288671182187571, 0.00291630955829613), `EUR/GBP_RV t+1` = c(0.00401994700051122,
0.00407732180013827, 0.00466624428620966, 0.00458235106134663,
0.00395107145155152, 0.00554932910921084), `EUR/GBP_RGV t+1` = c(0.00280067842079775,
0.00275522601341373, 0.00296142025653418, 0.00320716195737542,
0.00266141804235125, 0.00440970289025837), `EUR/GBP_RBV t+1` = c(0.00288377777753365,
0.00300554199386584, 0.00360608177982326, 0.00327292734850446,
0.0029202430753471, 0.00336891287836027), `EUR/GBP_RV` = c(0.00446710941914797,
0.00401994700051122, 0.00407732180013827, 0.00466624428620966,
0.00458235106134663, 0.00482454749708351), `EUR/GBP_RV_5` = c(0.00499598016427624,
0.00470474196716823, 0.00456452150727461, 0.00453292965488229,
0.00436259471347075, 0.00442030721926592), `EUR/GBP_RV_22` = c(0.00515060219897263,
0.00509920878086075, 0.00502079002092667, 0.00501107755050095,
0.00499963428727425, 0.00495435807685843), `EUR/GBP_RBV` = c(0.00324667045338159,
0.00288377777753365, 0.00300554199386584, 0.00360608177982326,
0.00327292734850446, 0.00272655057625291), `EUR/GBP_RBV_5` = c(0.0034985439252634,
0.00318731350301598, 0.00319529774619179, 0.0032799330165155,
0.00320299987062176, 0.00310626895475871), `EUR/GBP_RBV_22` = c(0.0036581887941976,
0.00362298829344015, 0.00355498498935768, 0.0035465419934449,
0.00355752455210586, 0.00351669973034298), `EUR/GBP_RGV` = c(0.00306825643155514,
0.00280067842079775, 0.00275522601341373, 0.00296142025653418,
0.00320716195737542, 0.00398022367546721), `EUR/GBP_RGV_5` = c(0.00353290218424469,
0.00345194162523714, 0.00325362896209417, 0.00312087362386985,
0.00295854861593525, 0.00311308998902836), `EUR/GBP_RGV_22` = c(0.00359974659692405,
0.00356342531619103, 0.00352224165959556, 0.00351722666683608,
0.00349184335907274, 0.00346394410318992), `EUR/GBP_TotalCount` = structure(c(-0.179518680545716,
-0.0757259172924681, 0.333514120677483, 0.759064450015801, -0.419724789788948,
-0.360414639358521), .Dim = c(6L, 1L)), `EUR/GBP_BloombergCount` = structure(c(-0.701694550941621,
-0.669811381311996, -0.574161872423118, -0.644304845608295, -0.784590791978649,
-0.631551577756444), .Dim = c(6L, 1L)), `EUR/GBP_SocialMediaCount` = structure(c(-1.68861759789696,
-1.66829994393287, -1.5910928588693, -1.59515638966212, -1.6967446594826,
-1.63172816679749), .Dim = c(6L, 1L)), `EUR/GBP_NewsCount` = structure(c(0.76560533722738,
0.879161625683434, 1.33717198912285, 1.90306082659552, 0.487392430510049,
0.487392430510049), .Dim = c(6L, 1L))), na.action = structure(c(`6` = 6L,
`38` = 38L, `74` = 74L, `101` = 101L, `140` = 140L, `165` = 165L,
`189` = 189L, `197` = 197L, `236` = 236L, `256` = 256L, `323` = 323L,
`351` = 351L, `393` = 393L, `423` = 423L, `442` = 442L, `455` = 455L,
`490` = 490L, `510` = 510L, `551` = 551L, `576` = 576L, `605` = 605L,
`646` = 646L, `676` = 676L, `696` = 696L, `708` = 708L, `742` = 742L,
`762` = 762L, `793` = 793L, `829` = 829L, `858` = 858L, `904` = 904L,
`929` = 929L, `950` = 950L, `961` = 961L, `996` = 996L, `1016` = 1016L,
`1089` = 1089L, `1114` = 1114L, `1159` = 1159L, `1184` = 1184L,
`1207` = 1207L, `1216` = 1216L, `1238` = 1238L, `1243` = 1243L,
`1253` = 1253L, `1278` = 1278L, `1315` = 1315L, `1346` = 1346L,
`1372` = 1372L, `1416` = 1416L, `1441` = 1441L, `1473` = 1473L,
`1532` = 1532L, `1599` = 1599L, `1626` = 1626L, `1669` = 1669L,
`1694` = 1694L, `1718` = 1718L, `1726` = 1726L, `1766` = 1766L,
`1786` = 1786L, `1827` = 1827L, `1853` = 1853L, `1881` = 1881L,
`1922` = 1922L, `1952` = 1952L, `1971` = 1971L, `1984` = 1984L,
`2019` = 2019L, `2039` = 2039L, `2075` = 2075L, `2106` = 2106L,
`2135` = 2135L, `2181` = 2181L, `2206` = 2206L, `2227` = 2227L,
`2238` = 2238L, `2273` = 2273L, `2293` = 2293L, `2325` = 2325L,
`2366` = 2366L, `2391` = 2391L, `2436` = 2436L, `2461` = 2461L,
`2483` = 2483L, `2493` = 2493L), class = "omit"), row.names = c(1L,
2L, 3L, 4L, 5L, 7L), class = "data.frame")
I have built 9 regression models per forecast horizon (t+1, t+5 and t+22) and I am using the predict function to make my forecasts. I have coded this in an R loop, where I also try to assign each forecast to a matrix. My code is the following:
EUR/GBP_RV_22`)
EURGBP_HAR_RVt5_NT_train <- lm(data.estimateI am trying to calculate realized volatility forecasts using a rolling window forecast. My aim is to use the first 500 observations to forecast the 501st observations, then shift the window forward one step using observations 2 to 501 to predict the 502nd observation. I want this to repeat until I have a complete pseudo out-of-sample forecast.
My df contains 2411 observations of 23 variables, here is small example:
Date
EUR/GBP_RV t+1
EUR/GBP_RV
EUR/GBP_RV_5
EUR/GBP_RV_22
2012-02-13
0.004019947
0.004467109
0.004995980
0.005150602
2012-02-14
0.004077322
0.004019947
0.004704742
0.005099209
2012-02-15
0.004666244
0.004077322
0.004564522
0.005020790
2012-02-16
0.004582351
0.004666244
0.004532930
0.005011078
2012-02-17
0.003951071
0.004582351
0.004362595
0.004999634
2012-02-21
0.005549329
0.004824547
0.004467109
0.004954358
The head of the df can be reproduced with
structure(list(Date = structure(c(15383, 15384, 15385, 15386,
15387, 15391), class = "Date"), `EUR/GBP_RV t+1,t+22` = c(0.00437808494654599,
0.00439764887779732, 0.00441997330738947, 0.00437799055732722,
0.00435021150904479, 0.00434881306458859), `EUR/GBP_RGV t+1,t+22` = c(0.00310674728131117,
0.00311502965608506, 0.00313756204195853, 0.00312923997431178,
0.00310846773074243, 0.00309755540903969), `EUR/GBP_RBV t+1,t+22` = c(0.00304961980133602,
0.00306866297401415, 0.00307794319983677, 0.00302801249035602,
0.00300946121851254, 0.00302272755554915), `EUR/GBP_RV t+1,t+5` = c(0.00425938711995146,
0.00442030721926592, 0.00471470868108043, 0.00487869292442023,
0.00476849421943949, 0.0046067439660438), `EUR/GBP_RGV t+1,t+5` = c(0.00287718093809447,
0.00311308998902836, 0.00344398536439729, 0.00376911066284235,
0.00377425759242542, 0.00353909902900148), `EUR/GBP_RBV t+1,t+5` = c(0.00313771439501486,
0.00310626895475871, 0.0031789431316576, 0.00305962424370556,
0.00288671182187571, 0.00291630955829613), `EUR/GBP_RV t+1` = c(0.00401994700051122,
0.00407732180013827, 0.00466624428620966, 0.00458235106134663,
0.00395107145155152, 0.00554932910921084), `EUR/GBP_RGV t+1` = c(0.00280067842079775,
0.00275522601341373, 0.00296142025653418, 0.00320716195737542,
0.00266141804235125, 0.00440970289025837), `EUR/GBP_RBV t+1` = c(0.00288377777753365,
0.00300554199386584, 0.00360608177982326, 0.00327292734850446,
0.0029202430753471, 0.00336891287836027), `EUR/GBP_RV` = c(0.00446710941914797,
0.00401994700051122, 0.00407732180013827, 0.00466624428620966,
0.00458235106134663, 0.00482454749708351), `EUR/GBP_RV_5` = c(0.00499598016427624,
0.00470474196716823, 0.00456452150727461, 0.00453292965488229,
0.00436259471347075, 0.00442030721926592), `EUR/GBP_RV_22` = c(0.00515060219897263,
0.00509920878086075, 0.00502079002092667, 0.00501107755050095,
0.00499963428727425, 0.00495435807685843), `EUR/GBP_RBV` = c(0.00324667045338159,
0.00288377777753365, 0.00300554199386584, 0.00360608177982326,
0.00327292734850446, 0.00272655057625291), `EUR/GBP_RBV_5` = c(0.0034985439252634,
0.00318731350301598, 0.00319529774619179, 0.0032799330165155,
0.00320299987062176, 0.00310626895475871), `EUR/GBP_RBV_22` = c(0.0036581887941976,
0.00362298829344015, 0.00355498498935768, 0.0035465419934449,
0.00355752455210586, 0.00351669973034298), `EUR/GBP_RGV` = c(0.00306825643155514,
0.00280067842079775, 0.00275522601341373, 0.00296142025653418,
0.00320716195737542, 0.00398022367546721), `EUR/GBP_RGV_5` = c(0.00353290218424469,
0.00345194162523714, 0.00325362896209417, 0.00312087362386985,
0.00295854861593525, 0.00311308998902836), `EUR/GBP_RGV_22` = c(0.00359974659692405,
0.00356342531619103, 0.00352224165959556, 0.00351722666683608,
0.00349184335907274, 0.00346394410318992), `EUR/GBP_TotalCount` = structure(c(-0.179518680545716,
-0.0757259172924681, 0.333514120677483, 0.759064450015801, -0.419724789788948,
-0.360414639358521), .Dim = c(6L, 1L)), `EUR/GBP_BloombergCount` = structure(c(-0.701694550941621,
-0.669811381311996, -0.574161872423118, -0.644304845608295, -0.784590791978649,
-0.631551577756444), .Dim = c(6L, 1L)), `EUR/GBP_SocialMediaCount` = structure(c(-1.68861759789696,
-1.66829994393287, -1.5910928588693, -1.59515638966212, -1.6967446594826,
-1.63172816679749), .Dim = c(6L, 1L)), `EUR/GBP_NewsCount` = structure(c(0.76560533722738,
0.879161625683434, 1.33717198912285, 1.90306082659552, 0.487392430510049,
0.487392430510049), .Dim = c(6L, 1L))), na.action = structure(c(`6` = 6L,
`38` = 38L, `74` = 74L, `101` = 101L, `140` = 140L, `165` = 165L,
`189` = 189L, `197` = 197L, `236` = 236L, `256` = 256L, `323` = 323L,
`351` = 351L, `393` = 393L, `423` = 423L, `442` = 442L, `455` = 455L,
`490` = 490L, `510` = 510L, `551` = 551L, `576` = 576L, `605` = 605L,
`646` = 646L, `676` = 676L, `696` = 696L, `708` = 708L, `742` = 742L,
`762` = 762L, `793` = 793L, `829` = 829L, `858` = 858L, `904` = 904L,
`929` = 929L, `950` = 950L, `961` = 961L, `996` = 996L, `1016` = 1016L,
`1089` = 1089L, `1114` = 1114L, `1159` = 1159L, `1184` = 1184L,
`1207` = 1207L, `1216` = 1216L, `1238` = 1238L, `1243` = 1243L,
`1253` = 1253L, `1278` = 1278L, `1315` = 1315L, `1346` = 1346L,
`1372` = 1372L, `1416` = 1416L, `1441` = 1441L, `1473` = 1473L,
`1532` = 1532L, `1599` = 1599L, `1626` = 1626L, `1669` = 1669L,
`1694` = 1694L, `1718` = 1718L, `1726` = 1726L, `1766` = 1766L,
`1786` = 1786L, `1827` = 1827L, `1853` = 1853L, `1881` = 1881L,
`1922` = 1922L, `1952` = 1952L, `1971` = 1971L, `1984` = 1984L,
`2019` = 2019L, `2039` = 2039L, `2075` = 2075L, `2106` = 2106L,
`2135` = 2135L, `2181` = 2181L, `2206` = 2206L, `2227` = 2227L,
`2238` = 2238L, `2273` = 2273L, `2293` = 2293L, `2325` = 2325L,
`2366` = 2366L, `2391` = 2391L, `2436` = 2436L, `2461` = 2461L,
`2483` = 2483L, `2493` = 2493L), class = "omit"), row.names = c(1L,
2L, 3L, 4L, 5L, 7L), class = "data.frame")
I have built 9 regression models per forecast horizon (t+1, t+5 and t+22) and I am using the predict function to make my forecasts. I have coded this in an R loop, where I also try to assign each forecast to a matrix. My code is the following:
EUR/GBP_RV t+1,t+5`~data.estimateI am trying to calculate realized volatility forecasts using a rolling window forecast. My aim is to use the first 500 observations to forecast the 501st observations, then shift the window forward one step using observations 2 to 501 to predict the 502nd observation. I want this to repeat until I have a complete pseudo out-of-sample forecast.
My df contains 2411 observations of 23 variables, here is small example:
Date
EUR/GBP_RV t+1
EUR/GBP_RV
EUR/GBP_RV_5
EUR/GBP_RV_22
2012-02-13
0.004019947
0.004467109
0.004995980
0.005150602
2012-02-14
0.004077322
0.004019947
0.004704742
0.005099209
2012-02-15
0.004666244
0.004077322
0.004564522
0.005020790
2012-02-16
0.004582351
0.004666244
0.004532930
0.005011078
2012-02-17
0.003951071
0.004582351
0.004362595
0.004999634
2012-02-21
0.005549329
0.004824547
0.004467109
0.004954358
The head of the df can be reproduced with
structure(list(Date = structure(c(15383, 15384, 15385, 15386,
15387, 15391), class = "Date"), `EUR/GBP_RV t+1,t+22` = c(0.00437808494654599,
0.00439764887779732, 0.00441997330738947, 0.00437799055732722,
0.00435021150904479, 0.00434881306458859), `EUR/GBP_RGV t+1,t+22` = c(0.00310674728131117,
0.00311502965608506, 0.00313756204195853, 0.00312923997431178,
0.00310846773074243, 0.00309755540903969), `EUR/GBP_RBV t+1,t+22` = c(0.00304961980133602,
0.00306866297401415, 0.00307794319983677, 0.00302801249035602,
0.00300946121851254, 0.00302272755554915), `EUR/GBP_RV t+1,t+5` = c(0.00425938711995146,
0.00442030721926592, 0.00471470868108043, 0.00487869292442023,
0.00476849421943949, 0.0046067439660438), `EUR/GBP_RGV t+1,t+5` = c(0.00287718093809447,
0.00311308998902836, 0.00344398536439729, 0.00376911066284235,
0.00377425759242542, 0.00353909902900148), `EUR/GBP_RBV t+1,t+5` = c(0.00313771439501486,
0.00310626895475871, 0.0031789431316576, 0.00305962424370556,
0.00288671182187571, 0.00291630955829613), `EUR/GBP_RV t+1` = c(0.00401994700051122,
0.00407732180013827, 0.00466624428620966, 0.00458235106134663,
0.00395107145155152, 0.00554932910921084), `EUR/GBP_RGV t+1` = c(0.00280067842079775,
0.00275522601341373, 0.00296142025653418, 0.00320716195737542,
0.00266141804235125, 0.00440970289025837), `EUR/GBP_RBV t+1` = c(0.00288377777753365,
0.00300554199386584, 0.00360608177982326, 0.00327292734850446,
0.0029202430753471, 0.00336891287836027), `EUR/GBP_RV` = c(0.00446710941914797,
0.00401994700051122, 0.00407732180013827, 0.00466624428620966,
0.00458235106134663, 0.00482454749708351), `EUR/GBP_RV_5` = c(0.00499598016427624,
0.00470474196716823, 0.00456452150727461, 0.00453292965488229,
0.00436259471347075, 0.00442030721926592), `EUR/GBP_RV_22` = c(0.00515060219897263,
0.00509920878086075, 0.00502079002092667, 0.00501107755050095,
0.00499963428727425, 0.00495435807685843), `EUR/GBP_RBV` = c(0.00324667045338159,
0.00288377777753365, 0.00300554199386584, 0.00360608177982326,
0.00327292734850446, 0.00272655057625291), `EUR/GBP_RBV_5` = c(0.0034985439252634,
0.00318731350301598, 0.00319529774619179, 0.0032799330165155,
0.00320299987062176, 0.00310626895475871), `EUR/GBP_RBV_22` = c(0.0036581887941976,
0.00362298829344015, 0.00355498498935768, 0.0035465419934449,
0.00355752455210586, 0.00351669973034298), `EUR/GBP_RGV` = c(0.00306825643155514,
0.00280067842079775, 0.00275522601341373, 0.00296142025653418,
0.00320716195737542, 0.00398022367546721), `EUR/GBP_RGV_5` = c(0.00353290218424469,
0.00345194162523714, 0.00325362896209417, 0.00312087362386985,
0.00295854861593525, 0.00311308998902836), `EUR/GBP_RGV_22` = c(0.00359974659692405,
0.00356342531619103, 0.00352224165959556, 0.00351722666683608,
0.00349184335907274, 0.00346394410318992), `EUR/GBP_TotalCount` = structure(c(-0.179518680545716,
-0.0757259172924681, 0.333514120677483, 0.759064450015801, -0.419724789788948,
-0.360414639358521), .Dim = c(6L, 1L)), `EUR/GBP_BloombergCount` = structure(c(-0.701694550941621,
-0.669811381311996, -0.574161872423118, -0.644304845608295, -0.784590791978649,
-0.631551577756444), .Dim = c(6L, 1L)), `EUR/GBP_SocialMediaCount` = structure(c(-1.68861759789696,
-1.66829994393287, -1.5910928588693, -1.59515638966212, -1.6967446594826,
-1.63172816679749), .Dim = c(6L, 1L)), `EUR/GBP_NewsCount` = structure(c(0.76560533722738,
0.879161625683434, 1.33717198912285, 1.90306082659552, 0.487392430510049,
0.487392430510049), .Dim = c(6L, 1L))), na.action = structure(c(`6` = 6L,
`38` = 38L, `74` = 74L, `101` = 101L, `140` = 140L, `165` = 165L,
`189` = 189L, `197` = 197L, `236` = 236L, `256` = 256L, `323` = 323L,
`351` = 351L, `393` = 393L, `423` = 423L, `442` = 442L, `455` = 455L,
`490` = 490L, `510` = 510L, `551` = 551L, `576` = 576L, `605` = 605L,
`646` = 646L, `676` = 676L, `696` = 696L, `708` = 708L, `742` = 742L,
`762` = 762L, `793` = 793L, `829` = 829L, `858` = 858L, `904` = 904L,
`929` = 929L, `950` = 950L, `961` = 961L, `996` = 996L, `1016` = 1016L,
`1089` = 1089L, `1114` = 1114L, `1159` = 1159L, `1184` = 1184L,
`1207` = 1207L, `1216` = 1216L, `1238` = 1238L, `1243` = 1243L,
`1253` = 1253L, `1278` = 1278L, `1315` = 1315L, `1346` = 1346L,
`1372` = 1372L, `1416` = 1416L, `1441` = 1441L, `1473` = 1473L,
`1532` = 1532L, `1599` = 1599L, `1626` = 1626L, `1669` = 1669L,
`1694` = 1694L, `1718` = 1718L, `1726` = 1726L, `1766` = 1766L,
`1786` = 1786L, `1827` = 1827L, `1853` = 1853L, `1881` = 1881L,
`1922` = 1922L, `1952` = 1952L, `1971` = 1971L, `1984` = 1984L,
`2019` = 2019L, `2039` = 2039L, `2075` = 2075L, `2106` = 2106L,
`2135` = 2135L, `2181` = 2181L, `2206` = 2206L, `2227` = 2227L,
`2238` = 2238L, `2273` = 2273L, `2293` = 2293L, `2325` = 2325L,
`2366` = 2366L, `2391` = 2391L, `2436` = 2436L, `2461` = 2461L,
`2483` = 2483L, `2493` = 2493L), class = "omit"), row.names = c(1L,
2L, 3L, 4L, 5L, 7L), class = "data.frame")
I have built 9 regression models per forecast horizon (t+1, t+5 and t+22) and I am using the predict function to make my forecasts. I have coded this in an R loop, where I also try to assign each forecast to a matrix. My code is the following:
EUR/GBP_RV`+data.estimateI am trying to calculate realized volatility forecasts using a rolling window forecast. My aim is to use the first 500 observations to forecast the 501st observations, then shift the window forward one step using observations 2 to 501 to predict the 502nd observation. I want this to repeat until I have a complete pseudo out-of-sample forecast.
My df contains 2411 observations of 23 variables, here is small example:
Date
EUR/GBP_RV t+1
EUR/GBP_RV
EUR/GBP_RV_5
EUR/GBP_RV_22
2012-02-13
0.004019947
0.004467109
0.004995980
0.005150602
2012-02-14
0.004077322
0.004019947
0.004704742
0.005099209
2012-02-15
0.004666244
0.004077322
0.004564522
0.005020790
2012-02-16
0.004582351
0.004666244
0.004532930
0.005011078
2012-02-17
0.003951071
0.004582351
0.004362595
0.004999634
2012-02-21
0.005549329
0.004824547
0.004467109
0.004954358
The head of the df can be reproduced with
structure(list(Date = structure(c(15383, 15384, 15385, 15386,
15387, 15391), class = "Date"), `EUR/GBP_RV t+1,t+22` = c(0.00437808494654599,
0.00439764887779732, 0.00441997330738947, 0.00437799055732722,
0.00435021150904479, 0.00434881306458859), `EUR/GBP_RGV t+1,t+22` = c(0.00310674728131117,
0.00311502965608506, 0.00313756204195853, 0.00312923997431178,
0.00310846773074243, 0.00309755540903969), `EUR/GBP_RBV t+1,t+22` = c(0.00304961980133602,
0.00306866297401415, 0.00307794319983677, 0.00302801249035602,
0.00300946121851254, 0.00302272755554915), `EUR/GBP_RV t+1,t+5` = c(0.00425938711995146,
0.00442030721926592, 0.00471470868108043, 0.00487869292442023,
0.00476849421943949, 0.0046067439660438), `EUR/GBP_RGV t+1,t+5` = c(0.00287718093809447,
0.00311308998902836, 0.00344398536439729, 0.00376911066284235,
0.00377425759242542, 0.00353909902900148), `EUR/GBP_RBV t+1,t+5` = c(0.00313771439501486,
0.00310626895475871, 0.0031789431316576, 0.00305962424370556,
0.00288671182187571, 0.00291630955829613), `EUR/GBP_RV t+1` = c(0.00401994700051122,
0.00407732180013827, 0.00466624428620966, 0.00458235106134663,
0.00395107145155152, 0.00554932910921084), `EUR/GBP_RGV t+1` = c(0.00280067842079775,
0.00275522601341373, 0.00296142025653418, 0.00320716195737542,
0.00266141804235125, 0.00440970289025837), `EUR/GBP_RBV t+1` = c(0.00288377777753365,
0.00300554199386584, 0.00360608177982326, 0.00327292734850446,
0.0029202430753471, 0.00336891287836027), `EUR/GBP_RV` = c(0.00446710941914797,
0.00401994700051122, 0.00407732180013827, 0.00466624428620966,
0.00458235106134663, 0.00482454749708351), `EUR/GBP_RV_5` = c(0.00499598016427624,
0.00470474196716823, 0.00456452150727461, 0.00453292965488229,
0.00436259471347075, 0.00442030721926592), `EUR/GBP_RV_22` = c(0.00515060219897263,
0.00509920878086075, 0.00502079002092667, 0.00501107755050095,
0.00499963428727425, 0.00495435807685843), `EUR/GBP_RBV` = c(0.00324667045338159,
0.00288377777753365, 0.00300554199386584, 0.00360608177982326,
0.00327292734850446, 0.00272655057625291), `EUR/GBP_RBV_5` = c(0.0034985439252634,
0.00318731350301598, 0.00319529774619179, 0.0032799330165155,
0.00320299987062176, 0.00310626895475871), `EUR/GBP_RBV_22` = c(0.0036581887941976,
0.00362298829344015, 0.00355498498935768, 0.0035465419934449,
0.00355752455210586, 0.00351669973034298), `EUR/GBP_RGV` = c(0.00306825643155514,
0.00280067842079775, 0.00275522601341373, 0.00296142025653418,
0.00320716195737542, 0.00398022367546721), `EUR/GBP_RGV_5` = c(0.00353290218424469,
0.00345194162523714, 0.00325362896209417, 0.00312087362386985,
0.00295854861593525, 0.00311308998902836), `EUR/GBP_RGV_22` = c(0.00359974659692405,
0.00356342531619103, 0.00352224165959556, 0.00351722666683608,
0.00349184335907274, 0.00346394410318992), `EUR/GBP_TotalCount` = structure(c(-0.179518680545716,
-0.0757259172924681, 0.333514120677483, 0.759064450015801, -0.419724789788948,
-0.360414639358521), .Dim = c(6L, 1L)), `EUR/GBP_BloombergCount` = structure(c(-0.701694550941621,
-0.669811381311996, -0.574161872423118, -0.644304845608295, -0.784590791978649,
-0.631551577756444), .Dim = c(6L, 1L)), `EUR/GBP_SocialMediaCount` = structure(c(-1.68861759789696,
-1.66829994393287, -1.5910928588693, -1.59515638966212, -1.6967446594826,
-1.63172816679749), .Dim = c(6L, 1L)), `EUR/GBP_NewsCount` = structure(c(0.76560533722738,
0.879161625683434, 1.33717198912285, 1.90306082659552, 0.487392430510049,
0.487392430510049), .Dim = c(6L, 1L))), na.action = structure(c(`6` = 6L,
`38` = 38L, `74` = 74L, `101` = 101L, `140` = 140L, `165` = 165L,
`189` = 189L, `197` = 197L, `236` = 236L, `256` = 256L, `323` = 323L,
`351` = 351L, `393` = 393L, `423` = 423L, `442` = 442L, `455` = 455L,
`490` = 490L, `510` = 510L, `551` = 551L, `576` = 576L, `605` = 605L,
`646` = 646L, `676` = 676L, `696` = 696L, `708` = 708L, `742` = 742L,
`762` = 762L, `793` = 793L, `829` = 829L, `858` = 858L, `904` = 904L,
`929` = 929L, `950` = 950L, `961` = 961L, `996` = 996L, `1016` = 1016L,
`1089` = 1089L, `1114` = 1114L, `1159` = 1159L, `1184` = 1184L,
`1207` = 1207L, `1216` = 1216L, `1238` = 1238L, `1243` = 1243L,
`1253` = 1253L, `1278` = 1278L, `1315` = 1315L, `1346` = 1346L,
`1372` = 1372L, `1416` = 1416L, `1441` = 1441L, `1473` = 1473L,
`1532` = 1532L, `1599` = 1599L, `1626` = 1626L, `1669` = 1669L,
`1694` = 1694L, `1718` = 1718L, `1726` = 1726L, `1766` = 1766L,
`1786` = 1786L, `1827` = 1827L, `1853` = 1853L, `1881` = 1881L,
`1922` = 1922L, `1952` = 1952L, `1971` = 1971L, `1984` = 1984L,
`2019` = 2019L, `2039` = 2039L, `2075` = 2075L, `2106` = 2106L,
`2135` = 2135L, `2181` = 2181L, `2206` = 2206L, `2227` = 2227L,
`2238` = 2238L, `2273` = 2273L, `2293` = 2293L, `2325` = 2325L,
`2366` = 2366L, `2391` = 2391L, `2436` = 2436L, `2461` = 2461L,
`2483` = 2483L, `2493` = 2493L), class = "omit"), row.names = c(1L,
2L, 3L, 4L, 5L, 7L), class = "data.frame")
I have built 9 regression models per forecast horizon (t+1, t+5 and t+22) and I am using the predict function to make my forecasts. I have coded this in an R loop, where I also try to assign each forecast to a matrix. My code is the following:
EUR/GBP_RV_5`+data.estimateI am trying to calculate realized volatility forecasts using a rolling window forecast. My aim is to use the first 500 observations to forecast the 501st observations, then shift the window forward one step using observations 2 to 501 to predict the 502nd observation. I want this to repeat until I have a complete pseudo out-of-sample forecast.
My df contains 2411 observations of 23 variables, here is small example:
Date
EUR/GBP_RV t+1
EUR/GBP_RV
EUR/GBP_RV_5
EUR/GBP_RV_22
2012-02-13
0.004019947
0.004467109
0.004995980
0.005150602
2012-02-14
0.004077322
0.004019947
0.004704742
0.005099209
2012-02-15
0.004666244
0.004077322
0.004564522
0.005020790
2012-02-16
0.004582351
0.004666244
0.004532930
0.005011078
2012-02-17
0.003951071
0.004582351
0.004362595
0.004999634
2012-02-21
0.005549329
0.004824547
0.004467109
0.004954358
The head of the df can be reproduced with
structure(list(Date = structure(c(15383, 15384, 15385, 15386,
15387, 15391), class = "Date"), `EUR/GBP_RV t+1,t+22` = c(0.00437808494654599,
0.00439764887779732, 0.00441997330738947, 0.00437799055732722,
0.00435021150904479, 0.00434881306458859), `EUR/GBP_RGV t+1,t+22` = c(0.00310674728131117,
0.00311502965608506, 0.00313756204195853, 0.00312923997431178,
0.00310846773074243, 0.00309755540903969), `EUR/GBP_RBV t+1,t+22` = c(0.00304961980133602,
0.00306866297401415, 0.00307794319983677, 0.00302801249035602,
0.00300946121851254, 0.00302272755554915), `EUR/GBP_RV t+1,t+5` = c(0.00425938711995146,
0.00442030721926592, 0.00471470868108043, 0.00487869292442023,
0.00476849421943949, 0.0046067439660438), `EUR/GBP_RGV t+1,t+5` = c(0.00287718093809447,
0.00311308998902836, 0.00344398536439729, 0.00376911066284235,
0.00377425759242542, 0.00353909902900148), `EUR/GBP_RBV t+1,t+5` = c(0.00313771439501486,
0.00310626895475871, 0.0031789431316576, 0.00305962424370556,
0.00288671182187571, 0.00291630955829613), `EUR/GBP_RV t+1` = c(0.00401994700051122,
0.00407732180013827, 0.00466624428620966, 0.00458235106134663,
0.00395107145155152, 0.00554932910921084), `EUR/GBP_RGV t+1` = c(0.00280067842079775,
0.00275522601341373, 0.00296142025653418, 0.00320716195737542,
0.00266141804235125, 0.00440970289025837), `EUR/GBP_RBV t+1` = c(0.00288377777753365,
0.00300554199386584, 0.00360608177982326, 0.00327292734850446,
0.0029202430753471, 0.00336891287836027), `EUR/GBP_RV` = c(0.00446710941914797,
0.00401994700051122, 0.00407732180013827, 0.00466624428620966,
0.00458235106134663, 0.00482454749708351), `EUR/GBP_RV_5` = c(0.00499598016427624,
0.00470474196716823, 0.00456452150727461, 0.00453292965488229,
0.00436259471347075, 0.00442030721926592), `EUR/GBP_RV_22` = c(0.00515060219897263,
0.00509920878086075, 0.00502079002092667, 0.00501107755050095,
0.00499963428727425, 0.00495435807685843), `EUR/GBP_RBV` = c(0.00324667045338159,
0.00288377777753365, 0.00300554199386584, 0.00360608177982326,
0.00327292734850446, 0.00272655057625291), `EUR/GBP_RBV_5` = c(0.0034985439252634,
0.00318731350301598, 0.00319529774619179, 0.0032799330165155,
0.00320299987062176, 0.00310626895475871), `EUR/GBP_RBV_22` = c(0.0036581887941976,
0.00362298829344015, 0.00355498498935768, 0.0035465419934449,
0.00355752455210586, 0.00351669973034298), `EUR/GBP_RGV` = c(0.00306825643155514,
0.00280067842079775, 0.00275522601341373, 0.00296142025653418,
0.00320716195737542, 0.00398022367546721), `EUR/GBP_RGV_5` = c(0.00353290218424469,
0.00345194162523714, 0.00325362896209417, 0.00312087362386985,
0.00295854861593525, 0.00311308998902836), `EUR/GBP_RGV_22` = c(0.00359974659692405,
0.00356342531619103, 0.00352224165959556, 0.00351722666683608,
0.00349184335907274, 0.00346394410318992), `EUR/GBP_TotalCount` = structure(c(-0.179518680545716,
-0.0757259172924681, 0.333514120677483, 0.759064450015801, -0.419724789788948,
-0.360414639358521), .Dim = c(6L, 1L)), `EUR/GBP_BloombergCount` = structure(c(-0.701694550941621,
-0.669811381311996, -0.574161872423118, -0.644304845608295, -0.784590791978649,
-0.631551577756444), .Dim = c(6L, 1L)), `EUR/GBP_SocialMediaCount` = structure(c(-1.68861759789696,
-1.66829994393287, -1.5910928588693, -1.59515638966212, -1.6967446594826,
-1.63172816679749), .Dim = c(6L, 1L)), `EUR/GBP_NewsCount` = structure(c(0.76560533722738,
0.879161625683434, 1.33717198912285, 1.90306082659552, 0.487392430510049,
0.487392430510049), .Dim = c(6L, 1L))), na.action = structure(c(`6` = 6L,
`38` = 38L, `74` = 74L, `101` = 101L, `140` = 140L, `165` = 165L,
`189` = 189L, `197` = 197L, `236` = 236L, `256` = 256L, `323` = 323L,
`351` = 351L, `393` = 393L, `423` = 423L, `442` = 442L, `455` = 455L,
`490` = 490L, `510` = 510L, `551` = 551L, `576` = 576L, `605` = 605L,
`646` = 646L, `676` = 676L, `696` = 696L, `708` = 708L, `742` = 742L,
`762` = 762L, `793` = 793L, `829` = 829L, `858` = 858L, `904` = 904L,
`929` = 929L, `950` = 950L, `961` = 961L, `996` = 996L, `1016` = 1016L,
`1089` = 1089L, `1114` = 1114L, `1159` = 1159L, `1184` = 1184L,
`1207` = 1207L, `1216` = 1216L, `1238` = 1238L, `1243` = 1243L,
`1253` = 1253L, `1278` = 1278L, `1315` = 1315L, `1346` = 1346L,
`1372` = 1372L, `1416` = 1416L, `1441` = 1441L, `1473` = 1473L,
`1532` = 1532L, `1599` = 1599L, `1626` = 1626L, `1669` = 1669L,
`1694` = 1694L, `1718` = 1718L, `1726` = 1726L, `1766` = 1766L,
`1786` = 1786L, `1827` = 1827L, `1853` = 1853L, `1881` = 1881L,
`1922` = 1922L, `1952` = 1952L, `1971` = 1971L, `1984` = 1984L,
`2019` = 2019L, `2039` = 2039L, `2075` = 2075L, `2106` = 2106L,
`2135` = 2135L, `2181` = 2181L, `2206` = 2206L, `2227` = 2227L,
`2238` = 2238L, `2273` = 2273L, `2293` = 2293L, `2325` = 2325L,
`2366` = 2366L, `2391` = 2391L, `2436` = 2436L, `2461` = 2461L,
`2483` = 2483L, `2493` = 2493L), class = "omit"), row.names = c(1L,
2L, 3L, 4L, 5L, 7L), class = "data.frame")
I have built 9 regression models per forecast horizon (t+1, t+5 and t+22) and I am using the predict function to make my forecasts. I have coded this in an R loop, where I also try to assign each forecast to a matrix. My code is the following:
EUR/GBP_RV_22`+data.estimateI am trying to calculate realized volatility forecasts using a rolling window forecast. My aim is to use the first 500 observations to forecast the 501st observations, then shift the window forward one step using observations 2 to 501 to predict the 502nd observation. I want this to repeat until I have a complete pseudo out-of-sample forecast.
My df contains 2411 observations of 23 variables, here is small example:
Date
EUR/GBP_RV t+1
EUR/GBP_RV
EUR/GBP_RV_5
EUR/GBP_RV_22
2012-02-13
0.004019947
0.004467109
0.004995980
0.005150602
2012-02-14
0.004077322
0.004019947
0.004704742
0.005099209
2012-02-15
0.004666244
0.004077322
0.004564522
0.005020790
2012-02-16
0.004582351
0.004666244
0.004532930
0.005011078
2012-02-17
0.003951071
0.004582351
0.004362595
0.004999634
2012-02-21
0.005549329
0.004824547
0.004467109
0.004954358
The head of the df can be reproduced with
structure(list(Date = structure(c(15383, 15384, 15385, 15386,
15387, 15391), class = "Date"), `EUR/GBP_RV t+1,t+22` = c(0.00437808494654599,
0.00439764887779732, 0.00441997330738947, 0.00437799055732722,
0.00435021150904479, 0.00434881306458859), `EUR/GBP_RGV t+1,t+22` = c(0.00310674728131117,
0.00311502965608506, 0.00313756204195853, 0.00312923997431178,
0.00310846773074243, 0.00309755540903969), `EUR/GBP_RBV t+1,t+22` = c(0.00304961980133602,
0.00306866297401415, 0.00307794319983677, 0.00302801249035602,
0.00300946121851254, 0.00302272755554915), `EUR/GBP_RV t+1,t+5` = c(0.00425938711995146,
0.00442030721926592, 0.00471470868108043, 0.00487869292442023,
0.00476849421943949, 0.0046067439660438), `EUR/GBP_RGV t+1,t+5` = c(0.00287718093809447,
0.00311308998902836, 0.00344398536439729, 0.00376911066284235,
0.00377425759242542, 0.00353909902900148), `EUR/GBP_RBV t+1,t+5` = c(0.00313771439501486,
0.00310626895475871, 0.0031789431316576, 0.00305962424370556,
0.00288671182187571, 0.00291630955829613), `EUR/GBP_RV t+1` = c(0.00401994700051122,
0.00407732180013827, 0.00466624428620966, 0.00458235106134663,
0.00395107145155152, 0.00554932910921084), `EUR/GBP_RGV t+1` = c(0.00280067842079775,
0.00275522601341373, 0.00296142025653418, 0.00320716195737542,
0.00266141804235125, 0.00440970289025837), `EUR/GBP_RBV t+1` = c(0.00288377777753365,
0.00300554199386584, 0.00360608177982326, 0.00327292734850446,
0.0029202430753471, 0.00336891287836027), `EUR/GBP_RV` = c(0.00446710941914797,
0.00401994700051122, 0.00407732180013827, 0.00466624428620966,
0.00458235106134663, 0.00482454749708351), `EUR/GBP_RV_5` = c(0.00499598016427624,
0.00470474196716823, 0.00456452150727461, 0.00453292965488229,
0.00436259471347075, 0.00442030721926592), `EUR/GBP_RV_22` = c(0.00515060219897263,
0.00509920878086075, 0.00502079002092667, 0.00501107755050095,
0.00499963428727425, 0.00495435807685843), `EUR/GBP_RBV` = c(0.00324667045338159,
0.00288377777753365, 0.00300554199386584, 0.00360608177982326,
0.00327292734850446, 0.00272655057625291), `EUR/GBP_RBV_5` = c(0.0034985439252634,
0.00318731350301598, 0.00319529774619179, 0.0032799330165155,
0.00320299987062176, 0.00310626895475871), `EUR/GBP_RBV_22` = c(0.0036581887941976,
0.00362298829344015, 0.00355498498935768, 0.0035465419934449,
0.00355752455210586, 0.00351669973034298), `EUR/GBP_RGV` = c(0.00306825643155514,
0.00280067842079775, 0.00275522601341373, 0.00296142025653418,
0.00320716195737542, 0.00398022367546721), `EUR/GBP_RGV_5` = c(0.00353290218424469,
0.00345194162523714, 0.00325362896209417, 0.00312087362386985,
0.00295854861593525, 0.00311308998902836), `EUR/GBP_RGV_22` = c(0.00359974659692405,
0.00356342531619103, 0.00352224165959556, 0.00351722666683608,
0.00349184335907274, 0.00346394410318992), `EUR/GBP_TotalCount` = structure(c(-0.179518680545716,
-0.0757259172924681, 0.333514120677483, 0.759064450015801, -0.419724789788948,
-0.360414639358521), .Dim = c(6L, 1L)), `EUR/GBP_BloombergCount` = structure(c(-0.701694550941621,
-0.669811381311996, -0.574161872423118, -0.644304845608295, -0.784590791978649,
-0.631551577756444), .Dim = c(6L, 1L)), `EUR/GBP_SocialMediaCount` = structure(c(-1.68861759789696,
-1.66829994393287, -1.5910928588693, -1.59515638966212, -1.6967446594826,
-1.63172816679749), .Dim = c(6L, 1L)), `EUR/GBP_NewsCount` = structure(c(0.76560533722738,
0.879161625683434, 1.33717198912285, 1.90306082659552, 0.487392430510049,
0.487392430510049), .Dim = c(6L, 1L))), na.action = structure(c(`6` = 6L,
`38` = 38L, `74` = 74L, `101` = 101L, `140` = 140L, `165` = 165L,
`189` = 189L, `197` = 197L, `236` = 236L, `256` = 256L, `323` = 323L,
`351` = 351L, `393` = 393L, `423` = 423L, `442` = 442L, `455` = 455L,
`490` = 490L, `510` = 510L, `551` = 551L, `576` = 576L, `605` = 605L,
`646` = 646L, `676` = 676L, `696` = 696L, `708` = 708L, `742` = 742L,
`762` = 762L, `793` = 793L, `829` = 829L, `858` = 858L, `904` = 904L,
`929` = 929L, `950` = 950L, `961` = 961L, `996` = 996L, `1016` = 1016L,
`1089` = 1089L, `1114` = 1114L, `1159` = 1159L, `1184` = 1184L,
`1207` = 1207L, `1216` = 1216L, `1238` = 1238L, `1243` = 1243L,
`1253` = 1253L, `1278` = 1278L, `1315` = 1315L, `1346` = 1346L,
`1372` = 1372L, `1416` = 1416L, `1441` = 1441L, `1473` = 1473L,
`1532` = 1532L, `1599` = 1599L, `1626` = 1626L, `1669` = 1669L,
`1694` = 1694L, `1718` = 1718L, `1726` = 1726L, `1766` = 1766L,
`1786` = 1786L, `1827` = 1827L, `1853` = 1853L, `1881` = 1881L,
`1922` = 1922L, `1952` = 1952L, `1971` = 1971L, `1984` = 1984L,
`2019` = 2019L, `2039` = 2039L, `2075` = 2075L, `2106` = 2106L,
`2135` = 2135L, `2181` = 2181L, `2206` = 2206L, `2227` = 2227L,
`2238` = 2238L, `2273` = 2273L, `2293` = 2293L, `2325` = 2325L,
`2366` = 2366L, `2391` = 2391L, `2436` = 2436L, `2461` = 2461L,
`2483` = 2483L, `2493` = 2493L), class = "omit"), row.names = c(1L,
2L, 3L, 4L, 5L, 7L), class = "data.frame")
I have built 9 regression models per forecast horizon (t+1, t+5 and t+22) and I am using the predict function to make my forecasts. I have coded this in an R loop, where I also try to assign each forecast to a matrix. My code is the following:
EUR/GBP_TotalCount`)
EURGBP_HAR_RVBt5_train <- lm(data.estimateI am trying to calculate realized volatility forecasts using a rolling window forecast. My aim is to use the first 500 observations to forecast the 501st observations, then shift the window forward one step using observations 2 to 501 to predict the 502nd observation. I want this to repeat until I have a complete pseudo out-of-sample forecast.
My df contains 2411 observations of 23 variables, here is small example:
Date
EUR/GBP_RV t+1
EUR/GBP_RV
EUR/GBP_RV_5
EUR/GBP_RV_22
2012-02-13
0.004019947
0.004467109
0.004995980
0.005150602
2012-02-14
0.004077322
0.004019947
0.004704742
0.005099209
2012-02-15
0.004666244
0.004077322
0.004564522
0.005020790
2012-02-16
0.004582351
0.004666244
0.004532930
0.005011078
2012-02-17
0.003951071
0.004582351
0.004362595
0.004999634
2012-02-21
0.005549329
0.004824547
0.004467109
0.004954358
The head of the df can be reproduced with
structure(list(Date = structure(c(15383, 15384, 15385, 15386,
15387, 15391), class = "Date"), `EUR/GBP_RV t+1,t+22` = c(0.00437808494654599,
0.00439764887779732, 0.00441997330738947, 0.00437799055732722,
0.00435021150904479, 0.00434881306458859), `EUR/GBP_RGV t+1,t+22` = c(0.00310674728131117,
0.00311502965608506, 0.00313756204195853, 0.00312923997431178,
0.00310846773074243, 0.00309755540903969), `EUR/GBP_RBV t+1,t+22` = c(0.00304961980133602,
0.00306866297401415, 0.00307794319983677, 0.00302801249035602,
0.00300946121851254, 0.00302272755554915), `EUR/GBP_RV t+1,t+5` = c(0.00425938711995146,
0.00442030721926592, 0.00471470868108043, 0.00487869292442023,
0.00476849421943949, 0.0046067439660438), `EUR/GBP_RGV t+1,t+5` = c(0.00287718093809447,
0.00311308998902836, 0.00344398536439729, 0.00376911066284235,
0.00377425759242542, 0.00353909902900148), `EUR/GBP_RBV t+1,t+5` = c(0.00313771439501486,
0.00310626895475871, 0.0031789431316576, 0.00305962424370556,
0.00288671182187571, 0.00291630955829613), `EUR/GBP_RV t+1` = c(0.00401994700051122,
0.00407732180013827, 0.00466624428620966, 0.00458235106134663,
0.00395107145155152, 0.00554932910921084), `EUR/GBP_RGV t+1` = c(0.00280067842079775,
0.00275522601341373, 0.00296142025653418, 0.00320716195737542,
0.00266141804235125, 0.00440970289025837), `EUR/GBP_RBV t+1` = c(0.00288377777753365,
0.00300554199386584, 0.00360608177982326, 0.00327292734850446,
0.0029202430753471, 0.00336891287836027), `EUR/GBP_RV` = c(0.00446710941914797,
0.00401994700051122, 0.00407732180013827, 0.00466624428620966,
0.00458235106134663, 0.00482454749708351), `EUR/GBP_RV_5` = c(0.00499598016427624,
0.00470474196716823, 0.00456452150727461, 0.00453292965488229,
0.00436259471347075, 0.00442030721926592), `EUR/GBP_RV_22` = c(0.00515060219897263,
0.00509920878086075, 0.00502079002092667, 0.00501107755050095,
0.00499963428727425, 0.00495435807685843), `EUR/GBP_RBV` = c(0.00324667045338159,
0.00288377777753365, 0.00300554199386584, 0.00360608177982326,
0.00327292734850446, 0.00272655057625291), `EUR/GBP_RBV_5` = c(0.0034985439252634,
0.00318731350301598, 0.00319529774619179, 0.0032799330165155,
0.00320299987062176, 0.00310626895475871), `EUR/GBP_RBV_22` = c(0.0036581887941976,
0.00362298829344015, 0.00355498498935768, 0.0035465419934449,
0.00355752455210586, 0.00351669973034298), `EUR/GBP_RGV` = c(0.00306825643155514,
0.00280067842079775, 0.00275522601341373, 0.00296142025653418,
0.00320716195737542, 0.00398022367546721), `EUR/GBP_RGV_5` = c(0.00353290218424469,
0.00345194162523714, 0.00325362896209417, 0.00312087362386985,
0.00295854861593525, 0.00311308998902836), `EUR/GBP_RGV_22` = c(0.00359974659692405,
0.00356342531619103, 0.00352224165959556, 0.00351722666683608,
0.00349184335907274, 0.00346394410318992), `EUR/GBP_TotalCount` = structure(c(-0.179518680545716,
-0.0757259172924681, 0.333514120677483, 0.759064450015801, -0.419724789788948,
-0.360414639358521), .Dim = c(6L, 1L)), `EUR/GBP_BloombergCount` = structure(c(-0.701694550941621,
-0.669811381311996, -0.574161872423118, -0.644304845608295, -0.784590791978649,
-0.631551577756444), .Dim = c(6L, 1L)), `EUR/GBP_SocialMediaCount` = structure(c(-1.68861759789696,
-1.66829994393287, -1.5910928588693, -1.59515638966212, -1.6967446594826,
-1.63172816679749), .Dim = c(6L, 1L)), `EUR/GBP_NewsCount` = structure(c(0.76560533722738,
0.879161625683434, 1.33717198912285, 1.90306082659552, 0.487392430510049,
0.487392430510049), .Dim = c(6L, 1L))), na.action = structure(c(`6` = 6L,
`38` = 38L, `74` = 74L, `101` = 101L, `140` = 140L, `165` = 165L,
`189` = 189L, `197` = 197L, `236` = 236L, `256` = 256L, `323` = 323L,
`351` = 351L, `393` = 393L, `423` = 423L, `442` = 442L, `455` = 455L,
`490` = 490L, `510` = 510L, `551` = 551L, `576` = 576L, `605` = 605L,
`646` = 646L, `676` = 676L, `696` = 696L, `708` = 708L, `742` = 742L,
`762` = 762L, `793` = 793L, `829` = 829L, `858` = 858L, `904` = 904L,
`929` = 929L, `950` = 950L, `961` = 961L, `996` = 996L, `1016` = 1016L,
`1089` = 1089L, `1114` = 1114L, `1159` = 1159L, `1184` = 1184L,
`1207` = 1207L, `1216` = 1216L, `1238` = 1238L, `1243` = 1243L,
`1253` = 1253L, `1278` = 1278L, `1315` = 1315L, `1346` = 1346L,
`1372` = 1372L, `1416` = 1416L, `1441` = 1441L, `1473` = 1473L,
`1532` = 1532L, `1599` = 1599L, `1626` = 1626L, `1669` = 1669L,
`1694` = 1694L, `1718` = 1718L, `1726` = 1726L, `1766` = 1766L,
`1786` = 1786L, `1827` = 1827L, `1853` = 1853L, `1881` = 1881L,
`1922` = 1922L, `1952` = 1952L, `1971` = 1971L, `1984` = 1984L,
`2019` = 2019L, `2039` = 2039L, `2075` = 2075L, `2106` = 2106L,
`2135` = 2135L, `2181` = 2181L, `2206` = 2206L, `2227` = 2227L,
`2238` = 2238L, `2273` = 2273L, `2293` = 2293L, `2325` = 2325L,
`2366` = 2366L, `2391` = 2391L, `2436` = 2436L, `2461` = 2461L,
`2483` = 2483L, `2493` = 2493L), class = "omit"), row.names = c(1L,
2L, 3L, 4L, 5L, 7L), class = "data.frame")
I have built 9 regression models per forecast horizon (t+1, t+5 and t+22) and I am using the predict function to make my forecasts. I have coded this in an R loop, where I also try to assign each forecast to a matrix. My code is the following:
EUR/GBP_RBV t+1,t+5`~data.estimateI am trying to calculate realized volatility forecasts using a rolling window forecast. My aim is to use the first 500 observations to forecast the 501st observations, then shift the window forward one step using observations 2 to 501 to predict the 502nd observation. I want this to repeat until I have a complete pseudo out-of-sample forecast.
My df contains 2411 observations of 23 variables, here is small example:
Date
EUR/GBP_RV t+1
EUR/GBP_RV
EUR/GBP_RV_5
EUR/GBP_RV_22
2012-02-13
0.004019947
0.004467109
0.004995980
0.005150602
2012-02-14
0.004077322
0.004019947
0.004704742
0.005099209
2012-02-15
0.004666244
0.004077322
0.004564522
0.005020790
2012-02-16
0.004582351
0.004666244
0.004532930
0.005011078
2012-02-17
0.003951071
0.004582351
0.004362595
0.004999634
2012-02-21
0.005549329
0.004824547
0.004467109
0.004954358
The head of the df can be reproduced with
structure(list(Date = structure(c(15383, 15384, 15385, 15386,
15387, 15391), class = "Date"), `EUR/GBP_RV t+1,t+22` = c(0.00437808494654599,
0.00439764887779732, 0.00441997330738947, 0.00437799055732722,
0.00435021150904479, 0.00434881306458859), `EUR/GBP_RGV t+1,t+22` = c(0.00310674728131117,
0.00311502965608506, 0.00313756204195853, 0.00312923997431178,
0.00310846773074243, 0.00309755540903969), `EUR/GBP_RBV t+1,t+22` = c(0.00304961980133602,
0.00306866297401415, 0.00307794319983677, 0.00302801249035602,
0.00300946121851254, 0.00302272755554915), `EUR/GBP_RV t+1,t+5` = c(0.00425938711995146,
0.00442030721926592, 0.00471470868108043, 0.00487869292442023,
0.00476849421943949, 0.0046067439660438), `EUR/GBP_RGV t+1,t+5` = c(0.00287718093809447,
0.00311308998902836, 0.00344398536439729, 0.00376911066284235,
0.00377425759242542, 0.00353909902900148), `EUR/GBP_RBV t+1,t+5` = c(0.00313771439501486,
0.00310626895475871, 0.0031789431316576, 0.00305962424370556,
0.00288671182187571, 0.00291630955829613), `EUR/GBP_RV t+1` = c(0.00401994700051122,
0.00407732180013827, 0.00466624428620966, 0.00458235106134663,
0.00395107145155152, 0.00554932910921084), `EUR/GBP_RGV t+1` = c(0.00280067842079775,
0.00275522601341373, 0.00296142025653418, 0.00320716195737542,
0.00266141804235125, 0.00440970289025837), `EUR/GBP_RBV t+1` = c(0.00288377777753365,
0.00300554199386584, 0.00360608177982326, 0.00327292734850446,
0.0029202430753471, 0.00336891287836027), `EUR/GBP_RV` = c(0.00446710941914797,
0.00401994700051122, 0.00407732180013827, 0.00466624428620966,
0.00458235106134663, 0.00482454749708351), `EUR/GBP_RV_5` = c(0.00499598016427624,
0.00470474196716823, 0.00456452150727461, 0.00453292965488229,
0.00436259471347075, 0.00442030721926592), `EUR/GBP_RV_22` = c(0.00515060219897263,
0.00509920878086075, 0.00502079002092667, 0.00501107755050095,
0.00499963428727425, 0.00495435807685843), `EUR/GBP_RBV` = c(0.00324667045338159,
0.00288377777753365, 0.00300554199386584, 0.00360608177982326,
0.00327292734850446, 0.00272655057625291), `EUR/GBP_RBV_5` = c(0.0034985439252634,
0.00318731350301598, 0.00319529774619179, 0.0032799330165155,
0.00320299987062176, 0.00310626895475871), `EUR/GBP_RBV_22` = c(0.0036581887941976,
0.00362298829344015, 0.00355498498935768, 0.0035465419934449,
0.00355752455210586, 0.00351669973034298), `EUR/GBP_RGV` = c(0.00306825643155514,
0.00280067842079775, 0.00275522601341373, 0.00296142025653418,
0.00320716195737542, 0.00398022367546721), `EUR/GBP_RGV_5` = c(0.00353290218424469,
0.00345194162523714, 0.00325362896209417, 0.00312087362386985,
0.00295854861593525, 0.00311308998902836), `EUR/GBP_RGV_22` = c(0.00359974659692405,
0.00356342531619103, 0.00352224165959556, 0.00351722666683608,
0.00349184335907274, 0.00346394410318992), `EUR/GBP_TotalCount` = structure(c(-0.179518680545716,
-0.0757259172924681, 0.333514120677483, 0.759064450015801, -0.419724789788948,
-0.360414639358521), .Dim = c(6L, 1L)), `EUR/GBP_BloombergCount` = structure(c(-0.701694550941621,
-0.669811381311996, -0.574161872423118, -0.644304845608295, -0.784590791978649,
-0.631551577756444), .Dim = c(6L, 1L)), `EUR/GBP_SocialMediaCount` = structure(c(-1.68861759789696,
-1.66829994393287, -1.5910928588693, -1.59515638966212, -1.6967446594826,
-1.63172816679749), .Dim = c(6L, 1L)), `EUR/GBP_NewsCount` = structure(c(0.76560533722738,
0.879161625683434, 1.33717198912285, 1.90306082659552, 0.487392430510049,
0.487392430510049), .Dim = c(6L, 1L))), na.action = structure(c(`6` = 6L,
`38` = 38L, `74` = 74L, `101` = 101L, `140` = 140L, `165` = 165L,
`189` = 189L, `197` = 197L, `236` = 236L, `256` = 256L, `323` = 323L,
`351` = 351L, `393` = 393L, `423` = 423L, `442` = 442L, `455` = 455L,
`490` = 490L, `510` = 510L, `551` = 551L, `576` = 576L, `605` = 605L,
`646` = 646L, `676` = 676L, `696` = 696L, `708` = 708L, `742` = 742L,
`762` = 762L, `793` = 793L, `829` = 829L, `858` = 858L, `904` = 904L,
`929` = 929L, `950` = 950L, `961` = 961L, `996` = 996L, `1016` = 1016L,
`1089` = 1089L, `1114` = 1114L, `1159` = 1159L, `1184` = 1184L,
`1207` = 1207L, `1216` = 1216L, `1238` = 1238L, `1243` = 1243L,
`1253` = 1253L, `1278` = 1278L, `1315` = 1315L, `1346` = 1346L,
`1372` = 1372L, `1416` = 1416L, `1441` = 1441L, `1473` = 1473L,
`1532` = 1532L, `1599` = 1599L, `1626` = 1626L, `1669` = 1669L,
`1694` = 1694L, `1718` = 1718L, `1726` = 1726L, `1766` = 1766L,
`1786` = 1786L, `1827` = 1827L, `1853` = 1853L, `1881` = 1881L,
`1922` = 1922L, `1952` = 1952L, `1971` = 1971L, `1984` = 1984L,
`2019` = 2019L, `2039` = 2039L, `2075` = 2075L, `2106` = 2106L,
`2135` = 2135L, `2181` = 2181L, `2206` = 2206L, `2227` = 2227L,
`2238` = 2238L, `2273` = 2273L, `2293` = 2293L, `2325` = 2325L,
`2366` = 2366L, `2391` = 2391L, `2436` = 2436L, `2461` = 2461L,
`2483` = 2483L, `2493` = 2493L), class = "omit"), row.names = c(1L,
2L, 3L, 4L, 5L, 7L), class = "data.frame")
I have built 9 regression models per forecast horizon (t+1, t+5 and t+22) and I am using the predict function to make my forecasts. I have coded this in an R loop, where I also try to assign each forecast to a matrix. My code is the following:
EUR/GBP_RBV`+data.estimateI am trying to calculate realized volatility forecasts using a rolling window forecast. My aim is to use the first 500 observations to forecast the 501st observations, then shift the window forward one step using observations 2 to 501 to predict the 502nd observation. I want this to repeat until I have a complete pseudo out-of-sample forecast.
My df contains 2411 observations of 23 variables, here is small example:
Date
EUR/GBP_RV t+1
EUR/GBP_RV
EUR/GBP_RV_5
EUR/GBP_RV_22
2012-02-13
0.004019947
0.004467109
0.004995980
0.005150602
2012-02-14
0.004077322
0.004019947
0.004704742
0.005099209
2012-02-15
0.004666244
0.004077322
0.004564522
0.005020790
2012-02-16
0.004582351
0.004666244
0.004532930
0.005011078
2012-02-17
0.003951071
0.004582351
0.004362595
0.004999634
2012-02-21
0.005549329
0.004824547
0.004467109
0.004954358
The head of the df can be reproduced with
structure(list(Date = structure(c(15383, 15384, 15385, 15386,
15387, 15391), class = "Date"), `EUR/GBP_RV t+1,t+22` = c(0.00437808494654599,
0.00439764887779732, 0.00441997330738947, 0.00437799055732722,
0.00435021150904479, 0.00434881306458859), `EUR/GBP_RGV t+1,t+22` = c(0.00310674728131117,
0.00311502965608506, 0.00313756204195853, 0.00312923997431178,
0.00310846773074243, 0.00309755540903969), `EUR/GBP_RBV t+1,t+22` = c(0.00304961980133602,
0.00306866297401415, 0.00307794319983677, 0.00302801249035602,
0.00300946121851254, 0.00302272755554915), `EUR/GBP_RV t+1,t+5` = c(0.00425938711995146,
0.00442030721926592, 0.00471470868108043, 0.00487869292442023,
0.00476849421943949, 0.0046067439660438), `EUR/GBP_RGV t+1,t+5` = c(0.00287718093809447,
0.00311308998902836, 0.00344398536439729, 0.00376911066284235,
0.00377425759242542, 0.00353909902900148), `EUR/GBP_RBV t+1,t+5` = c(0.00313771439501486,
0.00310626895475871, 0.0031789431316576, 0.00305962424370556,
0.00288671182187571, 0.00291630955829613), `EUR/GBP_RV t+1` = c(0.00401994700051122,
0.00407732180013827, 0.00466624428620966, 0.00458235106134663,
0.00395107145155152, 0.00554932910921084), `EUR/GBP_RGV t+1` = c(0.00280067842079775,
0.00275522601341373, 0.00296142025653418, 0.00320716195737542,
0.00266141804235125, 0.00440970289025837), `EUR/GBP_RBV t+1` = c(0.00288377777753365,
0.00300554199386584, 0.00360608177982326, 0.00327292734850446,
0.0029202430753471, 0.00336891287836027), `EUR/GBP_RV` = c(0.00446710941914797,
0.00401994700051122, 0.00407732180013827, 0.00466624428620966,
0.00458235106134663, 0.00482454749708351), `EUR/GBP_RV_5` = c(0.00499598016427624,
0.00470474196716823, 0.00456452150727461, 0.00453292965488229,
0.00436259471347075, 0.00442030721926592), `EUR/GBP_RV_22` = c(0.00515060219897263,
0.00509920878086075, 0.00502079002092667, 0.00501107755050095,
0.00499963428727425, 0.00495435807685843), `EUR/GBP_RBV` = c(0.00324667045338159,
0.00288377777753365, 0.00300554199386584, 0.00360608177982326,
0.00327292734850446, 0.00272655057625291), `EUR/GBP_RBV_5` = c(0.0034985439252634,
0.00318731350301598, 0.00319529774619179, 0.0032799330165155,
0.00320299987062176, 0.00310626895475871), `EUR/GBP_RBV_22` = c(0.0036581887941976,
0.00362298829344015, 0.00355498498935768, 0.0035465419934449,
0.00355752455210586, 0.00351669973034298), `EUR/GBP_RGV` = c(0.00306825643155514,
0.00280067842079775, 0.00275522601341373, 0.00296142025653418,
0.00320716195737542, 0.00398022367546721), `EUR/GBP_RGV_5` = c(0.00353290218424469,
0.00345194162523714, 0.00325362896209417, 0.00312087362386985,
0.00295854861593525, 0.00311308998902836), `EUR/GBP_RGV_22` = c(0.00359974659692405,
0.00356342531619103, 0.00352224165959556, 0.00351722666683608,
0.00349184335907274, 0.00346394410318992), `EUR/GBP_TotalCount` = structure(c(-0.179518680545716,
-0.0757259172924681, 0.333514120677483, 0.759064450015801, -0.419724789788948,
-0.360414639358521), .Dim = c(6L, 1L)), `EUR/GBP_BloombergCount` = structure(c(-0.701694550941621,
-0.669811381311996, -0.574161872423118, -0.644304845608295, -0.784590791978649,
-0.631551577756444), .Dim = c(6L, 1L)), `EUR/GBP_SocialMediaCount` = structure(c(-1.68861759789696,
-1.66829994393287, -1.5910928588693, -1.59515638966212, -1.6967446594826,
-1.63172816679749), .Dim = c(6L, 1L)), `EUR/GBP_NewsCount` = structure(c(0.76560533722738,
0.879161625683434, 1.33717198912285, 1.90306082659552, 0.487392430510049,
0.487392430510049), .Dim = c(6L, 1L))), na.action = structure(c(`6` = 6L,
`38` = 38L, `74` = 74L, `101` = 101L, `140` = 140L, `165` = 165L,
`189` = 189L, `197` = 197L, `236` = 236L, `256` = 256L, `323` = 323L,
`351` = 351L, `393` = 393L, `423` = 423L, `442` = 442L, `455` = 455L,
`490` = 490L, `510` = 510L, `551` = 551L, `576` = 576L, `605` = 605L,
`646` = 646L, `676` = 676L, `696` = 696L, `708` = 708L, `742` = 742L,
`762` = 762L, `793` = 793L, `829` = 829L, `858` = 858L, `904` = 904L,
`929` = 929L, `950` = 950L, `961` = 961L, `996` = 996L, `1016` = 1016L,
`1089` = 1089L, `1114` = 1114L, `1159` = 1159L, `1184` = 1184L,
`1207` = 1207L, `1216` = 1216L, `1238` = 1238L, `1243` = 1243L,
`1253` = 1253L, `1278` = 1278L, `1315` = 1315L, `1346` = 1346L,
`1372` = 1372L, `1416` = 1416L, `1441` = 1441L, `1473` = 1473L,
`1532` = 1532L, `1599` = 1599L, `1626` = 1626L, `1669` = 1669L,
`1694` = 1694L, `1718` = 1718L, `1726` = 1726L, `1766` = 1766L,
`1786` = 1786L, `1827` = 1827L, `1853` = 1853L, `1881` = 1881L,
`1922` = 1922L, `1952` = 1952L, `1971` = 1971L, `1984` = 1984L,
`2019` = 2019L, `2039` = 2039L, `2075` = 2075L, `2106` = 2106L,
`2135` = 2135L, `2181` = 2181L, `2206` = 2206L, `2227` = 2227L,
`2238` = 2238L, `2273` = 2273L, `2293` = 2293L, `2325` = 2325L,
`2366` = 2366L, `2391` = 2391L, `2436` = 2436L, `2461` = 2461L,
`2483` = 2483L, `2493` = 2493L), class = "omit"), row.names = c(1L,
2L, 3L, 4L, 5L, 7L), class = "data.frame")
I have built 9 regression models per forecast horizon (t+1, t+5 and t+22) and I am using the predict function to make my forecasts. I have coded this in an R loop, where I also try to assign each forecast to a matrix. My code is the following:
EUR/GBP_RBV_5`+data.estimateI am trying to calculate realized volatility forecasts using a rolling window forecast. My aim is to use the first 500 observations to forecast the 501st observations, then shift the window forward one step using observations 2 to 501 to predict the 502nd observation. I want this to repeat until I have a complete pseudo out-of-sample forecast.
My df contains 2411 observations of 23 variables, here is small example:
Date
EUR/GBP_RV t+1
EUR/GBP_RV
EUR/GBP_RV_5
EUR/GBP_RV_22
2012-02-13
0.004019947
0.004467109
0.004995980
0.005150602
2012-02-14
0.004077322
0.004019947
0.004704742
0.005099209
2012-02-15
0.004666244
0.004077322
0.004564522
0.005020790
2012-02-16
0.004582351
0.004666244
0.004532930
0.005011078
2012-02-17
0.003951071
0.004582351
0.004362595
0.004999634
2012-02-21
0.005549329
0.004824547
0.004467109
0.004954358
The head of the df can be reproduced with
structure(list(Date = structure(c(15383, 15384, 15385, 15386,
15387, 15391), class = "Date"), `EUR/GBP_RV t+1,t+22` = c(0.00437808494654599,
0.00439764887779732, 0.00441997330738947, 0.00437799055732722,
0.00435021150904479, 0.00434881306458859), `EUR/GBP_RGV t+1,t+22` = c(0.00310674728131117,
0.00311502965608506, 0.00313756204195853, 0.00312923997431178,
0.00310846773074243, 0.00309755540903969), `EUR/GBP_RBV t+1,t+22` = c(0.00304961980133602,
0.00306866297401415, 0.00307794319983677, 0.00302801249035602,
0.00300946121851254, 0.00302272755554915), `EUR/GBP_RV t+1,t+5` = c(0.00425938711995146,
0.00442030721926592, 0.00471470868108043, 0.00487869292442023,
0.00476849421943949, 0.0046067439660438), `EUR/GBP_RGV t+1,t+5` = c(0.00287718093809447,
0.00311308998902836, 0.00344398536439729, 0.00376911066284235,
0.00377425759242542, 0.00353909902900148), `EUR/GBP_RBV t+1,t+5` = c(0.00313771439501486,
0.00310626895475871, 0.0031789431316576, 0.00305962424370556,
0.00288671182187571, 0.00291630955829613), `EUR/GBP_RV t+1` = c(0.00401994700051122,
0.00407732180013827, 0.00466624428620966, 0.00458235106134663,
0.00395107145155152, 0.00554932910921084), `EUR/GBP_RGV t+1` = c(0.00280067842079775,
0.00275522601341373, 0.00296142025653418, 0.00320716195737542,
0.00266141804235125, 0.00440970289025837), `EUR/GBP_RBV t+1` = c(0.00288377777753365,
0.00300554199386584, 0.00360608177982326, 0.00327292734850446,
0.0029202430753471, 0.00336891287836027), `EUR/GBP_RV` = c(0.00446710941914797,
0.00401994700051122, 0.00407732180013827, 0.00466624428620966,
0.00458235106134663, 0.00482454749708351), `EUR/GBP_RV_5` = c(0.00499598016427624,
0.00470474196716823, 0.00456452150727461, 0.00453292965488229,
0.00436259471347075, 0.00442030721926592), `EUR/GBP_RV_22` = c(0.00515060219897263,
0.00509920878086075, 0.00502079002092667, 0.00501107755050095,
0.00499963428727425, 0.00495435807685843), `EUR/GBP_RBV` = c(0.00324667045338159,
0.00288377777753365, 0.00300554199386584, 0.00360608177982326,
0.00327292734850446, 0.00272655057625291), `EUR/GBP_RBV_5` = c(0.0034985439252634,
0.00318731350301598, 0.00319529774619179, 0.0032799330165155,
0.00320299987062176, 0.00310626895475871), `EUR/GBP_RBV_22` = c(0.0036581887941976,
0.00362298829344015, 0.00355498498935768, 0.0035465419934449,
0.00355752455210586, 0.00351669973034298), `EUR/GBP_RGV` = c(0.00306825643155514,
0.00280067842079775, 0.00275522601341373, 0.00296142025653418,
0.00320716195737542, 0.00398022367546721), `EUR/GBP_RGV_5` = c(0.00353290218424469,
0.00345194162523714, 0.00325362896209417, 0.00312087362386985,
0.00295854861593525, 0.00311308998902836), `EUR/GBP_RGV_22` = c(0.00359974659692405,
0.00356342531619103, 0.00352224165959556, 0.00351722666683608,
0.00349184335907274, 0.00346394410318992), `EUR/GBP_TotalCount` = structure(c(-0.179518680545716,
-0.0757259172924681, 0.333514120677483, 0.759064450015801, -0.419724789788948,
-0.360414639358521), .Dim = c(6L, 1L)), `EUR/GBP_BloombergCount` = structure(c(-0.701694550941621,
-0.669811381311996, -0.574161872423118, -0.644304845608295, -0.784590791978649,
-0.631551577756444), .Dim = c(6L, 1L)), `EUR/GBP_SocialMediaCount` = structure(c(-1.68861759789696,
-1.66829994393287, -1.5910928588693, -1.59515638966212, -1.6967446594826,
-1.63172816679749), .Dim = c(6L, 1L)), `EUR/GBP_NewsCount` = structure(c(0.76560533722738,
0.879161625683434, 1.33717198912285, 1.90306082659552, 0.487392430510049,
0.487392430510049), .Dim = c(6L, 1L))), na.action = structure(c(`6` = 6L,
`38` = 38L, `74` = 74L, `101` = 101L, `140` = 140L, `165` = 165L,
`189` = 189L, `197` = 197L, `236` = 236L, `256` = 256L, `323` = 323L,
`351` = 351L, `393` = 393L, `423` = 423L, `442` = 442L, `455` = 455L,
`490` = 490L, `510` = 510L, `551` = 551L, `576` = 576L, `605` = 605L,
`646` = 646L, `676` = 676L, `696` = 696L, `708` = 708L, `742` = 742L,
`762` = 762L, `793` = 793L, `829` = 829L, `858` = 858L, `904` = 904L,
`929` = 929L, `950` = 950L, `961` = 961L, `996` = 996L, `1016` = 1016L,
`1089` = 1089L, `1114` = 1114L, `1159` = 1159L, `1184` = 1184L,
`1207` = 1207L, `1216` = 1216L, `1238` = 1238L, `1243` = 1243L,
`1253` = 1253L, `1278` = 1278L, `1315` = 1315L, `1346` = 1346L,
`1372` = 1372L, `1416` = 1416L, `1441` = 1441L, `1473` = 1473L,
`1532` = 1532L, `1599` = 1599L, `1626` = 1626L, `1669` = 1669L,
`1694` = 1694L, `1718` = 1718L, `1726` = 1726L, `1766` = 1766L,
`1786` = 1786L, `1827` = 1827L, `1853` = 1853L, `1881` = 1881L,
`1922` = 1922L, `1952` = 1952L, `1971` = 1971L, `1984` = 1984L,
`2019` = 2019L, `2039` = 2039L, `2075` = 2075L, `2106` = 2106L,
`2135` = 2135L, `2181` = 2181L, `2206` = 2206L, `2227` = 2227L,
`2238` = 2238L, `2273` = 2273L, `2293` = 2293L, `2325` = 2325L,
`2366` = 2366L, `2391` = 2391L, `2436` = 2436L, `2461` = 2461L,
`2483` = 2483L, `2493` = 2493L), class = "omit"), row.names = c(1L,
2L, 3L, 4L, 5L, 7L), class = "data.frame")
I have built 9 regression models per forecast horizon (t+1, t+5 and t+22) and I am using the predict function to make my forecasts. I have coded this in an R loop, where I also try to assign each forecast to a matrix. My code is the following:
EUR/GBP_RBV_22`)
EURGBP_HAR_RVBt5_NT_train <- lm(data.estimateI am trying to calculate realized volatility forecasts using a rolling window forecast. My aim is to use the first 500 observations to forecast the 501st observations, then shift the window forward one step using observations 2 to 501 to predict the 502nd observation. I want this to repeat until I have a complete pseudo out-of-sample forecast.
My df contains 2411 observations of 23 variables, here is small example:
Date
EUR/GBP_RV t+1
EUR/GBP_RV
EUR/GBP_RV_5
EUR/GBP_RV_22
2012-02-13
0.004019947
0.004467109
0.004995980
0.005150602
2012-02-14
0.004077322
0.004019947
0.004704742
0.005099209
2012-02-15
0.004666244
0.004077322
0.004564522
0.005020790
2012-02-16
0.004582351
0.004666244
0.004532930
0.005011078
2012-02-17
0.003951071
0.004582351
0.004362595
0.004999634
2012-02-21
0.005549329
0.004824547
0.004467109
0.004954358
The head of the df can be reproduced with
structure(list(Date = structure(c(15383, 15384, 15385, 15386,
15387, 15391), class = "Date"), `EUR/GBP_RV t+1,t+22` = c(0.00437808494654599,
0.00439764887779732, 0.00441997330738947, 0.00437799055732722,
0.00435021150904479, 0.00434881306458859), `EUR/GBP_RGV t+1,t+22` = c(0.00310674728131117,
0.00311502965608506, 0.00313756204195853, 0.00312923997431178,
0.00310846773074243, 0.00309755540903969), `EUR/GBP_RBV t+1,t+22` = c(0.00304961980133602,
0.00306866297401415, 0.00307794319983677, 0.00302801249035602,
0.00300946121851254, 0.00302272755554915), `EUR/GBP_RV t+1,t+5` = c(0.00425938711995146,
0.00442030721926592, 0.00471470868108043, 0.00487869292442023,
0.00476849421943949, 0.0046067439660438), `EUR/GBP_RGV t+1,t+5` = c(0.00287718093809447,
0.00311308998902836, 0.00344398536439729, 0.00376911066284235,
0.00377425759242542, 0.00353909902900148), `EUR/GBP_RBV t+1,t+5` = c(0.00313771439501486,
0.00310626895475871, 0.0031789431316576, 0.00305962424370556,
0.00288671182187571, 0.00291630955829613), `EUR/GBP_RV t+1` = c(0.00401994700051122,
0.00407732180013827, 0.00466624428620966, 0.00458235106134663,
0.00395107145155152, 0.00554932910921084), `EUR/GBP_RGV t+1` = c(0.00280067842079775,
0.00275522601341373, 0.00296142025653418, 0.00320716195737542,
0.00266141804235125, 0.00440970289025837), `EUR/GBP_RBV t+1` = c(0.00288377777753365,
0.00300554199386584, 0.00360608177982326, 0.00327292734850446,
0.0029202430753471, 0.00336891287836027), `EUR/GBP_RV` = c(0.00446710941914797,
0.00401994700051122, 0.00407732180013827, 0.00466624428620966,
0.00458235106134663, 0.00482454749708351), `EUR/GBP_RV_5` = c(0.00499598016427624,
0.00470474196716823, 0.00456452150727461, 0.00453292965488229,
0.00436259471347075, 0.00442030721926592), `EUR/GBP_RV_22` = c(0.00515060219897263,
0.00509920878086075, 0.00502079002092667, 0.00501107755050095,
0.00499963428727425, 0.00495435807685843), `EUR/GBP_RBV` = c(0.00324667045338159,
0.00288377777753365, 0.00300554199386584, 0.00360608177982326,
0.00327292734850446, 0.00272655057625291), `EUR/GBP_RBV_5` = c(0.0034985439252634,
0.00318731350301598, 0.00319529774619179, 0.0032799330165155,
0.00320299987062176, 0.00310626895475871), `EUR/GBP_RBV_22` = c(0.0036581887941976,
0.00362298829344015, 0.00355498498935768, 0.0035465419934449,
0.00355752455210586, 0.00351669973034298), `EUR/GBP_RGV` = c(0.00306825643155514,
0.00280067842079775, 0.00275522601341373, 0.00296142025653418,
0.00320716195737542, 0.00398022367546721), `EUR/GBP_RGV_5` = c(0.00353290218424469,
0.00345194162523714, 0.00325362896209417, 0.00312087362386985,
0.00295854861593525, 0.00311308998902836), `EUR/GBP_RGV_22` = c(0.00359974659692405,
0.00356342531619103, 0.00352224165959556, 0.00351722666683608,
0.00349184335907274, 0.00346394410318992), `EUR/GBP_TotalCount` = structure(c(-0.179518680545716,
-0.0757259172924681, 0.333514120677483, 0.759064450015801, -0.419724789788948,
-0.360414639358521), .Dim = c(6L, 1L)), `EUR/GBP_BloombergCount` = structure(c(-0.701694550941621,
-0.669811381311996, -0.574161872423118, -0.644304845608295, -0.784590791978649,
-0.631551577756444), .Dim = c(6L, 1L)), `EUR/GBP_SocialMediaCount` = structure(c(-1.68861759789696,
-1.66829994393287, -1.5910928588693, -1.59515638966212, -1.6967446594826,
-1.63172816679749), .Dim = c(6L, 1L)), `EUR/GBP_NewsCount` = structure(c(0.76560533722738,
0.879161625683434, 1.33717198912285, 1.90306082659552, 0.487392430510049,
0.487392430510049), .Dim = c(6L, 1L))), na.action = structure(c(`6` = 6L,
`38` = 38L, `74` = 74L, `101` = 101L, `140` = 140L, `165` = 165L,
`189` = 189L, `197` = 197L, `236` = 236L, `256` = 256L, `323` = 323L,
`351` = 351L, `393` = 393L, `423` = 423L, `442` = 442L, `455` = 455L,
`490` = 490L, `510` = 510L, `551` = 551L, `576` = 576L, `605` = 605L,
`646` = 646L, `676` = 676L, `696` = 696L, `708` = 708L, `742` = 742L,
`762` = 762L, `793` = 793L, `829` = 829L, `858` = 858L, `904` = 904L,
`929` = 929L, `950` = 950L, `961` = 961L, `996` = 996L, `1016` = 1016L,
`1089` = 1089L, `1114` = 1114L, `1159` = 1159L, `1184` = 1184L,
`1207` = 1207L, `1216` = 1216L, `1238` = 1238L, `1243` = 1243L,
`1253` = 1253L, `1278` = 1278L, `1315` = 1315L, `1346` = 1346L,
`1372` = 1372L, `1416` = 1416L, `1441` = 1441L, `1473` = 1473L,
`1532` = 1532L, `1599` = 1599L, `1626` = 1626L, `1669` = 1669L,
`1694` = 1694L, `1718` = 1718L, `1726` = 1726L, `1766` = 1766L,
`1786` = 1786L, `1827` = 1827L, `1853` = 1853L, `1881` = 1881L,
`1922` = 1922L, `1952` = 1952L, `1971` = 1971L, `1984` = 1984L,
`2019` = 2019L, `2039` = 2039L, `2075` = 2075L, `2106` = 2106L,
`2135` = 2135L, `2181` = 2181L, `2206` = 2206L, `2227` = 2227L,
`2238` = 2238L, `2273` = 2273L, `2293` = 2293L, `2325` = 2325L,
`2366` = 2366L, `2391` = 2391L, `2436` = 2436L, `2461` = 2461L,
`2483` = 2483L, `2493` = 2493L), class = "omit"), row.names = c(1L,
2L, 3L, 4L, 5L, 7L), class = "data.frame")
I have built 9 regression models per forecast horizon (t+1, t+5 and t+22) and I am using the predict function to make my forecasts. I have coded this in an R loop, where I also try to assign each forecast to a matrix. My code is the following:
EUR/GBP_RBV t+1,t+5`~data.estimateI am trying to calculate realized volatility forecasts using a rolling window forecast. My aim is to use the first 500 observations to forecast the 501st observations, then shift the window forward one step using observations 2 to 501 to predict the 502nd observation. I want this to repeat until I have a complete pseudo out-of-sample forecast.
My df contains 2411 observations of 23 variables, here is small example:
Date
EUR/GBP_RV t+1
EUR/GBP_RV
EUR/GBP_RV_5
EUR/GBP_RV_22
2012-02-13
0.004019947
0.004467109
0.004995980
0.005150602
2012-02-14
0.004077322
0.004019947
0.004704742
0.005099209
2012-02-15
0.004666244
0.004077322
0.004564522
0.005020790
2012-02-16
0.004582351
0.004666244
0.004532930
0.005011078
2012-02-17
0.003951071
0.004582351
0.004362595
0.004999634
2012-02-21
0.005549329
0.004824547
0.004467109
0.004954358
The head of the df can be reproduced with
structure(list(Date = structure(c(15383, 15384, 15385, 15386,
15387, 15391), class = "Date"), `EUR/GBP_RV t+1,t+22` = c(0.00437808494654599,
0.00439764887779732, 0.00441997330738947, 0.00437799055732722,
0.00435021150904479, 0.00434881306458859), `EUR/GBP_RGV t+1,t+22` = c(0.00310674728131117,
0.00311502965608506, 0.00313756204195853, 0.00312923997431178,
0.00310846773074243, 0.00309755540903969), `EUR/GBP_RBV t+1,t+22` = c(0.00304961980133602,
0.00306866297401415, 0.00307794319983677, 0.00302801249035602,
0.00300946121851254, 0.00302272755554915), `EUR/GBP_RV t+1,t+5` = c(0.00425938711995146,
0.00442030721926592, 0.00471470868108043, 0.00487869292442023,
0.00476849421943949, 0.0046067439660438), `EUR/GBP_RGV t+1,t+5` = c(0.00287718093809447,
0.00311308998902836, 0.00344398536439729, 0.00376911066284235,
0.00377425759242542, 0.00353909902900148), `EUR/GBP_RBV t+1,t+5` = c(0.00313771439501486,
0.00310626895475871, 0.0031789431316576, 0.00305962424370556,
0.00288671182187571, 0.00291630955829613), `EUR/GBP_RV t+1` = c(0.00401994700051122,
0.00407732180013827, 0.00466624428620966, 0.00458235106134663,
0.00395107145155152, 0.00554932910921084), `EUR/GBP_RGV t+1` = c(0.00280067842079775,
0.00275522601341373, 0.00296142025653418, 0.00320716195737542,
0.00266141804235125, 0.00440970289025837), `EUR/GBP_RBV t+1` = c(0.00288377777753365,
0.00300554199386584, 0.00360608177982326, 0.00327292734850446,
0.0029202430753471, 0.00336891287836027), `EUR/GBP_RV` = c(0.00446710941914797,
0.00401994700051122, 0.00407732180013827, 0.00466624428620966,
0.00458235106134663, 0.00482454749708351), `EUR/GBP_RV_5` = c(0.00499598016427624,
0.00470474196716823, 0.00456452150727461, 0.00453292965488229,
0.00436259471347075, 0.00442030721926592), `EUR/GBP_RV_22` = c(0.00515060219897263,
0.00509920878086075, 0.00502079002092667, 0.00501107755050095,
0.00499963428727425, 0.00495435807685843), `EUR/GBP_RBV` = c(0.00324667045338159,
0.00288377777753365, 0.00300554199386584, 0.00360608177982326,
0.00327292734850446, 0.00272655057625291), `EUR/GBP_RBV_5` = c(0.0034985439252634,
0.00318731350301598, 0.00319529774619179, 0.0032799330165155,
0.00320299987062176, 0.00310626895475871), `EUR/GBP_RBV_22` = c(0.0036581887941976,
0.00362298829344015, 0.00355498498935768, 0.0035465419934449,
0.00355752455210586, 0.00351669973034298), `EUR/GBP_RGV` = c(0.00306825643155514,
0.00280067842079775, 0.00275522601341373, 0.00296142025653418,
0.00320716195737542, 0.00398022367546721), `EUR/GBP_RGV_5` = c(0.00353290218424469,
0.00345194162523714, 0.00325362896209417, 0.00312087362386985,
0.00295854861593525, 0.00311308998902836), `EUR/GBP_RGV_22` = c(0.00359974659692405,
0.00356342531619103, 0.00352224165959556, 0.00351722666683608,
0.00349184335907274, 0.00346394410318992), `EUR/GBP_TotalCount` = structure(c(-0.179518680545716,
-0.0757259172924681, 0.333514120677483, 0.759064450015801, -0.419724789788948,
-0.360414639358521), .Dim = c(6L, 1L)), `EUR/GBP_BloombergCount` = structure(c(-0.701694550941621,
-0.669811381311996, -0.574161872423118, -0.644304845608295, -0.784590791978649,
-0.631551577756444), .Dim = c(6L, 1L)), `EUR/GBP_SocialMediaCount` = structure(c(-1.68861759789696,
-1.66829994393287, -1.5910928588693, -1.59515638966212, -1.6967446594826,
-1.63172816679749), .Dim = c(6L, 1L)), `EUR/GBP_NewsCount` = structure(c(0.76560533722738,
0.879161625683434, 1.33717198912285, 1.90306082659552, 0.487392430510049,
0.487392430510049), .Dim = c(6L, 1L))), na.action = structure(c(`6` = 6L,
`38` = 38L, `74` = 74L, `101` = 101L, `140` = 140L, `165` = 165L,
`189` = 189L, `197` = 197L, `236` = 236L, `256` = 256L, `323` = 323L,
`351` = 351L, `393` = 393L, `423` = 423L, `442` = 442L, `455` = 455L,
`490` = 490L, `510` = 510L, `551` = 551L, `576` = 576L, `605` = 605L,
`646` = 646L, `676` = 676L, `696` = 696L, `708` = 708L, `742` = 742L,
`762` = 762L, `793` = 793L, `829` = 829L, `858` = 858L, `904` = 904L,
`929` = 929L, `950` = 950L, `961` = 961L, `996` = 996L, `1016` = 1016L,
`1089` = 1089L, `1114` = 1114L, `1159` = 1159L, `1184` = 1184L,
`1207` = 1207L, `1216` = 1216L, `1238` = 1238L, `1243` = 1243L,
`1253` = 1253L, `1278` = 1278L, `1315` = 1315L, `1346` = 1346L,
`1372` = 1372L, `1416` = 1416L, `1441` = 1441L, `1473` = 1473L,
`1532` = 1532L, `1599` = 1599L, `1626` = 1626L, `1669` = 1669L,
`1694` = 1694L, `1718` = 1718L, `1726` = 1726L, `1766` = 1766L,
`1786` = 1786L, `1827` = 1827L, `1853` = 1853L, `1881` = 1881L,
`1922` = 1922L, `1952` = 1952L, `1971` = 1971L, `1984` = 1984L,
`2019` = 2019L, `2039` = 2039L, `2075` = 2075L, `2106` = 2106L,
`2135` = 2135L, `2181` = 2181L, `2206` = 2206L, `2227` = 2227L,
`2238` = 2238L, `2273` = 2273L, `2293` = 2293L, `2325` = 2325L,
`2366` = 2366L, `2391` = 2391L, `2436` = 2436L, `2461` = 2461L,
`2483` = 2483L, `2493` = 2493L), class = "omit"), row.names = c(1L,
2L, 3L, 4L, 5L, 7L), class = "data.frame")
I have built 9 regression models per forecast horizon (t+1, t+5 and t+22) and I am using the predict function to make my forecasts. I have coded this in an R loop, where I also try to assign each forecast to a matrix. My code is the following:
EUR/GBP_RBV`+data.estimateI am trying to calculate realized volatility forecasts using a rolling window forecast. My aim is to use the first 500 observations to forecast the 501st observations, then shift the window forward one step using observations 2 to 501 to predict the 502nd observation. I want this to repeat until I have a complete pseudo out-of-sample forecast.
My df contains 2411 observations of 23 variables, here is small example:
Date
EUR/GBP_RV t+1
EUR/GBP_RV
EUR/GBP_RV_5
EUR/GBP_RV_22
2012-02-13
0.004019947
0.004467109
0.004995980
0.005150602
2012-02-14
0.004077322
0.004019947
0.004704742
0.005099209
2012-02-15
0.004666244
0.004077322
0.004564522
0.005020790
2012-02-16
0.004582351
0.004666244
0.004532930
0.005011078
2012-02-17
0.003951071
0.004582351
0.004362595
0.004999634
2012-02-21
0.005549329
0.004824547
0.004467109
0.004954358
The head of the df can be reproduced with
structure(list(Date = structure(c(15383, 15384, 15385, 15386,
15387, 15391), class = "Date"), `EUR/GBP_RV t+1,t+22` = c(0.00437808494654599,
0.00439764887779732, 0.00441997330738947, 0.00437799055732722,
0.00435021150904479, 0.00434881306458859), `EUR/GBP_RGV t+1,t+22` = c(0.00310674728131117,
0.00311502965608506, 0.00313756204195853, 0.00312923997431178,
0.00310846773074243, 0.00309755540903969), `EUR/GBP_RBV t+1,t+22` = c(0.00304961980133602,
0.00306866297401415, 0.00307794319983677, 0.00302801249035602,
0.00300946121851254, 0.00302272755554915), `EUR/GBP_RV t+1,t+5` = c(0.00425938711995146,
0.00442030721926592, 0.00471470868108043, 0.00487869292442023,
0.00476849421943949, 0.0046067439660438), `EUR/GBP_RGV t+1,t+5` = c(0.00287718093809447,
0.00311308998902836, 0.00344398536439729, 0.00376911066284235,
0.00377425759242542, 0.00353909902900148), `EUR/GBP_RBV t+1,t+5` = c(0.00313771439501486,
0.00310626895475871, 0.0031789431316576, 0.00305962424370556,
0.00288671182187571, 0.00291630955829613), `EUR/GBP_RV t+1` = c(0.00401994700051122,
0.00407732180013827, 0.00466624428620966, 0.00458235106134663,
0.00395107145155152, 0.00554932910921084), `EUR/GBP_RGV t+1` = c(0.00280067842079775,
0.00275522601341373, 0.00296142025653418, 0.00320716195737542,
0.00266141804235125, 0.00440970289025837), `EUR/GBP_RBV t+1` = c(0.00288377777753365,
0.00300554199386584, 0.00360608177982326, 0.00327292734850446,
0.0029202430753471, 0.00336891287836027), `EUR/GBP_RV` = c(0.00446710941914797,
0.00401994700051122, 0.00407732180013827, 0.00466624428620966,
0.00458235106134663, 0.00482454749708351), `EUR/GBP_RV_5` = c(0.00499598016427624,
0.00470474196716823, 0.00456452150727461, 0.00453292965488229,
0.00436259471347075, 0.00442030721926592), `EUR/GBP_RV_22` = c(0.00515060219897263,
0.00509920878086075, 0.00502079002092667, 0.00501107755050095,
0.00499963428727425, 0.00495435807685843), `EUR/GBP_RBV` = c(0.00324667045338159,
0.00288377777753365, 0.00300554199386584, 0.00360608177982326,
0.00327292734850446, 0.00272655057625291), `EUR/GBP_RBV_5` = c(0.0034985439252634,
0.00318731350301598, 0.00319529774619179, 0.0032799330165155,
0.00320299987062176, 0.00310626895475871), `EUR/GBP_RBV_22` = c(0.0036581887941976,
0.00362298829344015, 0.00355498498935768, 0.0035465419934449,
0.00355752455210586, 0.00351669973034298), `EUR/GBP_RGV` = c(0.00306825643155514,
0.00280067842079775, 0.00275522601341373, 0.00296142025653418,
0.00320716195737542, 0.00398022367546721), `EUR/GBP_RGV_5` = c(0.00353290218424469,
0.00345194162523714, 0.00325362896209417, 0.00312087362386985,
0.00295854861593525, 0.00311308998902836), `EUR/GBP_RGV_22` = c(0.00359974659692405,
0.00356342531619103, 0.00352224165959556, 0.00351722666683608,
0.00349184335907274, 0.00346394410318992), `EUR/GBP_TotalCount` = structure(c(-0.179518680545716,
-0.0757259172924681, 0.333514120677483, 0.759064450015801, -0.419724789788948,
-0.360414639358521), .Dim = c(6L, 1L)), `EUR/GBP_BloombergCount` = structure(c(-0.701694550941621,
-0.669811381311996, -0.574161872423118, -0.644304845608295, -0.784590791978649,
-0.631551577756444), .Dim = c(6L, 1L)), `EUR/GBP_SocialMediaCount` = structure(c(-1.68861759789696,
-1.66829994393287, -1.5910928588693, -1.59515638966212, -1.6967446594826,
-1.63172816679749), .Dim = c(6L, 1L)), `EUR/GBP_NewsCount` = structure(c(0.76560533722738,
0.879161625683434, 1.33717198912285, 1.90306082659552, 0.487392430510049,
0.487392430510049), .Dim = c(6L, 1L))), na.action = structure(c(`6` = 6L,
`38` = 38L, `74` = 74L, `101` = 101L, `140` = 140L, `165` = 165L,
`189` = 189L, `197` = 197L, `236` = 236L, `256` = 256L, `323` = 323L,
`351` = 351L, `393` = 393L, `423` = 423L, `442` = 442L, `455` = 455L,
`490` = 490L, `510` = 510L, `551` = 551L, `576` = 576L, `605` = 605L,
`646` = 646L, `676` = 676L, `696` = 696L, `708` = 708L, `742` = 742L,
`762` = 762L, `793` = 793L, `829` = 829L, `858` = 858L, `904` = 904L,
`929` = 929L, `950` = 950L, `961` = 961L, `996` = 996L, `1016` = 1016L,
`1089` = 1089L, `1114` = 1114L, `1159` = 1159L, `1184` = 1184L,
`1207` = 1207L, `1216` = 1216L, `1238` = 1238L, `1243` = 1243L,
`1253` = 1253L, `1278` = 1278L, `1315` = 1315L, `1346` = 1346L,
`1372` = 1372L, `1416` = 1416L, `1441` = 1441L, `1473` = 1473L,
`1532` = 1532L, `1599` = 1599L, `1626` = 1626L, `1669` = 1669L,
`1694` = 1694L, `1718` = 1718L, `1726` = 1726L, `1766` = 1766L,
`1786` = 1786L, `1827` = 1827L, `1853` = 1853L, `1881` = 1881L,
`1922` = 1922L, `1952` = 1952L, `1971` = 1971L, `1984` = 1984L,
`2019` = 2019L, `2039` = 2039L, `2075` = 2075L, `2106` = 2106L,
`2135` = 2135L, `2181` = 2181L, `2206` = 2206L, `2227` = 2227L,
`2238` = 2238L, `2273` = 2273L, `2293` = 2293L, `2325` = 2325L,
`2366` = 2366L, `2391` = 2391L, `2436` = 2436L, `2461` = 2461L,
`2483` = 2483L, `2493` = 2493L), class = "omit"), row.names = c(1L,
2L, 3L, 4L, 5L, 7L), class = "data.frame")
I have built 9 regression models per forecast horizon (t+1, t+5 and t+22) and I am using the predict function to make my forecasts. I have coded this in an R loop, where I also try to assign each forecast to a matrix. My code is the following:
EUR/GBP_RBV_5`+data.estimateI am trying to calculate realized volatility forecasts using a rolling window forecast. My aim is to use the first 500 observations to forecast the 501st observations, then shift the window forward one step using observations 2 to 501 to predict the 502nd observation. I want this to repeat until I have a complete pseudo out-of-sample forecast.
My df contains 2411 observations of 23 variables, here is small example:
Date
EUR/GBP_RV t+1
EUR/GBP_RV
EUR/GBP_RV_5
EUR/GBP_RV_22
2012-02-13
0.004019947
0.004467109
0.004995980
0.005150602
2012-02-14
0.004077322
0.004019947
0.004704742
0.005099209
2012-02-15
0.004666244
0.004077322
0.004564522
0.005020790
2012-02-16
0.004582351
0.004666244
0.004532930
0.005011078
2012-02-17
0.003951071
0.004582351
0.004362595
0.004999634
2012-02-21
0.005549329
0.004824547
0.004467109
0.004954358
The head of the df can be reproduced with
structure(list(Date = structure(c(15383, 15384, 15385, 15386,
15387, 15391), class = "Date"), `EUR/GBP_RV t+1,t+22` = c(0.00437808494654599,
0.00439764887779732, 0.00441997330738947, 0.00437799055732722,
0.00435021150904479, 0.00434881306458859), `EUR/GBP_RGV t+1,t+22` = c(0.00310674728131117,
0.00311502965608506, 0.00313756204195853, 0.00312923997431178,
0.00310846773074243, 0.00309755540903969), `EUR/GBP_RBV t+1,t+22` = c(0.00304961980133602,
0.00306866297401415, 0.00307794319983677, 0.00302801249035602,
0.00300946121851254, 0.00302272755554915), `EUR/GBP_RV t+1,t+5` = c(0.00425938711995146,
0.00442030721926592, 0.00471470868108043, 0.00487869292442023,
0.00476849421943949, 0.0046067439660438), `EUR/GBP_RGV t+1,t+5` = c(0.00287718093809447,
0.00311308998902836, 0.00344398536439729, 0.00376911066284235,
0.00377425759242542, 0.00353909902900148), `EUR/GBP_RBV t+1,t+5` = c(0.00313771439501486,
0.00310626895475871, 0.0031789431316576, 0.00305962424370556,
0.00288671182187571, 0.00291630955829613), `EUR/GBP_RV t+1` = c(0.00401994700051122,
0.00407732180013827, 0.00466624428620966, 0.00458235106134663,
0.00395107145155152, 0.00554932910921084), `EUR/GBP_RGV t+1` = c(0.00280067842079775,
0.00275522601341373, 0.00296142025653418, 0.00320716195737542,
0.00266141804235125, 0.00440970289025837), `EUR/GBP_RBV t+1` = c(0.00288377777753365,
0.00300554199386584, 0.00360608177982326, 0.00327292734850446,
0.0029202430753471, 0.00336891287836027), `EUR/GBP_RV` = c(0.00446710941914797,
0.00401994700051122, 0.00407732180013827, 0.00466624428620966,
0.00458235106134663, 0.00482454749708351), `EUR/GBP_RV_5` = c(0.00499598016427624,
0.00470474196716823, 0.00456452150727461, 0.00453292965488229,
0.00436259471347075, 0.00442030721926592), `EUR/GBP_RV_22` = c(0.00515060219897263,
0.00509920878086075, 0.00502079002092667, 0.00501107755050095,
0.00499963428727425, 0.00495435807685843), `EUR/GBP_RBV` = c(0.00324667045338159,
0.00288377777753365, 0.00300554199386584, 0.00360608177982326,
0.00327292734850446, 0.00272655057625291), `EUR/GBP_RBV_5` = c(0.0034985439252634,
0.00318731350301598, 0.00319529774619179, 0.0032799330165155,
0.00320299987062176, 0.00310626895475871), `EUR/GBP_RBV_22` = c(0.0036581887941976,
0.00362298829344015, 0.00355498498935768, 0.0035465419934449,
0.00355752455210586, 0.00351669973034298), `EUR/GBP_RGV` = c(0.00306825643155514,
0.00280067842079775, 0.00275522601341373, 0.00296142025653418,
0.00320716195737542, 0.00398022367546721), `EUR/GBP_RGV_5` = c(0.00353290218424469,
0.00345194162523714, 0.00325362896209417, 0.00312087362386985,
0.00295854861593525, 0.00311308998902836), `EUR/GBP_RGV_22` = c(0.00359974659692405,
0.00356342531619103, 0.00352224165959556, 0.00351722666683608,
0.00349184335907274, 0.00346394410318992), `EUR/GBP_TotalCount` = structure(c(-0.179518680545716,
-0.0757259172924681, 0.333514120677483, 0.759064450015801, -0.419724789788948,
-0.360414639358521), .Dim = c(6L, 1L)), `EUR/GBP_BloombergCount` = structure(c(-0.701694550941621,
-0.669811381311996, -0.574161872423118, -0.644304845608295, -0.784590791978649,
-0.631551577756444), .Dim = c(6L, 1L)), `EUR/GBP_SocialMediaCount` = structure(c(-1.68861759789696,
-1.66829994393287, -1.5910928588693, -1.59515638966212, -1.6967446594826,
-1.63172816679749), .Dim = c(6L, 1L)), `EUR/GBP_NewsCount` = structure(c(0.76560533722738,
0.879161625683434, 1.33717198912285, 1.90306082659552, 0.487392430510049,
0.487392430510049), .Dim = c(6L, 1L))), na.action = structure(c(`6` = 6L,
`38` = 38L, `74` = 74L, `101` = 101L, `140` = 140L, `165` = 165L,
`189` = 189L, `197` = 197L, `236` = 236L, `256` = 256L, `323` = 323L,
`351` = 351L, `393` = 393L, `423` = 423L, `442` = 442L, `455` = 455L,
`490` = 490L, `510` = 510L, `551` = 551L, `576` = 576L, `605` = 605L,
`646` = 646L, `676` = 676L, `696` = 696L, `708` = 708L, `742` = 742L,
`762` = 762L, `793` = 793L, `829` = 829L, `858` = 858L, `904` = 904L,
`929` = 929L, `950` = 950L, `961` = 961L, `996` = 996L, `1016` = 1016L,
`1089` = 1089L, `1114` = 1114L, `1159` = 1159L, `1184` = 1184L,
`1207` = 1207L, `1216` = 1216L, `1238` = 1238L, `1243` = 1243L,
`1253` = 1253L, `1278` = 1278L, `1315` = 1315L, `1346` = 1346L,
`1372` = 1372L, `1416` = 1416L, `1441` = 1441L, `1473` = 1473L,
`1532` = 1532L, `1599` = 1599L, `1626` = 1626L, `1669` = 1669L,
`1694` = 1694L, `1718` = 1718L, `1726` = 1726L, `1766` = 1766L,
`1786` = 1786L, `1827` = 1827L, `1853` = 1853L, `1881` = 1881L,
`1922` = 1922L, `1952` = 1952L, `1971` = 1971L, `1984` = 1984L,
`2019` = 2019L, `2039` = 2039L, `2075` = 2075L, `2106` = 2106L,
`2135` = 2135L, `2181` = 2181L, `2206` = 2206L, `2227` = 2227L,
`2238` = 2238L, `2273` = 2273L, `2293` = 2293L, `2325` = 2325L,
`2366` = 2366L, `2391` = 2391L, `2436` = 2436L, `2461` = 2461L,
`2483` = 2483L, `2493` = 2493L), class = "omit"), row.names = c(1L,
2L, 3L, 4L, 5L, 7L), class = "data.frame")
I have built 9 regression models per forecast horizon (t+1, t+5 and t+22) and I am using the predict function to make my forecasts. I have coded this in an R loop, where I also try to assign each forecast to a matrix. My code is the following:
EUR/GBP_RBV_22`+data.estimateI am trying to calculate realized volatility forecasts using a rolling window forecast. My aim is to use the first 500 observations to forecast the 501st observations, then shift the window forward one step using observations 2 to 501 to predict the 502nd observation. I want this to repeat until I have a complete pseudo out-of-sample forecast.
My df contains 2411 observations of 23 variables, here is small example:
Date
EUR/GBP_RV t+1
EUR/GBP_RV
EUR/GBP_RV_5
EUR/GBP_RV_22
2012-02-13
0.004019947
0.004467109
0.004995980
0.005150602
2012-02-14
0.004077322
0.004019947
0.004704742
0.005099209
2012-02-15
0.004666244
0.004077322
0.004564522
0.005020790
2012-02-16
0.004582351
0.004666244
0.004532930
0.005011078
2012-02-17
0.003951071
0.004582351
0.004362595
0.004999634
2012-02-21
0.005549329
0.004824547
0.004467109
0.004954358
The head of the df can be reproduced with
structure(list(Date = structure(c(15383, 15384, 15385, 15386,
15387, 15391), class = "Date"), `EUR/GBP_RV t+1,t+22` = c(0.00437808494654599,
0.00439764887779732, 0.00441997330738947, 0.00437799055732722,
0.00435021150904479, 0.00434881306458859), `EUR/GBP_RGV t+1,t+22` = c(0.00310674728131117,
0.00311502965608506, 0.00313756204195853, 0.00312923997431178,
0.00310846773074243, 0.00309755540903969), `EUR/GBP_RBV t+1,t+22` = c(0.00304961980133602,
0.00306866297401415, 0.00307794319983677, 0.00302801249035602,
0.00300946121851254, 0.00302272755554915), `EUR/GBP_RV t+1,t+5` = c(0.00425938711995146,
0.00442030721926592, 0.00471470868108043, 0.00487869292442023,
0.00476849421943949, 0.0046067439660438), `EUR/GBP_RGV t+1,t+5` = c(0.00287718093809447,
0.00311308998902836, 0.00344398536439729, 0.00376911066284235,
0.00377425759242542, 0.00353909902900148), `EUR/GBP_RBV t+1,t+5` = c(0.00313771439501486,
0.00310626895475871, 0.0031789431316576, 0.00305962424370556,
0.00288671182187571, 0.00291630955829613), `EUR/GBP_RV t+1` = c(0.00401994700051122,
0.00407732180013827, 0.00466624428620966, 0.00458235106134663,
0.00395107145155152, 0.00554932910921084), `EUR/GBP_RGV t+1` = c(0.00280067842079775,
0.00275522601341373, 0.00296142025653418, 0.00320716195737542,
0.00266141804235125, 0.00440970289025837), `EUR/GBP_RBV t+1` = c(0.00288377777753365,
0.00300554199386584, 0.00360608177982326, 0.00327292734850446,
0.0029202430753471, 0.00336891287836027), `EUR/GBP_RV` = c(0.00446710941914797,
0.00401994700051122, 0.00407732180013827, 0.00466624428620966,
0.00458235106134663, 0.00482454749708351), `EUR/GBP_RV_5` = c(0.00499598016427624,
0.00470474196716823, 0.00456452150727461, 0.00453292965488229,
0.00436259471347075, 0.00442030721926592), `EUR/GBP_RV_22` = c(0.00515060219897263,
0.00509920878086075, 0.00502079002092667, 0.00501107755050095,
0.00499963428727425, 0.00495435807685843), `EUR/GBP_RBV` = c(0.00324667045338159,
0.00288377777753365, 0.00300554199386584, 0.00360608177982326,
0.00327292734850446, 0.00272655057625291), `EUR/GBP_RBV_5` = c(0.0034985439252634,
0.00318731350301598, 0.00319529774619179, 0.0032799330165155,
0.00320299987062176, 0.00310626895475871), `EUR/GBP_RBV_22` = c(0.0036581887941976,
0.00362298829344015, 0.00355498498935768, 0.0035465419934449,
0.00355752455210586, 0.00351669973034298), `EUR/GBP_RGV` = c(0.00306825643155514,
0.00280067842079775, 0.00275522601341373, 0.00296142025653418,
0.00320716195737542, 0.00398022367546721), `EUR/GBP_RGV_5` = c(0.00353290218424469,
0.00345194162523714, 0.00325362896209417, 0.00312087362386985,
0.00295854861593525, 0.00311308998902836), `EUR/GBP_RGV_22` = c(0.00359974659692405,
0.00356342531619103, 0.00352224165959556, 0.00351722666683608,
0.00349184335907274, 0.00346394410318992), `EUR/GBP_TotalCount` = structure(c(-0.179518680545716,
-0.0757259172924681, 0.333514120677483, 0.759064450015801, -0.419724789788948,
-0.360414639358521), .Dim = c(6L, 1L)), `EUR/GBP_BloombergCount` = structure(c(-0.701694550941621,
-0.669811381311996, -0.574161872423118, -0.644304845608295, -0.784590791978649,
-0.631551577756444), .Dim = c(6L, 1L)), `EUR/GBP_SocialMediaCount` = structure(c(-1.68861759789696,
-1.66829994393287, -1.5910928588693, -1.59515638966212, -1.6967446594826,
-1.63172816679749), .Dim = c(6L, 1L)), `EUR/GBP_NewsCount` = structure(c(0.76560533722738,
0.879161625683434, 1.33717198912285, 1.90306082659552, 0.487392430510049,
0.487392430510049), .Dim = c(6L, 1L))), na.action = structure(c(`6` = 6L,
`38` = 38L, `74` = 74L, `101` = 101L, `140` = 140L, `165` = 165L,
`189` = 189L, `197` = 197L, `236` = 236L, `256` = 256L, `323` = 323L,
`351` = 351L, `393` = 393L, `423` = 423L, `442` = 442L, `455` = 455L,
`490` = 490L, `510` = 510L, `551` = 551L, `576` = 576L, `605` = 605L,
`646` = 646L, `676` = 676L, `696` = 696L, `708` = 708L, `742` = 742L,
`762` = 762L, `793` = 793L, `829` = 829L, `858` = 858L, `904` = 904L,
`929` = 929L, `950` = 950L, `961` = 961L, `996` = 996L, `1016` = 1016L,
`1089` = 1089L, `1114` = 1114L, `1159` = 1159L, `1184` = 1184L,
`1207` = 1207L, `1216` = 1216L, `1238` = 1238L, `1243` = 1243L,
`1253` = 1253L, `1278` = 1278L, `1315` = 1315L, `1346` = 1346L,
`1372` = 1372L, `1416` = 1416L, `1441` = 1441L, `1473` = 1473L,
`1532` = 1532L, `1599` = 1599L, `1626` = 1626L, `1669` = 1669L,
`1694` = 1694L, `1718` = 1718L, `1726` = 1726L, `1766` = 1766L,
`1786` = 1786L, `1827` = 1827L, `1853` = 1853L, `1881` = 1881L,
`1922` = 1922L, `1952` = 1952L, `1971` = 1971L, `1984` = 1984L,
`2019` = 2019L, `2039` = 2039L, `2075` = 2075L, `2106` = 2106L,
`2135` = 2135L, `2181` = 2181L, `2206` = 2206L, `2227` = 2227L,
`2238` = 2238L, `2273` = 2273L, `2293` = 2293L, `2325` = 2325L,
`2366` = 2366L, `2391` = 2391L, `2436` = 2436L, `2461` = 2461L,
`2483` = 2483L, `2493` = 2493L), class = "omit"), row.names = c(1L,
2L, 3L, 4L, 5L, 7L), class = "data.frame")
I have built 9 regression models per forecast horizon (t+1, t+5 and t+22) and I am using the predict function to make my forecasts. I have coded this in an R loop, where I also try to assign each forecast to a matrix. My code is the following:
EUR/GBP_TotalCount`)
EURGBP_HAR_RVGt5_train <- lm(data.estimateI am trying to calculate realized volatility forecasts using a rolling window forecast. My aim is to use the first 500 observations to forecast the 501st observations, then shift the window forward one step using observations 2 to 501 to predict the 502nd observation. I want this to repeat until I have a complete pseudo out-of-sample forecast.
My df contains 2411 observations of 23 variables, here is small example:
Date
EUR/GBP_RV t+1
EUR/GBP_RV
EUR/GBP_RV_5
EUR/GBP_RV_22
2012-02-13
0.004019947
0.004467109
0.004995980
0.005150602
2012-02-14
0.004077322
0.004019947
0.004704742
0.005099209
2012-02-15
0.004666244
0.004077322
0.004564522
0.005020790
2012-02-16
0.004582351
0.004666244
0.004532930
0.005011078
2012-02-17
0.003951071
0.004582351
0.004362595
0.004999634
2012-02-21
0.005549329
0.004824547
0.004467109
0.004954358
The head of the df can be reproduced with
structure(list(Date = structure(c(15383, 15384, 15385, 15386,
15387, 15391), class = "Date"), `EUR/GBP_RV t+1,t+22` = c(0.00437808494654599,
0.00439764887779732, 0.00441997330738947, 0.00437799055732722,
0.00435021150904479, 0.00434881306458859), `EUR/GBP_RGV t+1,t+22` = c(0.00310674728131117,
0.00311502965608506, 0.00313756204195853, 0.00312923997431178,
0.00310846773074243, 0.00309755540903969), `EUR/GBP_RBV t+1,t+22` = c(0.00304961980133602,
0.00306866297401415, 0.00307794319983677, 0.00302801249035602,
0.00300946121851254, 0.00302272755554915), `EUR/GBP_RV t+1,t+5` = c(0.00425938711995146,
0.00442030721926592, 0.00471470868108043, 0.00487869292442023,
0.00476849421943949, 0.0046067439660438), `EUR/GBP_RGV t+1,t+5` = c(0.00287718093809447,
0.00311308998902836, 0.00344398536439729, 0.00376911066284235,
0.00377425759242542, 0.00353909902900148), `EUR/GBP_RBV t+1,t+5` = c(0.00313771439501486,
0.00310626895475871, 0.0031789431316576, 0.00305962424370556,
0.00288671182187571, 0.00291630955829613), `EUR/GBP_RV t+1` = c(0.00401994700051122,
0.00407732180013827, 0.00466624428620966, 0.00458235106134663,
0.00395107145155152, 0.00554932910921084), `EUR/GBP_RGV t+1` = c(0.00280067842079775,
0.00275522601341373, 0.00296142025653418, 0.00320716195737542,
0.00266141804235125, 0.00440970289025837), `EUR/GBP_RBV t+1` = c(0.00288377777753365,
0.00300554199386584, 0.00360608177982326, 0.00327292734850446,
0.0029202430753471, 0.00336891287836027), `EUR/GBP_RV` = c(0.00446710941914797,
0.00401994700051122, 0.00407732180013827, 0.00466624428620966,
0.00458235106134663, 0.00482454749708351), `EUR/GBP_RV_5` = c(0.00499598016427624,
0.00470474196716823, 0.00456452150727461, 0.00453292965488229,
0.00436259471347075, 0.00442030721926592), `EUR/GBP_RV_22` = c(0.00515060219897263,
0.00509920878086075, 0.00502079002092667, 0.00501107755050095,
0.00499963428727425, 0.00495435807685843), `EUR/GBP_RBV` = c(0.00324667045338159,
0.00288377777753365, 0.00300554199386584, 0.00360608177982326,
0.00327292734850446, 0.00272655057625291), `EUR/GBP_RBV_5` = c(0.0034985439252634,
0.00318731350301598, 0.00319529774619179, 0.0032799330165155,
0.00320299987062176, 0.00310626895475871), `EUR/GBP_RBV_22` = c(0.0036581887941976,
0.00362298829344015, 0.00355498498935768, 0.0035465419934449,
0.00355752455210586, 0.00351669973034298), `EUR/GBP_RGV` = c(0.00306825643155514,
0.00280067842079775, 0.00275522601341373, 0.00296142025653418,
0.00320716195737542, 0.00398022367546721), `EUR/GBP_RGV_5` = c(0.00353290218424469,
0.00345194162523714, 0.00325362896209417, 0.00312087362386985,
0.00295854861593525, 0.00311308998902836), `EUR/GBP_RGV_22` = c(0.00359974659692405,
0.00356342531619103, 0.00352224165959556, 0.00351722666683608,
0.00349184335907274, 0.00346394410318992), `EUR/GBP_TotalCount` = structure(c(-0.179518680545716,
-0.0757259172924681, 0.333514120677483, 0.759064450015801, -0.419724789788948,
-0.360414639358521), .Dim = c(6L, 1L)), `EUR/GBP_BloombergCount` = structure(c(-0.701694550941621,
-0.669811381311996, -0.574161872423118, -0.644304845608295, -0.784590791978649,
-0.631551577756444), .Dim = c(6L, 1L)), `EUR/GBP_SocialMediaCount` = structure(c(-1.68861759789696,
-1.66829994393287, -1.5910928588693, -1.59515638966212, -1.6967446594826,
-1.63172816679749), .Dim = c(6L, 1L)), `EUR/GBP_NewsCount` = structure(c(0.76560533722738,
0.879161625683434, 1.33717198912285, 1.90306082659552, 0.487392430510049,
0.487392430510049), .Dim = c(6L, 1L))), na.action = structure(c(`6` = 6L,
`38` = 38L, `74` = 74L, `101` = 101L, `140` = 140L, `165` = 165L,
`189` = 189L, `197` = 197L, `236` = 236L, `256` = 256L, `323` = 323L,
`351` = 351L, `393` = 393L, `423` = 423L, `442` = 442L, `455` = 455L,
`490` = 490L, `510` = 510L, `551` = 551L, `576` = 576L, `605` = 605L,
`646` = 646L, `676` = 676L, `696` = 696L, `708` = 708L, `742` = 742L,
`762` = 762L, `793` = 793L, `829` = 829L, `858` = 858L, `904` = 904L,
`929` = 929L, `950` = 950L, `961` = 961L, `996` = 996L, `1016` = 1016L,
`1089` = 1089L, `1114` = 1114L, `1159` = 1159L, `1184` = 1184L,
`1207` = 1207L, `1216` = 1216L, `1238` = 1238L, `1243` = 1243L,
`1253` = 1253L, `1278` = 1278L, `1315` = 1315L, `1346` = 1346L,
`1372` = 1372L, `1416` = 1416L, `1441` = 1441L, `1473` = 1473L,
`1532` = 1532L, `1599` = 1599L, `1626` = 1626L, `1669` = 1669L,
`1694` = 1694L, `1718` = 1718L, `1726` = 1726L, `1766` = 1766L,
`1786` = 1786L, `1827` = 1827L, `1853` = 1853L, `1881` = 1881L,
`1922` = 1922L, `1952` = 1952L, `1971` = 1971L, `1984` = 1984L,
`2019` = 2019L, `2039` = 2039L, `2075` = 2075L, `2106` = 2106L,
`2135` = 2135L, `2181` = 2181L, `2206` = 2206L, `2227` = 2227L,
`2238` = 2238L, `2273` = 2273L, `2293` = 2293L, `2325` = 2325L,
`2366` = 2366L, `2391` = 2391L, `2436` = 2436L, `2461` = 2461L,
`2483` = 2483L, `2493` = 2493L), class = "omit"), row.names = c(1L,
2L, 3L, 4L, 5L, 7L), class = "data.frame")
I have built 9 regression models per forecast horizon (t+1, t+5 and t+22) and I am using the predict function to make my forecasts. I have coded this in an R loop, where I also try to assign each forecast to a matrix. My code is the following:
EUR/GBP_RGV t+1,t+5`~data.estimateI am trying to calculate realized volatility forecasts using a rolling window forecast. My aim is to use the first 500 observations to forecast the 501st observations, then shift the window forward one step using observations 2 to 501 to predict the 502nd observation. I want this to repeat until I have a complete pseudo out-of-sample forecast.
My df contains 2411 observations of 23 variables, here is small example:
Date
EUR/GBP_RV t+1
EUR/GBP_RV
EUR/GBP_RV_5
EUR/GBP_RV_22
2012-02-13
0.004019947
0.004467109
0.004995980
0.005150602
2012-02-14
0.004077322
0.004019947
0.004704742
0.005099209
2012-02-15
0.004666244
0.004077322
0.004564522
0.005020790
2012-02-16
0.004582351
0.004666244
0.004532930
0.005011078
2012-02-17
0.003951071
0.004582351
0.004362595
0.004999634
2012-02-21
0.005549329
0.004824547
0.004467109
0.004954358
The head of the df can be reproduced with
structure(list(Date = structure(c(15383, 15384, 15385, 15386,
15387, 15391), class = "Date"), `EUR/GBP_RV t+1,t+22` = c(0.00437808494654599,
0.00439764887779732, 0.00441997330738947, 0.00437799055732722,
0.00435021150904479, 0.00434881306458859), `EUR/GBP_RGV t+1,t+22` = c(0.00310674728131117,
0.00311502965608506, 0.00313756204195853, 0.00312923997431178,
0.00310846773074243, 0.00309755540903969), `EUR/GBP_RBV t+1,t+22` = c(0.00304961980133602,
0.00306866297401415, 0.00307794319983677, 0.00302801249035602,
0.00300946121851254, 0.00302272755554915), `EUR/GBP_RV t+1,t+5` = c(0.00425938711995146,
0.00442030721926592, 0.00471470868108043, 0.00487869292442023,
0.00476849421943949, 0.0046067439660438), `EUR/GBP_RGV t+1,t+5` = c(0.00287718093809447,
0.00311308998902836, 0.00344398536439729, 0.00376911066284235,
0.00377425759242542, 0.00353909902900148), `EUR/GBP_RBV t+1,t+5` = c(0.00313771439501486,
0.00310626895475871, 0.0031789431316576, 0.00305962424370556,
0.00288671182187571, 0.00291630955829613), `EUR/GBP_RV t+1` = c(0.00401994700051122,
0.00407732180013827, 0.00466624428620966, 0.00458235106134663,
0.00395107145155152, 0.00554932910921084), `EUR/GBP_RGV t+1` = c(0.00280067842079775,
0.00275522601341373, 0.00296142025653418, 0.00320716195737542,
0.00266141804235125, 0.00440970289025837), `EUR/GBP_RBV t+1` = c(0.00288377777753365,
0.00300554199386584, 0.00360608177982326, 0.00327292734850446,
0.0029202430753471, 0.00336891287836027), `EUR/GBP_RV` = c(0.00446710941914797,
0.00401994700051122, 0.00407732180013827, 0.00466624428620966,
0.00458235106134663, 0.00482454749708351), `EUR/GBP_RV_5` = c(0.00499598016427624,
0.00470474196716823, 0.00456452150727461, 0.00453292965488229,
0.00436259471347075, 0.00442030721926592), `EUR/GBP_RV_22` = c(0.00515060219897263,
0.00509920878086075, 0.00502079002092667, 0.00501107755050095,
0.00499963428727425, 0.00495435807685843), `EUR/GBP_RBV` = c(0.00324667045338159,
0.00288377777753365, 0.00300554199386584, 0.00360608177982326,
0.00327292734850446, 0.00272655057625291), `EUR/GBP_RBV_5` = c(0.0034985439252634,
0.00318731350301598, 0.00319529774619179, 0.0032799330165155,
0.00320299987062176, 0.00310626895475871), `EUR/GBP_RBV_22` = c(0.0036581887941976,
0.00362298829344015, 0.00355498498935768, 0.0035465419934449,
0.00355752455210586, 0.00351669973034298), `EUR/GBP_RGV` = c(0.00306825643155514,
0.00280067842079775, 0.00275522601341373, 0.00296142025653418,
0.00320716195737542, 0.00398022367546721), `EUR/GBP_RGV_5` = c(0.00353290218424469,
0.00345194162523714, 0.00325362896209417, 0.00312087362386985,
0.00295854861593525, 0.00311308998902836), `EUR/GBP_RGV_22` = c(0.00359974659692405,
0.00356342531619103, 0.00352224165959556, 0.00351722666683608,
0.00349184335907274, 0.00346394410318992), `EUR/GBP_TotalCount` = structure(c(-0.179518680545716,
-0.0757259172924681, 0.333514120677483, 0.759064450015801, -0.419724789788948,
-0.360414639358521), .Dim = c(6L, 1L)), `EUR/GBP_BloombergCount` = structure(c(-0.701694550941621,
-0.669811381311996, -0.574161872423118, -0.644304845608295, -0.784590791978649,
-0.631551577756444), .Dim = c(6L, 1L)), `EUR/GBP_SocialMediaCount` = structure(c(-1.68861759789696,
-1.66829994393287, -1.5910928588693, -1.59515638966212, -1.6967446594826,
-1.63172816679749), .Dim = c(6L, 1L)), `EUR/GBP_NewsCount` = structure(c(0.76560533722738,
0.879161625683434, 1.33717198912285, 1.90306082659552, 0.487392430510049,
0.487392430510049), .Dim = c(6L, 1L))), na.action = structure(c(`6` = 6L,
`38` = 38L, `74` = 74L, `101` = 101L, `140` = 140L, `165` = 165L,
`189` = 189L, `197` = 197L, `236` = 236L, `256` = 256L, `323` = 323L,
`351` = 351L, `393` = 393L, `423` = 423L, `442` = 442L, `455` = 455L,
`490` = 490L, `510` = 510L, `551` = 551L, `576` = 576L, `605` = 605L,
`646` = 646L, `676` = 676L, `696` = 696L, `708` = 708L, `742` = 742L,
`762` = 762L, `793` = 793L, `829` = 829L, `858` = 858L, `904` = 904L,
`929` = 929L, `950` = 950L, `961` = 961L, `996` = 996L, `1016` = 1016L,
`1089` = 1089L, `1114` = 1114L, `1159` = 1159L, `1184` = 1184L,
`1207` = 1207L, `1216` = 1216L, `1238` = 1238L, `1243` = 1243L,
`1253` = 1253L, `1278` = 1278L, `1315` = 1315L, `1346` = 1346L,
`1372` = 1372L, `1416` = 1416L, `1441` = 1441L, `1473` = 1473L,
`1532` = 1532L, `1599` = 1599L, `1626` = 1626L, `1669` = 1669L,
`1694` = 1694L, `1718` = 1718L, `1726` = 1726L, `1766` = 1766L,
`1786` = 1786L, `1827` = 1827L, `1853` = 1853L, `1881` = 1881L,
`1922` = 1922L, `1952` = 1952L, `1971` = 1971L, `1984` = 1984L,
`2019` = 2019L, `2039` = 2039L, `2075` = 2075L, `2106` = 2106L,
`2135` = 2135L, `2181` = 2181L, `2206` = 2206L, `2227` = 2227L,
`2238` = 2238L, `2273` = 2273L, `2293` = 2293L, `2325` = 2325L,
`2366` = 2366L, `2391` = 2391L, `2436` = 2436L, `2461` = 2461L,
`2483` = 2483L, `2493` = 2493L), class = "omit"), row.names = c(1L,
2L, 3L, 4L, 5L, 7L), class = "data.frame")
I have built 9 regression models per forecast horizon (t+1, t+5 and t+22) and I am using the predict function to make my forecasts. I have coded this in an R loop, where I also try to assign each forecast to a matrix. My code is the following:
EUR/GBP_RGV`+data.estimateI am trying to calculate realized volatility forecasts using a rolling window forecast. My aim is to use the first 500 observations to forecast the 501st observations, then shift the window forward one step using observations 2 to 501 to predict the 502nd observation. I want this to repeat until I have a complete pseudo out-of-sample forecast.
My df contains 2411 observations of 23 variables, here is small example:
Date
EUR/GBP_RV t+1
EUR/GBP_RV
EUR/GBP_RV_5
EUR/GBP_RV_22
2012-02-13
0.004019947
0.004467109
0.004995980
0.005150602
2012-02-14
0.004077322
0.004019947
0.004704742
0.005099209
2012-02-15
0.004666244
0.004077322
0.004564522
0.005020790
2012-02-16
0.004582351
0.004666244
0.004532930
0.005011078
2012-02-17
0.003951071
0.004582351
0.004362595
0.004999634
2012-02-21
0.005549329
0.004824547
0.004467109
0.004954358
The head of the df can be reproduced with
structure(list(Date = structure(c(15383, 15384, 15385, 15386,
15387, 15391), class = "Date"), `EUR/GBP_RV t+1,t+22` = c(0.00437808494654599,
0.00439764887779732, 0.00441997330738947, 0.00437799055732722,
0.00435021150904479, 0.00434881306458859), `EUR/GBP_RGV t+1,t+22` = c(0.00310674728131117,
0.00311502965608506, 0.00313756204195853, 0.00312923997431178,
0.00310846773074243, 0.00309755540903969), `EUR/GBP_RBV t+1,t+22` = c(0.00304961980133602,
0.00306866297401415, 0.00307794319983677, 0.00302801249035602,
0.00300946121851254, 0.00302272755554915), `EUR/GBP_RV t+1,t+5` = c(0.00425938711995146,
0.00442030721926592, 0.00471470868108043, 0.00487869292442023,
0.00476849421943949, 0.0046067439660438), `EUR/GBP_RGV t+1,t+5` = c(0.00287718093809447,
0.00311308998902836, 0.00344398536439729, 0.00376911066284235,
0.00377425759242542, 0.00353909902900148), `EUR/GBP_RBV t+1,t+5` = c(0.00313771439501486,
0.00310626895475871, 0.0031789431316576, 0.00305962424370556,
0.00288671182187571, 0.00291630955829613), `EUR/GBP_RV t+1` = c(0.00401994700051122,
0.00407732180013827, 0.00466624428620966, 0.00458235106134663,
0.00395107145155152, 0.00554932910921084), `EUR/GBP_RGV t+1` = c(0.00280067842079775,
0.00275522601341373, 0.00296142025653418, 0.00320716195737542,
0.00266141804235125, 0.00440970289025837), `EUR/GBP_RBV t+1` = c(0.00288377777753365,
0.00300554199386584, 0.00360608177982326, 0.00327292734850446,
0.0029202430753471, 0.00336891287836027), `EUR/GBP_RV` = c(0.00446710941914797,
0.00401994700051122, 0.00407732180013827, 0.00466624428620966,
0.00458235106134663, 0.00482454749708351), `EUR/GBP_RV_5` = c(0.00499598016427624,
0.00470474196716823, 0.00456452150727461, 0.00453292965488229,
0.00436259471347075, 0.00442030721926592), `EUR/GBP_RV_22` = c(0.00515060219897263,
0.00509920878086075, 0.00502079002092667, 0.00501107755050095,
0.00499963428727425, 0.00495435807685843), `EUR/GBP_RBV` = c(0.00324667045338159,
0.00288377777753365, 0.00300554199386584, 0.00360608177982326,
0.00327292734850446, 0.00272655057625291), `EUR/GBP_RBV_5` = c(0.0034985439252634,
0.00318731350301598, 0.00319529774619179, 0.0032799330165155,
0.00320299987062176, 0.00310626895475871), `EUR/GBP_RBV_22` = c(0.0036581887941976,
0.00362298829344015, 0.00355498498935768, 0.0035465419934449,
0.00355752455210586, 0.00351669973034298), `EUR/GBP_RGV` = c(0.00306825643155514,
0.00280067842079775, 0.00275522601341373, 0.00296142025653418,
0.00320716195737542, 0.00398022367546721), `EUR/GBP_RGV_5` = c(0.00353290218424469,
0.00345194162523714, 0.00325362896209417, 0.00312087362386985,
0.00295854861593525, 0.00311308998902836), `EUR/GBP_RGV_22` = c(0.00359974659692405,
0.00356342531619103, 0.00352224165959556, 0.00351722666683608,
0.00349184335907274, 0.00346394410318992), `EUR/GBP_TotalCount` = structure(c(-0.179518680545716,
-0.0757259172924681, 0.333514120677483, 0.759064450015801, -0.419724789788948,
-0.360414639358521), .Dim = c(6L, 1L)), `EUR/GBP_BloombergCount` = structure(c(-0.701694550941621,
-0.669811381311996, -0.574161872423118, -0.644304845608295, -0.784590791978649,
-0.631551577756444), .Dim = c(6L, 1L)), `EUR/GBP_SocialMediaCount` = structure(c(-1.68861759789696,
-1.66829994393287, -1.5910928588693, -1.59515638966212, -1.6967446594826,
-1.63172816679749), .Dim = c(6L, 1L)), `EUR/GBP_NewsCount` = structure(c(0.76560533722738,
0.879161625683434, 1.33717198912285, 1.90306082659552, 0.487392430510049,
0.487392430510049), .Dim = c(6L, 1L))), na.action = structure(c(`6` = 6L,
`38` = 38L, `74` = 74L, `101` = 101L, `140` = 140L, `165` = 165L,
`189` = 189L, `197` = 197L, `236` = 236L, `256` = 256L, `323` = 323L,
`351` = 351L, `393` = 393L, `423` = 423L, `442` = 442L, `455` = 455L,
`490` = 490L, `510` = 510L, `551` = 551L, `576` = 576L, `605` = 605L,
`646` = 646L, `676` = 676L, `696` = 696L, `708` = 708L, `742` = 742L,
`762` = 762L, `793` = 793L, `829` = 829L, `858` = 858L, `904` = 904L,
`929` = 929L, `950` = 950L, `961` = 961L, `996` = 996L, `1016` = 1016L,
`1089` = 1089L, `1114` = 1114L, `1159` = 1159L, `1184` = 1184L,
`1207` = 1207L, `1216` = 1216L, `1238` = 1238L, `1243` = 1243L,
`1253` = 1253L, `1278` = 1278L, `1315` = 1315L, `1346` = 1346L,
`1372` = 1372L, `1416` = 1416L, `1441` = 1441L, `1473` = 1473L,
`1532` = 1532L, `1599` = 1599L, `1626` = 1626L, `1669` = 1669L,
`1694` = 1694L, `1718` = 1718L, `1726` = 1726L, `1766` = 1766L,
`1786` = 1786L, `1827` = 1827L, `1853` = 1853L, `1881` = 1881L,
`1922` = 1922L, `1952` = 1952L, `1971` = 1971L, `1984` = 1984L,
`2019` = 2019L, `2039` = 2039L, `2075` = 2075L, `2106` = 2106L,
`2135` = 2135L, `2181` = 2181L, `2206` = 2206L, `2227` = 2227L,
`2238` = 2238L, `2273` = 2273L, `2293` = 2293L, `2325` = 2325L,
`2366` = 2366L, `2391` = 2391L, `2436` = 2436L, `2461` = 2461L,
`2483` = 2483L, `2493` = 2493L), class = "omit"), row.names = c(1L,
2L, 3L, 4L, 5L, 7L), class = "data.frame")
I have built 9 regression models per forecast horizon (t+1, t+5 and t+22) and I am using the predict function to make my forecasts. I have coded this in an R loop, where I also try to assign each forecast to a matrix. My code is the following:
EUR/GBP_RGV_5`+data.estimateI am trying to calculate realized volatility forecasts using a rolling window forecast. My aim is to use the first 500 observations to forecast the 501st observations, then shift the window forward one step using observations 2 to 501 to predict the 502nd observation. I want this to repeat until I have a complete pseudo out-of-sample forecast.
My df contains 2411 observations of 23 variables, here is small example:
Date
EUR/GBP_RV t+1
EUR/GBP_RV
EUR/GBP_RV_5
EUR/GBP_RV_22
2012-02-13
0.004019947
0.004467109
0.004995980
0.005150602
2012-02-14
0.004077322
0.004019947
0.004704742
0.005099209
2012-02-15
0.004666244
0.004077322
0.004564522
0.005020790
2012-02-16
0.004582351
0.004666244
0.004532930
0.005011078
2012-02-17
0.003951071
0.004582351
0.004362595
0.004999634
2012-02-21
0.005549329
0.004824547
0.004467109
0.004954358
The head of the df can be reproduced with
structure(list(Date = structure(c(15383, 15384, 15385, 15386,
15387, 15391), class = "Date"), `EUR/GBP_RV t+1,t+22` = c(0.00437808494654599,
0.00439764887779732, 0.00441997330738947, 0.00437799055732722,
0.00435021150904479, 0.00434881306458859), `EUR/GBP_RGV t+1,t+22` = c(0.00310674728131117,
0.00311502965608506, 0.00313756204195853, 0.00312923997431178,
0.00310846773074243, 0.00309755540903969), `EUR/GBP_RBV t+1,t+22` = c(0.00304961980133602,
0.00306866297401415, 0.00307794319983677, 0.00302801249035602,
0.00300946121851254, 0.00302272755554915), `EUR/GBP_RV t+1,t+5` = c(0.00425938711995146,
0.00442030721926592, 0.00471470868108043, 0.00487869292442023,
0.00476849421943949, 0.0046067439660438), `EUR/GBP_RGV t+1,t+5` = c(0.00287718093809447,
0.00311308998902836, 0.00344398536439729, 0.00376911066284235,
0.00377425759242542, 0.00353909902900148), `EUR/GBP_RBV t+1,t+5` = c(0.00313771439501486,
0.00310626895475871, 0.0031789431316576, 0.00305962424370556,
0.00288671182187571, 0.00291630955829613), `EUR/GBP_RV t+1` = c(0.00401994700051122,
0.00407732180013827, 0.00466624428620966, 0.00458235106134663,
0.00395107145155152, 0.00554932910921084), `EUR/GBP_RGV t+1` = c(0.00280067842079775,
0.00275522601341373, 0.00296142025653418, 0.00320716195737542,
0.00266141804235125, 0.00440970289025837), `EUR/GBP_RBV t+1` = c(0.00288377777753365,
0.00300554199386584, 0.00360608177982326, 0.00327292734850446,
0.0029202430753471, 0.00336891287836027), `EUR/GBP_RV` = c(0.00446710941914797,
0.00401994700051122, 0.00407732180013827, 0.00466624428620966,
0.00458235106134663, 0.00482454749708351), `EUR/GBP_RV_5` = c(0.00499598016427624,
0.00470474196716823, 0.00456452150727461, 0.00453292965488229,
0.00436259471347075, 0.00442030721926592), `EUR/GBP_RV_22` = c(0.00515060219897263,
0.00509920878086075, 0.00502079002092667, 0.00501107755050095,
0.00499963428727425, 0.00495435807685843), `EUR/GBP_RBV` = c(0.00324667045338159,
0.00288377777753365, 0.00300554199386584, 0.00360608177982326,
0.00327292734850446, 0.00272655057625291), `EUR/GBP_RBV_5` = c(0.0034985439252634,
0.00318731350301598, 0.00319529774619179, 0.0032799330165155,
0.00320299987062176, 0.00310626895475871), `EUR/GBP_RBV_22` = c(0.0036581887941976,
0.00362298829344015, 0.00355498498935768, 0.0035465419934449,
0.00355752455210586, 0.00351669973034298), `EUR/GBP_RGV` = c(0.00306825643155514,
0.00280067842079775, 0.00275522601341373, 0.00296142025653418,
0.00320716195737542, 0.00398022367546721), `EUR/GBP_RGV_5` = c(0.00353290218424469,
0.00345194162523714, 0.00325362896209417, 0.00312087362386985,
0.00295854861593525, 0.00311308998902836), `EUR/GBP_RGV_22` = c(0.00359974659692405,
0.00356342531619103, 0.00352224165959556, 0.00351722666683608,
0.00349184335907274, 0.00346394410318992), `EUR/GBP_TotalCount` = structure(c(-0.179518680545716,
-0.0757259172924681, 0.333514120677483, 0.759064450015801, -0.419724789788948,
-0.360414639358521), .Dim = c(6L, 1L)), `EUR/GBP_BloombergCount` = structure(c(-0.701694550941621,
-0.669811381311996, -0.574161872423118, -0.644304845608295, -0.784590791978649,
-0.631551577756444), .Dim = c(6L, 1L)), `EUR/GBP_SocialMediaCount` = structure(c(-1.68861759789696,
-1.66829994393287, -1.5910928588693, -1.59515638966212, -1.6967446594826,
-1.63172816679749), .Dim = c(6L, 1L)), `EUR/GBP_NewsCount` = structure(c(0.76560533722738,
0.879161625683434, 1.33717198912285, 1.90306082659552, 0.487392430510049,
0.487392430510049), .Dim = c(6L, 1L))), na.action = structure(c(`6` = 6L,
`38` = 38L, `74` = 74L, `101` = 101L, `140` = 140L, `165` = 165L,
`189` = 189L, `197` = 197L, `236` = 236L, `256` = 256L, `323` = 323L,
`351` = 351L, `393` = 393L, `423` = 423L, `442` = 442L, `455` = 455L,
`490` = 490L, `510` = 510L, `551` = 551L, `576` = 576L, `605` = 605L,
`646` = 646L, `676` = 676L, `696` = 696L, `708` = 708L, `742` = 742L,
`762` = 762L, `793` = 793L, `829` = 829L, `858` = 858L, `904` = 904L,
`929` = 929L, `950` = 950L, `961` = 961L, `996` = 996L, `1016` = 1016L,
`1089` = 1089L, `1114` = 1114L, `1159` = 1159L, `1184` = 1184L,
`1207` = 1207L, `1216` = 1216L, `1238` = 1238L, `1243` = 1243L,
`1253` = 1253L, `1278` = 1278L, `1315` = 1315L, `1346` = 1346L,
`1372` = 1372L, `1416` = 1416L, `1441` = 1441L, `1473` = 1473L,
`1532` = 1532L, `1599` = 1599L, `1626` = 1626L, `1669` = 1669L,
`1694` = 1694L, `1718` = 1718L, `1726` = 1726L, `1766` = 1766L,
`1786` = 1786L, `1827` = 1827L, `1853` = 1853L, `1881` = 1881L,
`1922` = 1922L, `1952` = 1952L, `1971` = 1971L, `1984` = 1984L,
`2019` = 2019L, `2039` = 2039L, `2075` = 2075L, `2106` = 2106L,
`2135` = 2135L, `2181` = 2181L, `2206` = 2206L, `2227` = 2227L,
`2238` = 2238L, `2273` = 2273L, `2293` = 2293L, `2325` = 2325L,
`2366` = 2366L, `2391` = 2391L, `2436` = 2436L, `2461` = 2461L,
`2483` = 2483L, `2493` = 2493L), class = "omit"), row.names = c(1L,
2L, 3L, 4L, 5L, 7L), class = "data.frame")
I have built 9 regression models per forecast horizon (t+1, t+5 and t+22) and I am using the predict function to make my forecasts. I have coded this in an R loop, where I also try to assign each forecast to a matrix. My code is the following:
EUR/GBP_RGV_22`)
EURGBP_HAR_RVGt5_NT_train <- lm(data.estimateI am trying to calculate realized volatility forecasts using a rolling window forecast. My aim is to use the first 500 observations to forecast the 501st observations, then shift the window forward one step using observations 2 to 501 to predict the 502nd observation. I want this to repeat until I have a complete pseudo out-of-sample forecast.
My df contains 2411 observations of 23 variables, here is small example:
Date
EUR/GBP_RV t+1
EUR/GBP_RV
EUR/GBP_RV_5
EUR/GBP_RV_22
2012-02-13
0.004019947
0.004467109
0.004995980
0.005150602
2012-02-14
0.004077322
0.004019947
0.004704742
0.005099209
2012-02-15
0.004666244
0.004077322
0.004564522
0.005020790
2012-02-16
0.004582351
0.004666244
0.004532930
0.005011078
2012-02-17
0.003951071
0.004582351
0.004362595
0.004999634
2012-02-21
0.005549329
0.004824547
0.004467109
0.004954358
The head of the df can be reproduced with
structure(list(Date = structure(c(15383, 15384, 15385, 15386,
15387, 15391), class = "Date"), `EUR/GBP_RV t+1,t+22` = c(0.00437808494654599,
0.00439764887779732, 0.00441997330738947, 0.00437799055732722,
0.00435021150904479, 0.00434881306458859), `EUR/GBP_RGV t+1,t+22` = c(0.00310674728131117,
0.00311502965608506, 0.00313756204195853, 0.00312923997431178,
0.00310846773074243, 0.00309755540903969), `EUR/GBP_RBV t+1,t+22` = c(0.00304961980133602,
0.00306866297401415, 0.00307794319983677, 0.00302801249035602,
0.00300946121851254, 0.00302272755554915), `EUR/GBP_RV t+1,t+5` = c(0.00425938711995146,
0.00442030721926592, 0.00471470868108043, 0.00487869292442023,
0.00476849421943949, 0.0046067439660438), `EUR/GBP_RGV t+1,t+5` = c(0.00287718093809447,
0.00311308998902836, 0.00344398536439729, 0.00376911066284235,
0.00377425759242542, 0.00353909902900148), `EUR/GBP_RBV t+1,t+5` = c(0.00313771439501486,
0.00310626895475871, 0.0031789431316576, 0.00305962424370556,
0.00288671182187571, 0.00291630955829613), `EUR/GBP_RV t+1` = c(0.00401994700051122,
0.00407732180013827, 0.00466624428620966, 0.00458235106134663,
0.00395107145155152, 0.00554932910921084), `EUR/GBP_RGV t+1` = c(0.00280067842079775,
0.00275522601341373, 0.00296142025653418, 0.00320716195737542,
0.00266141804235125, 0.00440970289025837), `EUR/GBP_RBV t+1` = c(0.00288377777753365,
0.00300554199386584, 0.00360608177982326, 0.00327292734850446,
0.0029202430753471, 0.00336891287836027), `EUR/GBP_RV` = c(0.00446710941914797,
0.00401994700051122, 0.00407732180013827, 0.00466624428620966,
0.00458235106134663, 0.00482454749708351), `EUR/GBP_RV_5` = c(0.00499598016427624,
0.00470474196716823, 0.00456452150727461, 0.00453292965488229,
0.00436259471347075, 0.00442030721926592), `EUR/GBP_RV_22` = c(0.00515060219897263,
0.00509920878086075, 0.00502079002092667, 0.00501107755050095,
0.00499963428727425, 0.00495435807685843), `EUR/GBP_RBV` = c(0.00324667045338159,
0.00288377777753365, 0.00300554199386584, 0.00360608177982326,
0.00327292734850446, 0.00272655057625291), `EUR/GBP_RBV_5` = c(0.0034985439252634,
0.00318731350301598, 0.00319529774619179, 0.0032799330165155,
0.00320299987062176, 0.00310626895475871), `EUR/GBP_RBV_22` = c(0.0036581887941976,
0.00362298829344015, 0.00355498498935768, 0.0035465419934449,
0.00355752455210586, 0.00351669973034298), `EUR/GBP_RGV` = c(0.00306825643155514,
0.00280067842079775, 0.00275522601341373, 0.00296142025653418,
0.00320716195737542, 0.00398022367546721), `EUR/GBP_RGV_5` = c(0.00353290218424469,
0.00345194162523714, 0.00325362896209417, 0.00312087362386985,
0.00295854861593525, 0.00311308998902836), `EUR/GBP_RGV_22` = c(0.00359974659692405,
0.00356342531619103, 0.00352224165959556, 0.00351722666683608,
0.00349184335907274, 0.00346394410318992), `EUR/GBP_TotalCount` = structure(c(-0.179518680545716,
-0.0757259172924681, 0.333514120677483, 0.759064450015801, -0.419724789788948,
-0.360414639358521), .Dim = c(6L, 1L)), `EUR/GBP_BloombergCount` = structure(c(-0.701694550941621,
-0.669811381311996, -0.574161872423118, -0.644304845608295, -0.784590791978649,
-0.631551577756444), .Dim = c(6L, 1L)), `EUR/GBP_SocialMediaCount` = structure(c(-1.68861759789696,
-1.66829994393287, -1.5910928588693, -1.59515638966212, -1.6967446594826,
-1.63172816679749), .Dim = c(6L, 1L)), `EUR/GBP_NewsCount` = structure(c(0.76560533722738,
0.879161625683434, 1.33717198912285, 1.90306082659552, 0.487392430510049,
0.487392430510049), .Dim = c(6L, 1L))), na.action = structure(c(`6` = 6L,
`38` = 38L, `74` = 74L, `101` = 101L, `140` = 140L, `165` = 165L,
`189` = 189L, `197` = 197L, `236` = 236L, `256` = 256L, `323` = 323L,
`351` = 351L, `393` = 393L, `423` = 423L, `442` = 442L, `455` = 455L,
`490` = 490L, `510` = 510L, `551` = 551L, `576` = 576L, `605` = 605L,
`646` = 646L, `676` = 676L, `696` = 696L, `708` = 708L, `742` = 742L,
`762` = 762L, `793` = 793L, `829` = 829L, `858` = 858L, `904` = 904L,
`929` = 929L, `950` = 950L, `961` = 961L, `996` = 996L, `1016` = 1016L,
`1089` = 1089L, `1114` = 1114L, `1159` = 1159L, `1184` = 1184L,
`1207` = 1207L, `1216` = 1216L, `1238` = 1238L, `1243` = 1243L,
`1253` = 1253L, `1278` = 1278L, `1315` = 1315L, `1346` = 1346L,
`1372` = 1372L, `1416` = 1416L, `1441` = 1441L, `1473` = 1473L,
`1532` = 1532L, `1599` = 1599L, `1626` = 1626L, `1669` = 1669L,
`1694` = 1694L, `1718` = 1718L, `1726` = 1726L, `1766` = 1766L,
`1786` = 1786L, `1827` = 1827L, `1853` = 1853L, `1881` = 1881L,
`1922` = 1922L, `1952` = 1952L, `1971` = 1971L, `1984` = 1984L,
`2019` = 2019L, `2039` = 2039L, `2075` = 2075L, `2106` = 2106L,
`2135` = 2135L, `2181` = 2181L, `2206` = 2206L, `2227` = 2227L,
`2238` = 2238L, `2273` = 2273L, `2293` = 2293L, `2325` = 2325L,
`2366` = 2366L, `2391` = 2391L, `2436` = 2436L, `2461` = 2461L,
`2483` = 2483L, `2493` = 2493L), class = "omit"), row.names = c(1L,
2L, 3L, 4L, 5L, 7L), class = "data.frame")
I have built 9 regression models per forecast horizon (t+1, t+5 and t+22) and I am using the predict function to make my forecasts. I have coded this in an R loop, where I also try to assign each forecast to a matrix. My code is the following:
EUR/GBP_RGV t+1,t+5`~data.estimateI am trying to calculate realized volatility forecasts using a rolling window forecast. My aim is to use the first 500 observations to forecast the 501st observations, then shift the window forward one step using observations 2 to 501 to predict the 502nd observation. I want this to repeat until I have a complete pseudo out-of-sample forecast.
My df contains 2411 observations of 23 variables, here is small example:
Date
EUR/GBP_RV t+1
EUR/GBP_RV
EUR/GBP_RV_5
EUR/GBP_RV_22
2012-02-13
0.004019947
0.004467109
0.004995980
0.005150602
2012-02-14
0.004077322
0.004019947
0.004704742
0.005099209
2012-02-15
0.004666244
0.004077322
0.004564522
0.005020790
2012-02-16
0.004582351
0.004666244
0.004532930
0.005011078
2012-02-17
0.003951071
0.004582351
0.004362595
0.004999634
2012-02-21
0.005549329
0.004824547
0.004467109
0.004954358
The head of the df can be reproduced with
structure(list(Date = structure(c(15383, 15384, 15385, 15386,
15387, 15391), class = "Date"), `EUR/GBP_RV t+1,t+22` = c(0.00437808494654599,
0.00439764887779732, 0.00441997330738947, 0.00437799055732722,
0.00435021150904479, 0.00434881306458859), `EUR/GBP_RGV t+1,t+22` = c(0.00310674728131117,
0.00311502965608506, 0.00313756204195853, 0.00312923997431178,
0.00310846773074243, 0.00309755540903969), `EUR/GBP_RBV t+1,t+22` = c(0.00304961980133602,
0.00306866297401415, 0.00307794319983677, 0.00302801249035602,
0.00300946121851254, 0.00302272755554915), `EUR/GBP_RV t+1,t+5` = c(0.00425938711995146,
0.00442030721926592, 0.00471470868108043, 0.00487869292442023,
0.00476849421943949, 0.0046067439660438), `EUR/GBP_RGV t+1,t+5` = c(0.00287718093809447,
0.00311308998902836, 0.00344398536439729, 0.00376911066284235,
0.00377425759242542, 0.00353909902900148), `EUR/GBP_RBV t+1,t+5` = c(0.00313771439501486,
0.00310626895475871, 0.0031789431316576, 0.00305962424370556,
0.00288671182187571, 0.00291630955829613), `EUR/GBP_RV t+1` = c(0.00401994700051122,
0.00407732180013827, 0.00466624428620966, 0.00458235106134663,
0.00395107145155152, 0.00554932910921084), `EUR/GBP_RGV t+1` = c(0.00280067842079775,
0.00275522601341373, 0.00296142025653418, 0.00320716195737542,
0.00266141804235125, 0.00440970289025837), `EUR/GBP_RBV t+1` = c(0.00288377777753365,
0.00300554199386584, 0.00360608177982326, 0.00327292734850446,
0.0029202430753471, 0.00336891287836027), `EUR/GBP_RV` = c(0.00446710941914797,
0.00401994700051122, 0.00407732180013827, 0.00466624428620966,
0.00458235106134663, 0.00482454749708351), `EUR/GBP_RV_5` = c(0.00499598016427624,
0.00470474196716823, 0.00456452150727461, 0.00453292965488229,
0.00436259471347075, 0.00442030721926592), `EUR/GBP_RV_22` = c(0.00515060219897263,
0.00509920878086075, 0.00502079002092667, 0.00501107755050095,
0.00499963428727425, 0.00495435807685843), `EUR/GBP_RBV` = c(0.00324667045338159,
0.00288377777753365, 0.00300554199386584, 0.00360608177982326,
0.00327292734850446, 0.00272655057625291), `EUR/GBP_RBV_5` = c(0.0034985439252634,
0.00318731350301598, 0.00319529774619179, 0.0032799330165155,
0.00320299987062176, 0.00310626895475871), `EUR/GBP_RBV_22` = c(0.0036581887941976,
0.00362298829344015, 0.00355498498935768, 0.0035465419934449,
0.00355752455210586, 0.00351669973034298), `EUR/GBP_RGV` = c(0.00306825643155514,
0.00280067842079775, 0.00275522601341373, 0.00296142025653418,
0.00320716195737542, 0.00398022367546721), `EUR/GBP_RGV_5` = c(0.00353290218424469,
0.00345194162523714, 0.00325362896209417, 0.00312087362386985,
0.00295854861593525, 0.00311308998902836), `EUR/GBP_RGV_22` = c(0.00359974659692405,
0.00356342531619103, 0.00352224165959556, 0.00351722666683608,
0.00349184335907274, 0.00346394410318992), `EUR/GBP_TotalCount` = structure(c(-0.179518680545716,
-0.0757259172924681, 0.333514120677483, 0.759064450015801, -0.419724789788948,
-0.360414639358521), .Dim = c(6L, 1L)), `EUR/GBP_BloombergCount` = structure(c(-0.701694550941621,
-0.669811381311996, -0.574161872423118, -0.644304845608295, -0.784590791978649,
-0.631551577756444), .Dim = c(6L, 1L)), `EUR/GBP_SocialMediaCount` = structure(c(-1.68861759789696,
-1.66829994393287, -1.5910928588693, -1.59515638966212, -1.6967446594826,
-1.63172816679749), .Dim = c(6L, 1L)), `EUR/GBP_NewsCount` = structure(c(0.76560533722738,
0.879161625683434, 1.33717198912285, 1.90306082659552, 0.487392430510049,
0.487392430510049), .Dim = c(6L, 1L))), na.action = structure(c(`6` = 6L,
`38` = 38L, `74` = 74L, `101` = 101L, `140` = 140L, `165` = 165L,
`189` = 189L, `197` = 197L, `236` = 236L, `256` = 256L, `323` = 323L,
`351` = 351L, `393` = 393L, `423` = 423L, `442` = 442L, `455` = 455L,
`490` = 490L, `510` = 510L, `551` = 551L, `576` = 576L, `605` = 605L,
`646` = 646L, `676` = 676L, `696` = 696L, `708` = 708L, `742` = 742L,
`762` = 762L, `793` = 793L, `829` = 829L, `858` = 858L, `904` = 904L,
`929` = 929L, `950` = 950L, `961` = 961L, `996` = 996L, `1016` = 1016L,
`1089` = 1089L, `1114` = 1114L, `1159` = 1159L, `1184` = 1184L,
`1207` = 1207L, `1216` = 1216L, `1238` = 1238L, `1243` = 1243L,
`1253` = 1253L, `1278` = 1278L, `1315` = 1315L, `1346` = 1346L,
`1372` = 1372L, `1416` = 1416L, `1441` = 1441L, `1473` = 1473L,
`1532` = 1532L, `1599` = 1599L, `1626` = 1626L, `1669` = 1669L,
`1694` = 1694L, `1718` = 1718L, `1726` = 1726L, `1766` = 1766L,
`1786` = 1786L, `1827` = 1827L, `1853` = 1853L, `1881` = 1881L,
`1922` = 1922L, `1952` = 1952L, `1971` = 1971L, `1984` = 1984L,
`2019` = 2019L, `2039` = 2039L, `2075` = 2075L, `2106` = 2106L,
`2135` = 2135L, `2181` = 2181L, `2206` = 2206L, `2227` = 2227L,
`2238` = 2238L, `2273` = 2273L, `2293` = 2293L, `2325` = 2325L,
`2366` = 2366L, `2391` = 2391L, `2436` = 2436L, `2461` = 2461L,
`2483` = 2483L, `2493` = 2493L), class = "omit"), row.names = c(1L,
2L, 3L, 4L, 5L, 7L), class = "data.frame")
I have built 9 regression models per forecast horizon (t+1, t+5 and t+22) and I am using the predict function to make my forecasts. I have coded this in an R loop, where I also try to assign each forecast to a matrix. My code is the following:
EUR/GBP_RGV`+data.estimateI am trying to calculate realized volatility forecasts using a rolling window forecast. My aim is to use the first 500 observations to forecast the 501st observations, then shift the window forward one step using observations 2 to 501 to predict the 502nd observation. I want this to repeat until I have a complete pseudo out-of-sample forecast.
My df contains 2411 observations of 23 variables, here is small example:
Date
EUR/GBP_RV t+1
EUR/GBP_RV
EUR/GBP_RV_5
EUR/GBP_RV_22
2012-02-13
0.004019947
0.004467109
0.004995980
0.005150602
2012-02-14
0.004077322
0.004019947
0.004704742
0.005099209
2012-02-15
0.004666244
0.004077322
0.004564522
0.005020790
2012-02-16
0.004582351
0.004666244
0.004532930
0.005011078
2012-02-17
0.003951071
0.004582351
0.004362595
0.004999634
2012-02-21
0.005549329
0.004824547
0.004467109
0.004954358
The head of the df can be reproduced with
structure(list(Date = structure(c(15383, 15384, 15385, 15386,
15387, 15391), class = "Date"), `EUR/GBP_RV t+1,t+22` = c(0.00437808494654599,
0.00439764887779732, 0.00441997330738947, 0.00437799055732722,
0.00435021150904479, 0.00434881306458859), `EUR/GBP_RGV t+1,t+22` = c(0.00310674728131117,
0.00311502965608506, 0.00313756204195853, 0.00312923997431178,
0.00310846773074243, 0.00309755540903969), `EUR/GBP_RBV t+1,t+22` = c(0.00304961980133602,
0.00306866297401415, 0.00307794319983677, 0.00302801249035602,
0.00300946121851254, 0.00302272755554915), `EUR/GBP_RV t+1,t+5` = c(0.00425938711995146,
0.00442030721926592, 0.00471470868108043, 0.00487869292442023,
0.00476849421943949, 0.0046067439660438), `EUR/GBP_RGV t+1,t+5` = c(0.00287718093809447,
0.00311308998902836, 0.00344398536439729, 0.00376911066284235,
0.00377425759242542, 0.00353909902900148), `EUR/GBP_RBV t+1,t+5` = c(0.00313771439501486,
0.00310626895475871, 0.0031789431316576, 0.00305962424370556,
0.00288671182187571, 0.00291630955829613), `EUR/GBP_RV t+1` = c(0.00401994700051122,
0.00407732180013827, 0.00466624428620966, 0.00458235106134663,
0.00395107145155152, 0.00554932910921084), `EUR/GBP_RGV t+1` = c(0.00280067842079775,
0.00275522601341373, 0.00296142025653418, 0.00320716195737542,
0.00266141804235125, 0.00440970289025837), `EUR/GBP_RBV t+1` = c(0.00288377777753365,
0.00300554199386584, 0.00360608177982326, 0.00327292734850446,
0.0029202430753471, 0.00336891287836027), `EUR/GBP_RV` = c(0.00446710941914797,
0.00401994700051122, 0.00407732180013827, 0.00466624428620966,
0.00458235106134663, 0.00482454749708351), `EUR/GBP_RV_5` = c(0.00499598016427624,
0.00470474196716823, 0.00456452150727461, 0.00453292965488229,
0.00436259471347075, 0.00442030721926592), `EUR/GBP_RV_22` = c(0.00515060219897263,
0.00509920878086075, 0.00502079002092667, 0.00501107755050095,
0.00499963428727425, 0.00495435807685843), `EUR/GBP_RBV` = c(0.00324667045338159,
0.00288377777753365, 0.00300554199386584, 0.00360608177982326,
0.00327292734850446, 0.00272655057625291), `EUR/GBP_RBV_5` = c(0.0034985439252634,
0.00318731350301598, 0.00319529774619179, 0.0032799330165155,
0.00320299987062176, 0.00310626895475871), `EUR/GBP_RBV_22` = c(0.0036581887941976,
0.00362298829344015, 0.00355498498935768, 0.0035465419934449,
0.00355752455210586, 0.00351669973034298), `EUR/GBP_RGV` = c(0.00306825643155514,
0.00280067842079775, 0.00275522601341373, 0.00296142025653418,
0.00320716195737542, 0.00398022367546721), `EUR/GBP_RGV_5` = c(0.00353290218424469,
0.00345194162523714, 0.00325362896209417, 0.00312087362386985,
0.00295854861593525, 0.00311308998902836), `EUR/GBP_RGV_22` = c(0.00359974659692405,
0.00356342531619103, 0.00352224165959556, 0.00351722666683608,
0.00349184335907274, 0.00346394410318992), `EUR/GBP_TotalCount` = structure(c(-0.179518680545716,
-0.0757259172924681, 0.333514120677483, 0.759064450015801, -0.419724789788948,
-0.360414639358521), .Dim = c(6L, 1L)), `EUR/GBP_BloombergCount` = structure(c(-0.701694550941621,
-0.669811381311996, -0.574161872423118, -0.644304845608295, -0.784590791978649,
-0.631551577756444), .Dim = c(6L, 1L)), `EUR/GBP_SocialMediaCount` = structure(c(-1.68861759789696,
-1.66829994393287, -1.5910928588693, -1.59515638966212, -1.6967446594826,
-1.63172816679749), .Dim = c(6L, 1L)), `EUR/GBP_NewsCount` = structure(c(0.76560533722738,
0.879161625683434, 1.33717198912285, 1.90306082659552, 0.487392430510049,
0.487392430510049), .Dim = c(6L, 1L))), na.action = structure(c(`6` = 6L,
`38` = 38L, `74` = 74L, `101` = 101L, `140` = 140L, `165` = 165L,
`189` = 189L, `197` = 197L, `236` = 236L, `256` = 256L, `323` = 323L,
`351` = 351L, `393` = 393L, `423` = 423L, `442` = 442L, `455` = 455L,
`490` = 490L, `510` = 510L, `551` = 551L, `576` = 576L, `605` = 605L,
`646` = 646L, `676` = 676L, `696` = 696L, `708` = 708L, `742` = 742L,
`762` = 762L, `793` = 793L, `829` = 829L, `858` = 858L, `904` = 904L,
`929` = 929L, `950` = 950L, `961` = 961L, `996` = 996L, `1016` = 1016L,
`1089` = 1089L, `1114` = 1114L, `1159` = 1159L, `1184` = 1184L,
`1207` = 1207L, `1216` = 1216L, `1238` = 1238L, `1243` = 1243L,
`1253` = 1253L, `1278` = 1278L, `1315` = 1315L, `1346` = 1346L,
`1372` = 1372L, `1416` = 1416L, `1441` = 1441L, `1473` = 1473L,
`1532` = 1532L, `1599` = 1599L, `1626` = 1626L, `1669` = 1669L,
`1694` = 1694L, `1718` = 1718L, `1726` = 1726L, `1766` = 1766L,
`1786` = 1786L, `1827` = 1827L, `1853` = 1853L, `1881` = 1881L,
`1922` = 1922L, `1952` = 1952L, `1971` = 1971L, `1984` = 1984L,
`2019` = 2019L, `2039` = 2039L, `2075` = 2075L, `2106` = 2106L,
`2135` = 2135L, `2181` = 2181L, `2206` = 2206L, `2227` = 2227L,
`2238` = 2238L, `2273` = 2273L, `2293` = 2293L, `2325` = 2325L,
`2366` = 2366L, `2391` = 2391L, `2436` = 2436L, `2461` = 2461L,
`2483` = 2483L, `2493` = 2493L), class = "omit"), row.names = c(1L,
2L, 3L, 4L, 5L, 7L), class = "data.frame")
I have built 9 regression models per forecast horizon (t+1, t+5 and t+22) and I am using the predict function to make my forecasts. I have coded this in an R loop, where I also try to assign each forecast to a matrix. My code is the following:
EUR/GBP_RGV_5`+data.estimateI am trying to calculate realized volatility forecasts using a rolling window forecast. My aim is to use the first 500 observations to forecast the 501st observations, then shift the window forward one step using observations 2 to 501 to predict the 502nd observation. I want this to repeat until I have a complete pseudo out-of-sample forecast.
My df contains 2411 observations of 23 variables, here is small example:
Date
EUR/GBP_RV t+1
EUR/GBP_RV
EUR/GBP_RV_5
EUR/GBP_RV_22
2012-02-13
0.004019947
0.004467109
0.004995980
0.005150602
2012-02-14
0.004077322
0.004019947
0.004704742
0.005099209
2012-02-15
0.004666244
0.004077322
0.004564522
0.005020790
2012-02-16
0.004582351
0.004666244
0.004532930
0.005011078
2012-02-17
0.003951071
0.004582351
0.004362595
0.004999634
2012-02-21
0.005549329
0.004824547
0.004467109
0.004954358
The head of the df can be reproduced with
structure(list(Date = structure(c(15383, 15384, 15385, 15386,
15387, 15391), class = "Date"), `EUR/GBP_RV t+1,t+22` = c(0.00437808494654599,
0.00439764887779732, 0.00441997330738947, 0.00437799055732722,
0.00435021150904479, 0.00434881306458859), `EUR/GBP_RGV t+1,t+22` = c(0.00310674728131117,
0.00311502965608506, 0.00313756204195853, 0.00312923997431178,
0.00310846773074243, 0.00309755540903969), `EUR/GBP_RBV t+1,t+22` = c(0.00304961980133602,
0.00306866297401415, 0.00307794319983677, 0.00302801249035602,
0.00300946121851254, 0.00302272755554915), `EUR/GBP_RV t+1,t+5` = c(0.00425938711995146,
0.00442030721926592, 0.00471470868108043, 0.00487869292442023,
0.00476849421943949, 0.0046067439660438), `EUR/GBP_RGV t+1,t+5` = c(0.00287718093809447,
0.00311308998902836, 0.00344398536439729, 0.00376911066284235,
0.00377425759242542, 0.00353909902900148), `EUR/GBP_RBV t+1,t+5` = c(0.00313771439501486,
0.00310626895475871, 0.0031789431316576, 0.00305962424370556,
0.00288671182187571, 0.00291630955829613), `EUR/GBP_RV t+1` = c(0.00401994700051122,
0.00407732180013827, 0.00466624428620966, 0.00458235106134663,
0.00395107145155152, 0.00554932910921084), `EUR/GBP_RGV t+1` = c(0.00280067842079775,
0.00275522601341373, 0.00296142025653418, 0.00320716195737542,
0.00266141804235125, 0.00440970289025837), `EUR/GBP_RBV t+1` = c(0.00288377777753365,
0.00300554199386584, 0.00360608177982326, 0.00327292734850446,
0.0029202430753471, 0.00336891287836027), `EUR/GBP_RV` = c(0.00446710941914797,
0.00401994700051122, 0.00407732180013827, 0.00466624428620966,
0.00458235106134663, 0.00482454749708351), `EUR/GBP_RV_5` = c(0.00499598016427624,
0.00470474196716823, 0.00456452150727461, 0.00453292965488229,
0.00436259471347075, 0.00442030721926592), `EUR/GBP_RV_22` = c(0.00515060219897263,
0.00509920878086075, 0.00502079002092667, 0.00501107755050095,
0.00499963428727425, 0.00495435807685843), `EUR/GBP_RBV` = c(0.00324667045338159,
0.00288377777753365, 0.00300554199386584, 0.00360608177982326,
0.00327292734850446, 0.00272655057625291), `EUR/GBP_RBV_5` = c(0.0034985439252634,
0.00318731350301598, 0.00319529774619179, 0.0032799330165155,
0.00320299987062176, 0.00310626895475871), `EUR/GBP_RBV_22` = c(0.0036581887941976,
0.00362298829344015, 0.00355498498935768, 0.0035465419934449,
0.00355752455210586, 0.00351669973034298), `EUR/GBP_RGV` = c(0.00306825643155514,
0.00280067842079775, 0.00275522601341373, 0.00296142025653418,
0.00320716195737542, 0.00398022367546721), `EUR/GBP_RGV_5` = c(0.00353290218424469,
0.00345194162523714, 0.00325362896209417, 0.00312087362386985,
0.00295854861593525, 0.00311308998902836), `EUR/GBP_RGV_22` = c(0.00359974659692405,
0.00356342531619103, 0.00352224165959556, 0.00351722666683608,
0.00349184335907274, 0.00346394410318992), `EUR/GBP_TotalCount` = structure(c(-0.179518680545716,
-0.0757259172924681, 0.333514120677483, 0.759064450015801, -0.419724789788948,
-0.360414639358521), .Dim = c(6L, 1L)), `EUR/GBP_BloombergCount` = structure(c(-0.701694550941621,
-0.669811381311996, -0.574161872423118, -0.644304845608295, -0.784590791978649,
-0.631551577756444), .Dim = c(6L, 1L)), `EUR/GBP_SocialMediaCount` = structure(c(-1.68861759789696,
-1.66829994393287, -1.5910928588693, -1.59515638966212, -1.6967446594826,
-1.63172816679749), .Dim = c(6L, 1L)), `EUR/GBP_NewsCount` = structure(c(0.76560533722738,
0.879161625683434, 1.33717198912285, 1.90306082659552, 0.487392430510049,
0.487392430510049), .Dim = c(6L, 1L))), na.action = structure(c(`6` = 6L,
`38` = 38L, `74` = 74L, `101` = 101L, `140` = 140L, `165` = 165L,
`189` = 189L, `197` = 197L, `236` = 236L, `256` = 256L, `323` = 323L,
`351` = 351L, `393` = 393L, `423` = 423L, `442` = 442L, `455` = 455L,
`490` = 490L, `510` = 510L, `551` = 551L, `576` = 576L, `605` = 605L,
`646` = 646L, `676` = 676L, `696` = 696L, `708` = 708L, `742` = 742L,
`762` = 762L, `793` = 793L, `829` = 829L, `858` = 858L, `904` = 904L,
`929` = 929L, `950` = 950L, `961` = 961L, `996` = 996L, `1016` = 1016L,
`1089` = 1089L, `1114` = 1114L, `1159` = 1159L, `1184` = 1184L,
`1207` = 1207L, `1216` = 1216L, `1238` = 1238L, `1243` = 1243L,
`1253` = 1253L, `1278` = 1278L, `1315` = 1315L, `1346` = 1346L,
`1372` = 1372L, `1416` = 1416L, `1441` = 1441L, `1473` = 1473L,
`1532` = 1532L, `1599` = 1599L, `1626` = 1626L, `1669` = 1669L,
`1694` = 1694L, `1718` = 1718L, `1726` = 1726L, `1766` = 1766L,
`1786` = 1786L, `1827` = 1827L, `1853` = 1853L, `1881` = 1881L,
`1922` = 1922L, `1952` = 1952L, `1971` = 1971L, `1984` = 1984L,
`2019` = 2019L, `2039` = 2039L, `2075` = 2075L, `2106` = 2106L,
`2135` = 2135L, `2181` = 2181L, `2206` = 2206L, `2227` = 2227L,
`2238` = 2238L, `2273` = 2273L, `2293` = 2293L, `2325` = 2325L,
`2366` = 2366L, `2391` = 2391L, `2436` = 2436L, `2461` = 2461L,
`2483` = 2483L, `2493` = 2493L), class = "omit"), row.names = c(1L,
2L, 3L, 4L, 5L, 7L), class = "data.frame")
I have built 9 regression models per forecast horizon (t+1, t+5 and t+22) and I am using the predict function to make my forecasts. I have coded this in an R loop, where I also try to assign each forecast to a matrix. My code is the following:
EUR/GBP_RGV_22`+data.estimateI am trying to calculate realized volatility forecasts using a rolling window forecast. My aim is to use the first 500 observations to forecast the 501st observations, then shift the window forward one step using observations 2 to 501 to predict the 502nd observation. I want this to repeat until I have a complete pseudo out-of-sample forecast.
My df contains 2411 observations of 23 variables, here is small example:
Date
EUR/GBP_RV t+1
EUR/GBP_RV
EUR/GBP_RV_5
EUR/GBP_RV_22
2012-02-13
0.004019947
0.004467109
0.004995980
0.005150602
2012-02-14
0.004077322
0.004019947
0.004704742
0.005099209
2012-02-15
0.004666244
0.004077322
0.004564522
0.005020790
2012-02-16
0.004582351
0.004666244
0.004532930
0.005011078
2012-02-17
0.003951071
0.004582351
0.004362595
0.004999634
2012-02-21
0.005549329
0.004824547
0.004467109
0.004954358
The head of the df can be reproduced with
structure(list(Date = structure(c(15383, 15384, 15385, 15386,
15387, 15391), class = "Date"), `EUR/GBP_RV t+1,t+22` = c(0.00437808494654599,
0.00439764887779732, 0.00441997330738947, 0.00437799055732722,
0.00435021150904479, 0.00434881306458859), `EUR/GBP_RGV t+1,t+22` = c(0.00310674728131117,
0.00311502965608506, 0.00313756204195853, 0.00312923997431178,
0.00310846773074243, 0.00309755540903969), `EUR/GBP_RBV t+1,t+22` = c(0.00304961980133602,
0.00306866297401415, 0.00307794319983677, 0.00302801249035602,
0.00300946121851254, 0.00302272755554915), `EUR/GBP_RV t+1,t+5` = c(0.00425938711995146,
0.00442030721926592, 0.00471470868108043, 0.00487869292442023,
0.00476849421943949, 0.0046067439660438), `EUR/GBP_RGV t+1,t+5` = c(0.00287718093809447,
0.00311308998902836, 0.00344398536439729, 0.00376911066284235,
0.00377425759242542, 0.00353909902900148), `EUR/GBP_RBV t+1,t+5` = c(0.00313771439501486,
0.00310626895475871, 0.0031789431316576, 0.00305962424370556,
0.00288671182187571, 0.00291630955829613), `EUR/GBP_RV t+1` = c(0.00401994700051122,
0.00407732180013827, 0.00466624428620966, 0.00458235106134663,
0.00395107145155152, 0.00554932910921084), `EUR/GBP_RGV t+1` = c(0.00280067842079775,
0.00275522601341373, 0.00296142025653418, 0.00320716195737542,
0.00266141804235125, 0.00440970289025837), `EUR/GBP_RBV t+1` = c(0.00288377777753365,
0.00300554199386584, 0.00360608177982326, 0.00327292734850446,
0.0029202430753471, 0.00336891287836027), `EUR/GBP_RV` = c(0.00446710941914797,
0.00401994700051122, 0.00407732180013827, 0.00466624428620966,
0.00458235106134663, 0.00482454749708351), `EUR/GBP_RV_5` = c(0.00499598016427624,
0.00470474196716823, 0.00456452150727461, 0.00453292965488229,
0.00436259471347075, 0.00442030721926592), `EUR/GBP_RV_22` = c(0.00515060219897263,
0.00509920878086075, 0.00502079002092667, 0.00501107755050095,
0.00499963428727425, 0.00495435807685843), `EUR/GBP_RBV` = c(0.00324667045338159,
0.00288377777753365, 0.00300554199386584, 0.00360608177982326,
0.00327292734850446, 0.00272655057625291), `EUR/GBP_RBV_5` = c(0.0034985439252634,
0.00318731350301598, 0.00319529774619179, 0.0032799330165155,
0.00320299987062176, 0.00310626895475871), `EUR/GBP_RBV_22` = c(0.0036581887941976,
0.00362298829344015, 0.00355498498935768, 0.0035465419934449,
0.00355752455210586, 0.00351669973034298), `EUR/GBP_RGV` = c(0.00306825643155514,
0.00280067842079775, 0.00275522601341373, 0.00296142025653418,
0.00320716195737542, 0.00398022367546721), `EUR/GBP_RGV_5` = c(0.00353290218424469,
0.00345194162523714, 0.00325362896209417, 0.00312087362386985,
0.00295854861593525, 0.00311308998902836), `EUR/GBP_RGV_22` = c(0.00359974659692405,
0.00356342531619103, 0.00352224165959556, 0.00351722666683608,
0.00349184335907274, 0.00346394410318992), `EUR/GBP_TotalCount` = structure(c(-0.179518680545716,
-0.0757259172924681, 0.333514120677483, 0.759064450015801, -0.419724789788948,
-0.360414639358521), .Dim = c(6L, 1L)), `EUR/GBP_BloombergCount` = structure(c(-0.701694550941621,
-0.669811381311996, -0.574161872423118, -0.644304845608295, -0.784590791978649,
-0.631551577756444), .Dim = c(6L, 1L)), `EUR/GBP_SocialMediaCount` = structure(c(-1.68861759789696,
-1.66829994393287, -1.5910928588693, -1.59515638966212, -1.6967446594826,
-1.63172816679749), .Dim = c(6L, 1L)), `EUR/GBP_NewsCount` = structure(c(0.76560533722738,
0.879161625683434, 1.33717198912285, 1.90306082659552, 0.487392430510049,
0.487392430510049), .Dim = c(6L, 1L))), na.action = structure(c(`6` = 6L,
`38` = 38L, `74` = 74L, `101` = 101L, `140` = 140L, `165` = 165L,
`189` = 189L, `197` = 197L, `236` = 236L, `256` = 256L, `323` = 323L,
`351` = 351L, `393` = 393L, `423` = 423L, `442` = 442L, `455` = 455L,
`490` = 490L, `510` = 510L, `551` = 551L, `576` = 576L, `605` = 605L,
`646` = 646L, `676` = 676L, `696` = 696L, `708` = 708L, `742` = 742L,
`762` = 762L, `793` = 793L, `829` = 829L, `858` = 858L, `904` = 904L,
`929` = 929L, `950` = 950L, `961` = 961L, `996` = 996L, `1016` = 1016L,
`1089` = 1089L, `1114` = 1114L, `1159` = 1159L, `1184` = 1184L,
`1207` = 1207L, `1216` = 1216L, `1238` = 1238L, `1243` = 1243L,
`1253` = 1253L, `1278` = 1278L, `1315` = 1315L, `1346` = 1346L,
`1372` = 1372L, `1416` = 1416L, `1441` = 1441L, `1473` = 1473L,
`1532` = 1532L, `1599` = 1599L, `1626` = 1626L, `1669` = 1669L,
`1694` = 1694L, `1718` = 1718L, `1726` = 1726L, `1766` = 1766L,
`1786` = 1786L, `1827` = 1827L, `1853` = 1853L, `1881` = 1881L,
`1922` = 1922L, `1952` = 1952L, `1971` = 1971L, `1984` = 1984L,
`2019` = 2019L, `2039` = 2039L, `2075` = 2075L, `2106` = 2106L,
`2135` = 2135L, `2181` = 2181L, `2206` = 2206L, `2227` = 2227L,
`2238` = 2238L, `2273` = 2273L, `2293` = 2293L, `2325` = 2325L,
`2366` = 2366L, `2391` = 2391L, `2436` = 2436L, `2461` = 2461L,
`2483` = 2483L, `2493` = 2493L), class = "omit"), row.names = c(1L,
2L, 3L, 4L, 5L, 7L), class = "data.frame")
I have built 9 regression models per forecast horizon (t+1, t+5 and t+22) and I am using the predict function to make my forecasts. I have coded this in an R loop, where I also try to assign each forecast to a matrix. My code is the following:
EUR/GBP_TotalCount`)
EURGBP_HAR_RVt5_Bloomberg_train <- lm(data.estimateI am trying to calculate realized volatility forecasts using a rolling window forecast. My aim is to use the first 500 observations to forecast the 501st observations, then shift the window forward one step using observations 2 to 501 to predict the 502nd observation. I want this to repeat until I have a complete pseudo out-of-sample forecast.
My df contains 2411 observations of 23 variables, here is small example:
Date
EUR/GBP_RV t+1
EUR/GBP_RV
EUR/GBP_RV_5
EUR/GBP_RV_22
2012-02-13
0.004019947
0.004467109
0.004995980
0.005150602
2012-02-14
0.004077322
0.004019947
0.004704742
0.005099209
2012-02-15
0.004666244
0.004077322
0.004564522
0.005020790
2012-02-16
0.004582351
0.004666244
0.004532930
0.005011078
2012-02-17
0.003951071
0.004582351
0.004362595
0.004999634
2012-02-21
0.005549329
0.004824547
0.004467109
0.004954358
The head of the df can be reproduced with
structure(list(Date = structure(c(15383, 15384, 15385, 15386,
15387, 15391), class = "Date"), `EUR/GBP_RV t+1,t+22` = c(0.00437808494654599,
0.00439764887779732, 0.00441997330738947, 0.00437799055732722,
0.00435021150904479, 0.00434881306458859), `EUR/GBP_RGV t+1,t+22` = c(0.00310674728131117,
0.00311502965608506, 0.00313756204195853, 0.00312923997431178,
0.00310846773074243, 0.00309755540903969), `EUR/GBP_RBV t+1,t+22` = c(0.00304961980133602,
0.00306866297401415, 0.00307794319983677, 0.00302801249035602,
0.00300946121851254, 0.00302272755554915), `EUR/GBP_RV t+1,t+5` = c(0.00425938711995146,
0.00442030721926592, 0.00471470868108043, 0.00487869292442023,
0.00476849421943949, 0.0046067439660438), `EUR/GBP_RGV t+1,t+5` = c(0.00287718093809447,
0.00311308998902836, 0.00344398536439729, 0.00376911066284235,
0.00377425759242542, 0.00353909902900148), `EUR/GBP_RBV t+1,t+5` = c(0.00313771439501486,
0.00310626895475871, 0.0031789431316576, 0.00305962424370556,
0.00288671182187571, 0.00291630955829613), `EUR/GBP_RV t+1` = c(0.00401994700051122,
0.00407732180013827, 0.00466624428620966, 0.00458235106134663,
0.00395107145155152, 0.00554932910921084), `EUR/GBP_RGV t+1` = c(0.00280067842079775,
0.00275522601341373, 0.00296142025653418, 0.00320716195737542,
0.00266141804235125, 0.00440970289025837), `EUR/GBP_RBV t+1` = c(0.00288377777753365,
0.00300554199386584, 0.00360608177982326, 0.00327292734850446,
0.0029202430753471, 0.00336891287836027), `EUR/GBP_RV` = c(0.00446710941914797,
0.00401994700051122, 0.00407732180013827, 0.00466624428620966,
0.00458235106134663, 0.00482454749708351), `EUR/GBP_RV_5` = c(0.00499598016427624,
0.00470474196716823, 0.00456452150727461, 0.00453292965488229,
0.00436259471347075, 0.00442030721926592), `EUR/GBP_RV_22` = c(0.00515060219897263,
0.00509920878086075, 0.00502079002092667, 0.00501107755050095,
0.00499963428727425, 0.00495435807685843), `EUR/GBP_RBV` = c(0.00324667045338159,
0.00288377777753365, 0.00300554199386584, 0.00360608177982326,
0.00327292734850446, 0.00272655057625291), `EUR/GBP_RBV_5` = c(0.0034985439252634,
0.00318731350301598, 0.00319529774619179, 0.0032799330165155,
0.00320299987062176, 0.00310626895475871), `EUR/GBP_RBV_22` = c(0.0036581887941976,
0.00362298829344015, 0.00355498498935768, 0.0035465419934449,
0.00355752455210586, 0.00351669973034298), `EUR/GBP_RGV` = c(0.00306825643155514,
0.00280067842079775, 0.00275522601341373, 0.00296142025653418,
0.00320716195737542, 0.00398022367546721), `EUR/GBP_RGV_5` = c(0.00353290218424469,
0.00345194162523714, 0.00325362896209417, 0.00312087362386985,
0.00295854861593525, 0.00311308998902836), `EUR/GBP_RGV_22` = c(0.00359974659692405,
0.00356342531619103, 0.00352224165959556, 0.00351722666683608,
0.00349184335907274, 0.00346394410318992), `EUR/GBP_TotalCount` = structure(c(-0.179518680545716,
-0.0757259172924681, 0.333514120677483, 0.759064450015801, -0.419724789788948,
-0.360414639358521), .Dim = c(6L, 1L)), `EUR/GBP_BloombergCount` = structure(c(-0.701694550941621,
-0.669811381311996, -0.574161872423118, -0.644304845608295, -0.784590791978649,
-0.631551577756444), .Dim = c(6L, 1L)), `EUR/GBP_SocialMediaCount` = structure(c(-1.68861759789696,
-1.66829994393287, -1.5910928588693, -1.59515638966212, -1.6967446594826,
-1.63172816679749), .Dim = c(6L, 1L)), `EUR/GBP_NewsCount` = structure(c(0.76560533722738,
0.879161625683434, 1.33717198912285, 1.90306082659552, 0.487392430510049,
0.487392430510049), .Dim = c(6L, 1L))), na.action = structure(c(`6` = 6L,
`38` = 38L, `74` = 74L, `101` = 101L, `140` = 140L, `165` = 165L,
`189` = 189L, `197` = 197L, `236` = 236L, `256` = 256L, `323` = 323L,
`351` = 351L, `393` = 393L, `423` = 423L, `442` = 442L, `455` = 455L,
`490` = 490L, `510` = 510L, `551` = 551L, `576` = 576L, `605` = 605L,
`646` = 646L, `676` = 676L, `696` = 696L, `708` = 708L, `742` = 742L,
`762` = 762L, `793` = 793L, `829` = 829L, `858` = 858L, `904` = 904L,
`929` = 929L, `950` = 950L, `961` = 961L, `996` = 996L, `1016` = 1016L,
`1089` = 1089L, `1114` = 1114L, `1159` = 1159L, `1184` = 1184L,
`1207` = 1207L, `1216` = 1216L, `1238` = 1238L, `1243` = 1243L,
`1253` = 1253L, `1278` = 1278L, `1315` = 1315L, `1346` = 1346L,
`1372` = 1372L, `1416` = 1416L, `1441` = 1441L, `1473` = 1473L,
`1532` = 1532L, `1599` = 1599L, `1626` = 1626L, `1669` = 1669L,
`1694` = 1694L, `1718` = 1718L, `1726` = 1726L, `1766` = 1766L,
`1786` = 1786L, `1827` = 1827L, `1853` = 1853L, `1881` = 1881L,
`1922` = 1922L, `1952` = 1952L, `1971` = 1971L, `1984` = 1984L,
`2019` = 2019L, `2039` = 2039L, `2075` = 2075L, `2106` = 2106L,
`2135` = 2135L, `2181` = 2181L, `2206` = 2206L, `2227` = 2227L,
`2238` = 2238L, `2273` = 2273L, `2293` = 2293L, `2325` = 2325L,
`2366` = 2366L, `2391` = 2391L, `2436` = 2436L, `2461` = 2461L,
`2483` = 2483L, `2493` = 2493L), class = "omit"), row.names = c(1L,
2L, 3L, 4L, 5L, 7L), class = "data.frame")
I have built 9 regression models per forecast horizon (t+1, t+5 and t+22) and I am using the predict function to make my forecasts. I have coded this in an R loop, where I also try to assign each forecast to a matrix. My code is the following:
EUR/GBP_RV t+1,t+5`~data.estimateI am trying to calculate realized volatility forecasts using a rolling window forecast. My aim is to use the first 500 observations to forecast the 501st observations, then shift the window forward one step using observations 2 to 501 to predict the 502nd observation. I want this to repeat until I have a complete pseudo out-of-sample forecast.
My df contains 2411 observations of 23 variables, here is small example:
Date
EUR/GBP_RV t+1
EUR/GBP_RV
EUR/GBP_RV_5
EUR/GBP_RV_22
2012-02-13
0.004019947
0.004467109
0.004995980
0.005150602
2012-02-14
0.004077322
0.004019947
0.004704742
0.005099209
2012-02-15
0.004666244
0.004077322
0.004564522
0.005020790
2012-02-16
0.004582351
0.004666244
0.004532930
0.005011078
2012-02-17
0.003951071
0.004582351
0.004362595
0.004999634
2012-02-21
0.005549329
0.004824547
0.004467109
0.004954358
The head of the df can be reproduced with
structure(list(Date = structure(c(15383, 15384, 15385, 15386,
15387, 15391), class = "Date"), `EUR/GBP_RV t+1,t+22` = c(0.00437808494654599,
0.00439764887779732, 0.00441997330738947, 0.00437799055732722,
0.00435021150904479, 0.00434881306458859), `EUR/GBP_RGV t+1,t+22` = c(0.00310674728131117,
0.00311502965608506, 0.00313756204195853, 0.00312923997431178,
0.00310846773074243, 0.00309755540903969), `EUR/GBP_RBV t+1,t+22` = c(0.00304961980133602,
0.00306866297401415, 0.00307794319983677, 0.00302801249035602,
0.00300946121851254, 0.00302272755554915), `EUR/GBP_RV t+1,t+5` = c(0.00425938711995146,
0.00442030721926592, 0.00471470868108043, 0.00487869292442023,
0.00476849421943949, 0.0046067439660438), `EUR/GBP_RGV t+1,t+5` = c(0.00287718093809447,
0.00311308998902836, 0.00344398536439729, 0.00376911066284235,
0.00377425759242542, 0.00353909902900148), `EUR/GBP_RBV t+1,t+5` = c(0.00313771439501486,
0.00310626895475871, 0.0031789431316576, 0.00305962424370556,
0.00288671182187571, 0.00291630955829613), `EUR/GBP_RV t+1` = c(0.00401994700051122,
0.00407732180013827, 0.00466624428620966, 0.00458235106134663,
0.00395107145155152, 0.00554932910921084), `EUR/GBP_RGV t+1` = c(0.00280067842079775,
0.00275522601341373, 0.00296142025653418, 0.00320716195737542,
0.00266141804235125, 0.00440970289025837), `EUR/GBP_RBV t+1` = c(0.00288377777753365,
0.00300554199386584, 0.00360608177982326, 0.00327292734850446,
0.0029202430753471, 0.00336891287836027), `EUR/GBP_RV` = c(0.00446710941914797,
0.00401994700051122, 0.00407732180013827, 0.00466624428620966,
0.00458235106134663, 0.00482454749708351), `EUR/GBP_RV_5` = c(0.00499598016427624,
0.00470474196716823, 0.00456452150727461, 0.00453292965488229,
0.00436259471347075, 0.00442030721926592), `EUR/GBP_RV_22` = c(0.00515060219897263,
0.00509920878086075, 0.00502079002092667, 0.00501107755050095,
0.00499963428727425, 0.00495435807685843), `EUR/GBP_RBV` = c(0.00324667045338159,
0.00288377777753365, 0.00300554199386584, 0.00360608177982326,
0.00327292734850446, 0.00272655057625291), `EUR/GBP_RBV_5` = c(0.0034985439252634,
0.00318731350301598, 0.00319529774619179, 0.0032799330165155,
0.00320299987062176, 0.00310626895475871), `EUR/GBP_RBV_22` = c(0.0036581887941976,
0.00362298829344015, 0.00355498498935768, 0.0035465419934449,
0.00355752455210586, 0.00351669973034298), `EUR/GBP_RGV` = c(0.00306825643155514,
0.00280067842079775, 0.00275522601341373, 0.00296142025653418,
0.00320716195737542, 0.00398022367546721), `EUR/GBP_RGV_5` = c(0.00353290218424469,
0.00345194162523714, 0.00325362896209417, 0.00312087362386985,
0.00295854861593525, 0.00311308998902836), `EUR/GBP_RGV_22` = c(0.00359974659692405,
0.00356342531619103, 0.00352224165959556, 0.00351722666683608,
0.00349184335907274, 0.00346394410318992), `EUR/GBP_TotalCount` = structure(c(-0.179518680545716,
-0.0757259172924681, 0.333514120677483, 0.759064450015801, -0.419724789788948,
-0.360414639358521), .Dim = c(6L, 1L)), `EUR/GBP_BloombergCount` = structure(c(-0.701694550941621,
-0.669811381311996, -0.574161872423118, -0.644304845608295, -0.784590791978649,
-0.631551577756444), .Dim = c(6L, 1L)), `EUR/GBP_SocialMediaCount` = structure(c(-1.68861759789696,
-1.66829994393287, -1.5910928588693, -1.59515638966212, -1.6967446594826,
-1.63172816679749), .Dim = c(6L, 1L)), `EUR/GBP_NewsCount` = structure(c(0.76560533722738,
0.879161625683434, 1.33717198912285, 1.90306082659552, 0.487392430510049,
0.487392430510049), .Dim = c(6L, 1L))), na.action = structure(c(`6` = 6L,
`38` = 38L, `74` = 74L, `101` = 101L, `140` = 140L, `165` = 165L,
`189` = 189L, `197` = 197L, `236` = 236L, `256` = 256L, `323` = 323L,
`351` = 351L, `393` = 393L, `423` = 423L, `442` = 442L, `455` = 455L,
`490` = 490L, `510` = 510L, `551` = 551L, `576` = 576L, `605` = 605L,
`646` = 646L, `676` = 676L, `696` = 696L, `708` = 708L, `742` = 742L,
`762` = 762L, `793` = 793L, `829` = 829L, `858` = 858L, `904` = 904L,
`929` = 929L, `950` = 950L, `961` = 961L, `996` = 996L, `1016` = 1016L,
`1089` = 1089L, `1114` = 1114L, `1159` = 1159L, `1184` = 1184L,
`1207` = 1207L, `1216` = 1216L, `1238` = 1238L, `1243` = 1243L,
`1253` = 1253L, `1278` = 1278L, `1315` = 1315L, `1346` = 1346L,
`1372` = 1372L, `1416` = 1416L, `1441` = 1441L, `1473` = 1473L,
`1532` = 1532L, `1599` = 1599L, `1626` = 1626L, `1669` = 1669L,
`1694` = 1694L, `1718` = 1718L, `1726` = 1726L, `1766` = 1766L,
`1786` = 1786L, `1827` = 1827L, `1853` = 1853L, `1881` = 1881L,
`1922` = 1922L, `1952` = 1952L, `1971` = 1971L, `1984` = 1984L,
`2019` = 2019L, `2039` = 2039L, `2075` = 2075L, `2106` = 2106L,
`2135` = 2135L, `2181` = 2181L, `2206` = 2206L, `2227` = 2227L,
`2238` = 2238L, `2273` = 2273L, `2293` = 2293L, `2325` = 2325L,
`2366` = 2366L, `2391` = 2391L, `2436` = 2436L, `2461` = 2461L,
`2483` = 2483L, `2493` = 2493L), class = "omit"), row.names = c(1L,
2L, 3L, 4L, 5L, 7L), class = "data.frame")
I have built 9 regression models per forecast horizon (t+1, t+5 and t+22) and I am using the predict function to make my forecasts. I have coded this in an R loop, where I also try to assign each forecast to a matrix. My code is the following:
EUR/GBP_RV`+data.estimateI am trying to calculate realized volatility forecasts using a rolling window forecast. My aim is to use the first 500 observations to forecast the 501st observations, then shift the window forward one step using observations 2 to 501 to predict the 502nd observation. I want this to repeat until I have a complete pseudo out-of-sample forecast.
My df contains 2411 observations of 23 variables, here is small example:
Date
EUR/GBP_RV t+1
EUR/GBP_RV
EUR/GBP_RV_5
EUR/GBP_RV_22
2012-02-13
0.004019947
0.004467109
0.004995980
0.005150602
2012-02-14
0.004077322
0.004019947
0.004704742
0.005099209
2012-02-15
0.004666244
0.004077322
0.004564522
0.005020790
2012-02-16
0.004582351
0.004666244
0.004532930
0.005011078
2012-02-17
0.003951071
0.004582351
0.004362595
0.004999634
2012-02-21
0.005549329
0.004824547
0.004467109
0.004954358
The head of the df can be reproduced with
structure(list(Date = structure(c(15383, 15384, 15385, 15386,
15387, 15391), class = "Date"), `EUR/GBP_RV t+1,t+22` = c(0.00437808494654599,
0.00439764887779732, 0.00441997330738947, 0.00437799055732722,
0.00435021150904479, 0.00434881306458859), `EUR/GBP_RGV t+1,t+22` = c(0.00310674728131117,
0.00311502965608506, 0.00313756204195853, 0.00312923997431178,
0.00310846773074243, 0.00309755540903969), `EUR/GBP_RBV t+1,t+22` = c(0.00304961980133602,
0.00306866297401415, 0.00307794319983677, 0.00302801249035602,
0.00300946121851254, 0.00302272755554915), `EUR/GBP_RV t+1,t+5` = c(0.00425938711995146,
0.00442030721926592, 0.00471470868108043, 0.00487869292442023,
0.00476849421943949, 0.0046067439660438), `EUR/GBP_RGV t+1,t+5` = c(0.00287718093809447,
0.00311308998902836, 0.00344398536439729, 0.00376911066284235,
0.00377425759242542, 0.00353909902900148), `EUR/GBP_RBV t+1,t+5` = c(0.00313771439501486,
0.00310626895475871, 0.0031789431316576, 0.00305962424370556,
0.00288671182187571, 0.00291630955829613), `EUR/GBP_RV t+1` = c(0.00401994700051122,
0.00407732180013827, 0.00466624428620966, 0.00458235106134663,
0.00395107145155152, 0.00554932910921084), `EUR/GBP_RGV t+1` = c(0.00280067842079775,
0.00275522601341373, 0.00296142025653418, 0.00320716195737542,
0.00266141804235125, 0.00440970289025837), `EUR/GBP_RBV t+1` = c(0.00288377777753365,
0.00300554199386584, 0.00360608177982326, 0.00327292734850446,
0.0029202430753471, 0.00336891287836027), `EUR/GBP_RV` = c(0.00446710941914797,
0.00401994700051122, 0.00407732180013827, 0.00466624428620966,
0.00458235106134663, 0.00482454749708351), `EUR/GBP_RV_5` = c(0.00499598016427624,
0.00470474196716823, 0.00456452150727461, 0.00453292965488229,
0.00436259471347075, 0.00442030721926592), `EUR/GBP_RV_22` = c(0.00515060219897263,
0.00509920878086075, 0.00502079002092667, 0.00501107755050095,
0.00499963428727425, 0.00495435807685843), `EUR/GBP_RBV` = c(0.00324667045338159,
0.00288377777753365, 0.00300554199386584, 0.00360608177982326,
0.00327292734850446, 0.00272655057625291), `EUR/GBP_RBV_5` = c(0.0034985439252634,
0.00318731350301598, 0.00319529774619179, 0.0032799330165155,
0.00320299987062176, 0.00310626895475871), `EUR/GBP_RBV_22` = c(0.0036581887941976,
0.00362298829344015, 0.00355498498935768, 0.0035465419934449,
0.00355752455210586, 0.00351669973034298), `EUR/GBP_RGV` = c(0.00306825643155514,
0.00280067842079775, 0.00275522601341373, 0.00296142025653418,
0.00320716195737542, 0.00398022367546721), `EUR/GBP_RGV_5` = c(0.00353290218424469,
0.00345194162523714, 0.00325362896209417, 0.00312087362386985,
0.00295854861593525, 0.00311308998902836), `EUR/GBP_RGV_22` = c(0.00359974659692405,
0.00356342531619103, 0.00352224165959556, 0.00351722666683608,
0.00349184335907274, 0.00346394410318992), `EUR/GBP_TotalCount` = structure(c(-0.179518680545716,
-0.0757259172924681, 0.333514120677483, 0.759064450015801, -0.419724789788948,
-0.360414639358521), .Dim = c(6L, 1L)), `EUR/GBP_BloombergCount` = structure(c(-0.701694550941621,
-0.669811381311996, -0.574161872423118, -0.644304845608295, -0.784590791978649,
-0.631551577756444), .Dim = c(6L, 1L)), `EUR/GBP_SocialMediaCount` = structure(c(-1.68861759789696,
-1.66829994393287, -1.5910928588693, -1.59515638966212, -1.6967446594826,
-1.63172816679749), .Dim = c(6L, 1L)), `EUR/GBP_NewsCount` = structure(c(0.76560533722738,
0.879161625683434, 1.33717198912285, 1.90306082659552, 0.487392430510049,
0.487392430510049), .Dim = c(6L, 1L))), na.action = structure(c(`6` = 6L,
`38` = 38L, `74` = 74L, `101` = 101L, `140` = 140L, `165` = 165L,
`189` = 189L, `197` = 197L, `236` = 236L, `256` = 256L, `323` = 323L,
`351` = 351L, `393` = 393L, `423` = 423L, `442` = 442L, `455` = 455L,
`490` = 490L, `510` = 510L, `551` = 551L, `576` = 576L, `605` = 605L,
`646` = 646L, `676` = 676L, `696` = 696L, `708` = 708L, `742` = 742L,
`762` = 762L, `793` = 793L, `829` = 829L, `858` = 858L, `904` = 904L,
`929` = 929L, `950` = 950L, `961` = 961L, `996` = 996L, `1016` = 1016L,
`1089` = 1089L, `1114` = 1114L, `1159` = 1159L, `1184` = 1184L,
`1207` = 1207L, `1216` = 1216L, `1238` = 1238L, `1243` = 1243L,
`1253` = 1253L, `1278` = 1278L, `1315` = 1315L, `1346` = 1346L,
`1372` = 1372L, `1416` = 1416L, `1441` = 1441L, `1473` = 1473L,
`1532` = 1532L, `1599` = 1599L, `1626` = 1626L, `1669` = 1669L,
`1694` = 1694L, `1718` = 1718L, `1726` = 1726L, `1766` = 1766L,
`1786` = 1786L, `1827` = 1827L, `1853` = 1853L, `1881` = 1881L,
`1922` = 1922L, `1952` = 1952L, `1971` = 1971L, `1984` = 1984L,
`2019` = 2019L, `2039` = 2039L, `2075` = 2075L, `2106` = 2106L,
`2135` = 2135L, `2181` = 2181L, `2206` = 2206L, `2227` = 2227L,
`2238` = 2238L, `2273` = 2273L, `2293` = 2293L, `2325` = 2325L,
`2366` = 2366L, `2391` = 2391L, `2436` = 2436L, `2461` = 2461L,
`2483` = 2483L, `2493` = 2493L), class = "omit"), row.names = c(1L,
2L, 3L, 4L, 5L, 7L), class = "data.frame")
I have built 9 regression models per forecast horizon (t+1, t+5 and t+22) and I am using the predict function to make my forecasts. I have coded this in an R loop, where I also try to assign each forecast to a matrix. My code is the following:
EUR/GBP_RV_5`+data.estimateI am trying to calculate realized volatility forecasts using a rolling window forecast. My aim is to use the first 500 observations to forecast the 501st observations, then shift the window forward one step using observations 2 to 501 to predict the 502nd observation. I want this to repeat until I have a complete pseudo out-of-sample forecast.
My df contains 2411 observations of 23 variables, here is small example:
Date
EUR/GBP_RV t+1
EUR/GBP_RV
EUR/GBP_RV_5
EUR/GBP_RV_22
2012-02-13
0.004019947
0.004467109
0.004995980
0.005150602
2012-02-14
0.004077322
0.004019947
0.004704742
0.005099209
2012-02-15
0.004666244
0.004077322
0.004564522
0.005020790
2012-02-16
0.004582351
0.004666244
0.004532930
0.005011078
2012-02-17
0.003951071
0.004582351
0.004362595
0.004999634
2012-02-21
0.005549329
0.004824547
0.004467109
0.004954358
The head of the df can be reproduced with
structure(list(Date = structure(c(15383, 15384, 15385, 15386,
15387, 15391), class = "Date"), `EUR/GBP_RV t+1,t+22` = c(0.00437808494654599,
0.00439764887779732, 0.00441997330738947, 0.00437799055732722,
0.00435021150904479, 0.00434881306458859), `EUR/GBP_RGV t+1,t+22` = c(0.00310674728131117,
0.00311502965608506, 0.00313756204195853, 0.00312923997431178,
0.00310846773074243, 0.00309755540903969), `EUR/GBP_RBV t+1,t+22` = c(0.00304961980133602,
0.00306866297401415, 0.00307794319983677, 0.00302801249035602,
0.00300946121851254, 0.00302272755554915), `EUR/GBP_RV t+1,t+5` = c(0.00425938711995146,
0.00442030721926592, 0.00471470868108043, 0.00487869292442023,
0.00476849421943949, 0.0046067439660438), `EUR/GBP_RGV t+1,t+5` = c(0.00287718093809447,
0.00311308998902836, 0.00344398536439729, 0.00376911066284235,
0.00377425759242542, 0.00353909902900148), `EUR/GBP_RBV t+1,t+5` = c(0.00313771439501486,
0.00310626895475871, 0.0031789431316576, 0.00305962424370556,
0.00288671182187571, 0.00291630955829613), `EUR/GBP_RV t+1` = c(0.00401994700051122,
0.00407732180013827, 0.00466624428620966, 0.00458235106134663,
0.00395107145155152, 0.00554932910921084), `EUR/GBP_RGV t+1` = c(0.00280067842079775,
0.00275522601341373, 0.00296142025653418, 0.00320716195737542,
0.00266141804235125, 0.00440970289025837), `EUR/GBP_RBV t+1` = c(0.00288377777753365,
0.00300554199386584, 0.00360608177982326, 0.00327292734850446,
0.0029202430753471, 0.00336891287836027), `EUR/GBP_RV` = c(0.00446710941914797,
0.00401994700051122, 0.00407732180013827, 0.00466624428620966,
0.00458235106134663, 0.00482454749708351), `EUR/GBP_RV_5` = c(0.00499598016427624,
0.00470474196716823, 0.00456452150727461, 0.00453292965488229,
0.00436259471347075, 0.00442030721926592), `EUR/GBP_RV_22` = c(0.00515060219897263,
0.00509920878086075, 0.00502079002092667, 0.00501107755050095,
0.00499963428727425, 0.00495435807685843), `EUR/GBP_RBV` = c(0.00324667045338159,
0.00288377777753365, 0.00300554199386584, 0.00360608177982326,
0.00327292734850446, 0.00272655057625291), `EUR/GBP_RBV_5` = c(0.0034985439252634,
0.00318731350301598, 0.00319529774619179, 0.0032799330165155,
0.00320299987062176, 0.00310626895475871), `EUR/GBP_RBV_22` = c(0.0036581887941976,
0.00362298829344015, 0.00355498498935768, 0.0035465419934449,
0.00355752455210586, 0.00351669973034298), `EUR/GBP_RGV` = c(0.00306825643155514,
0.00280067842079775, 0.00275522601341373, 0.00296142025653418,
0.00320716195737542, 0.00398022367546721), `EUR/GBP_RGV_5` = c(0.00353290218424469,
0.00345194162523714, 0.00325362896209417, 0.00312087362386985,
0.00295854861593525, 0.00311308998902836), `EUR/GBP_RGV_22` = c(0.00359974659692405,
0.00356342531619103, 0.00352224165959556, 0.00351722666683608,
0.00349184335907274, 0.00346394410318992), `EUR/GBP_TotalCount` = structure(c(-0.179518680545716,
-0.0757259172924681, 0.333514120677483, 0.759064450015801, -0.419724789788948,
-0.360414639358521), .Dim = c(6L, 1L)), `EUR/GBP_BloombergCount` = structure(c(-0.701694550941621,
-0.669811381311996, -0.574161872423118, -0.644304845608295, -0.784590791978649,
-0.631551577756444), .Dim = c(6L, 1L)), `EUR/GBP_SocialMediaCount` = structure(c(-1.68861759789696,
-1.66829994393287, -1.5910928588693, -1.59515638966212, -1.6967446594826,
-1.63172816679749), .Dim = c(6L, 1L)), `EUR/GBP_NewsCount` = structure(c(0.76560533722738,
0.879161625683434, 1.33717198912285, 1.90306082659552, 0.487392430510049,
0.487392430510049), .Dim = c(6L, 1L))), na.action = structure(c(`6` = 6L,
`38` = 38L, `74` = 74L, `101` = 101L, `140` = 140L, `165` = 165L,
`189` = 189L, `197` = 197L, `236` = 236L, `256` = 256L, `323` = 323L,
`351` = 351L, `393` = 393L, `423` = 423L, `442` = 442L, `455` = 455L,
`490` = 490L, `510` = 510L, `551` = 551L, `576` = 576L, `605` = 605L,
`646` = 646L, `676` = 676L, `696` = 696L, `708` = 708L, `742` = 742L,
`762` = 762L, `793` = 793L, `829` = 829L, `858` = 858L, `904` = 904L,
`929` = 929L, `950` = 950L, `961` = 961L, `996` = 996L, `1016` = 1016L,
`1089` = 1089L, `1114` = 1114L, `1159` = 1159L, `1184` = 1184L,
`1207` = 1207L, `1216` = 1216L, `1238` = 1238L, `1243` = 1243L,
`1253` = 1253L, `1278` = 1278L, `1315` = 1315L, `1346` = 1346L,
`1372` = 1372L, `1416` = 1416L, `1441` = 1441L, `1473` = 1473L,
`1532` = 1532L, `1599` = 1599L, `1626` = 1626L, `1669` = 1669L,
`1694` = 1694L, `1718` = 1718L, `1726` = 1726L, `1766` = 1766L,
`1786` = 1786L, `1827` = 1827L, `1853` = 1853L, `1881` = 1881L,
`1922` = 1922L, `1952` = 1952L, `1971` = 1971L, `1984` = 1984L,
`2019` = 2019L, `2039` = 2039L, `2075` = 2075L, `2106` = 2106L,
`2135` = 2135L, `2181` = 2181L, `2206` = 2206L, `2227` = 2227L,
`2238` = 2238L, `2273` = 2273L, `2293` = 2293L, `2325` = 2325L,
`2366` = 2366L, `2391` = 2391L, `2436` = 2436L, `2461` = 2461L,
`2483` = 2483L, `2493` = 2493L), class = "omit"), row.names = c(1L,
2L, 3L, 4L, 5L, 7L), class = "data.frame")
I have built 9 regression models per forecast horizon (t+1, t+5 and t+22) and I am using the predict function to make my forecasts. I have coded this in an R loop, where I also try to assign each forecast to a matrix. My code is the following:
EUR/GBP_RV_22`+data.estimateI am trying to calculate realized volatility forecasts using a rolling window forecast. My aim is to use the first 500 observations to forecast the 501st observations, then shift the window forward one step using observations 2 to 501 to predict the 502nd observation. I want this to repeat until I have a complete pseudo out-of-sample forecast.
My df contains 2411 observations of 23 variables, here is small example:
Date
EUR/GBP_RV t+1
EUR/GBP_RV
EUR/GBP_RV_5
EUR/GBP_RV_22
2012-02-13
0.004019947
0.004467109
0.004995980
0.005150602
2012-02-14
0.004077322
0.004019947
0.004704742
0.005099209
2012-02-15
0.004666244
0.004077322
0.004564522
0.005020790
2012-02-16
0.004582351
0.004666244
0.004532930
0.005011078
2012-02-17
0.003951071
0.004582351
0.004362595
0.004999634
2012-02-21
0.005549329
0.004824547
0.004467109
0.004954358
The head of the df can be reproduced with
structure(list(Date = structure(c(15383, 15384, 15385, 15386,
15387, 15391), class = "Date"), `EUR/GBP_RV t+1,t+22` = c(0.00437808494654599,
0.00439764887779732, 0.00441997330738947, 0.00437799055732722,
0.00435021150904479, 0.00434881306458859), `EUR/GBP_RGV t+1,t+22` = c(0.00310674728131117,
0.00311502965608506, 0.00313756204195853, 0.00312923997431178,
0.00310846773074243, 0.00309755540903969), `EUR/GBP_RBV t+1,t+22` = c(0.00304961980133602,
0.00306866297401415, 0.00307794319983677, 0.00302801249035602,
0.00300946121851254, 0.00302272755554915), `EUR/GBP_RV t+1,t+5` = c(0.00425938711995146,
0.00442030721926592, 0.00471470868108043, 0.00487869292442023,
0.00476849421943949, 0.0046067439660438), `EUR/GBP_RGV t+1,t+5` = c(0.00287718093809447,
0.00311308998902836, 0.00344398536439729, 0.00376911066284235,
0.00377425759242542, 0.00353909902900148), `EUR/GBP_RBV t+1,t+5` = c(0.00313771439501486,
0.00310626895475871, 0.0031789431316576, 0.00305962424370556,
0.00288671182187571, 0.00291630955829613), `EUR/GBP_RV t+1` = c(0.00401994700051122,
0.00407732180013827, 0.00466624428620966, 0.00458235106134663,
0.00395107145155152, 0.00554932910921084), `EUR/GBP_RGV t+1` = c(0.00280067842079775,
0.00275522601341373, 0.00296142025653418, 0.00320716195737542,
0.00266141804235125, 0.00440970289025837), `EUR/GBP_RBV t+1` = c(0.00288377777753365,
0.00300554199386584, 0.00360608177982326, 0.00327292734850446,
0.0029202430753471, 0.00336891287836027), `EUR/GBP_RV` = c(0.00446710941914797,
0.00401994700051122, 0.00407732180013827, 0.00466624428620966,
0.00458235106134663, 0.00482454749708351), `EUR/GBP_RV_5` = c(0.00499598016427624,
0.00470474196716823, 0.00456452150727461, 0.00453292965488229,
0.00436259471347075, 0.00442030721926592), `EUR/GBP_RV_22` = c(0.00515060219897263,
0.00509920878086075, 0.00502079002092667, 0.00501107755050095,
0.00499963428727425, 0.00495435807685843), `EUR/GBP_RBV` = c(0.00324667045338159,
0.00288377777753365, 0.00300554199386584, 0.00360608177982326,
0.00327292734850446, 0.00272655057625291), `EUR/GBP_RBV_5` = c(0.0034985439252634,
0.00318731350301598, 0.00319529774619179, 0.0032799330165155,
0.00320299987062176, 0.00310626895475871), `EUR/GBP_RBV_22` = c(0.0036581887941976,
0.00362298829344015, 0.00355498498935768, 0.0035465419934449,
0.00355752455210586, 0.00351669973034298), `EUR/GBP_RGV` = c(0.00306825643155514,
0.00280067842079775, 0.00275522601341373, 0.00296142025653418,
0.00320716195737542, 0.00398022367546721), `EUR/GBP_RGV_5` = c(0.00353290218424469,
0.00345194162523714, 0.00325362896209417, 0.00312087362386985,
0.00295854861593525, 0.00311308998902836), `EUR/GBP_RGV_22` = c(0.00359974659692405,
0.00356342531619103, 0.00352224165959556, 0.00351722666683608,
0.00349184335907274, 0.00346394410318992), `EUR/GBP_TotalCount` = structure(c(-0.179518680545716,
-0.0757259172924681, 0.333514120677483, 0.759064450015801, -0.419724789788948,
-0.360414639358521), .Dim = c(6L, 1L)), `EUR/GBP_BloombergCount` = structure(c(-0.701694550941621,
-0.669811381311996, -0.574161872423118, -0.644304845608295, -0.784590791978649,
-0.631551577756444), .Dim = c(6L, 1L)), `EUR/GBP_SocialMediaCount` = structure(c(-1.68861759789696,
-1.66829994393287, -1.5910928588693, -1.59515638966212, -1.6967446594826,
-1.63172816679749), .Dim = c(6L, 1L)), `EUR/GBP_NewsCount` = structure(c(0.76560533722738,
0.879161625683434, 1.33717198912285, 1.90306082659552, 0.487392430510049,
0.487392430510049), .Dim = c(6L, 1L))), na.action = structure(c(`6` = 6L,
`38` = 38L, `74` = 74L, `101` = 101L, `140` = 140L, `165` = 165L,
`189` = 189L, `197` = 197L, `236` = 236L, `256` = 256L, `323` = 323L,
`351` = 351L, `393` = 393L, `423` = 423L, `442` = 442L, `455` = 455L,
`490` = 490L, `510` = 510L, `551` = 551L, `576` = 576L, `605` = 605L,
`646` = 646L, `676` = 676L, `696` = 696L, `708` = 708L, `742` = 742L,
`762` = 762L, `793` = 793L, `829` = 829L, `858` = 858L, `904` = 904L,
`929` = 929L, `950` = 950L, `961` = 961L, `996` = 996L, `1016` = 1016L,
`1089` = 1089L, `1114` = 1114L, `1159` = 1159L, `1184` = 1184L,
`1207` = 1207L, `1216` = 1216L, `1238` = 1238L, `1243` = 1243L,
`1253` = 1253L, `1278` = 1278L, `1315` = 1315L, `1346` = 1346L,
`1372` = 1372L, `1416` = 1416L, `1441` = 1441L, `1473` = 1473L,
`1532` = 1532L, `1599` = 1599L, `1626` = 1626L, `1669` = 1669L,
`1694` = 1694L, `1718` = 1718L, `1726` = 1726L, `1766` = 1766L,
`1786` = 1786L, `1827` = 1827L, `1853` = 1853L, `1881` = 1881L,
`1922` = 1922L, `1952` = 1952L, `1971` = 1971L, `1984` = 1984L,
`2019` = 2019L, `2039` = 2039L, `2075` = 2075L, `2106` = 2106L,
`2135` = 2135L, `2181` = 2181L, `2206` = 2206L, `2227` = 2227L,
`2238` = 2238L, `2273` = 2273L, `2293` = 2293L, `2325` = 2325L,
`2366` = 2366L, `2391` = 2391L, `2436` = 2436L, `2461` = 2461L,
`2483` = 2483L, `2493` = 2493L), class = "omit"), row.names = c(1L,
2L, 3L, 4L, 5L, 7L), class = "data.frame")
I have built 9 regression models per forecast horizon (t+1, t+5 and t+22) and I am using the predict function to make my forecasts. I have coded this in an R loop, where I also try to assign each forecast to a matrix. My code is the following:
EUR/GBP_BloombergCount`)
EURGBP_HAR_RVt5_SocialMedia_train <- lm(data.estimateI am trying to calculate realized volatility forecasts using a rolling window forecast. My aim is to use the first 500 observations to forecast the 501st observations, then shift the window forward one step using observations 2 to 501 to predict the 502nd observation. I want this to repeat until I have a complete pseudo out-of-sample forecast.
My df contains 2411 observations of 23 variables, here is small example:
Date
EUR/GBP_RV t+1
EUR/GBP_RV
EUR/GBP_RV_5
EUR/GBP_RV_22
2012-02-13
0.004019947
0.004467109
0.004995980
0.005150602
2012-02-14
0.004077322
0.004019947
0.004704742
0.005099209
2012-02-15
0.004666244
0.004077322
0.004564522
0.005020790
2012-02-16
0.004582351
0.004666244
0.004532930
0.005011078
2012-02-17
0.003951071
0.004582351
0.004362595
0.004999634
2012-02-21
0.005549329
0.004824547
0.004467109
0.004954358
The head of the df can be reproduced with
structure(list(Date = structure(c(15383, 15384, 15385, 15386,
15387, 15391), class = "Date"), `EUR/GBP_RV t+1,t+22` = c(0.00437808494654599,
0.00439764887779732, 0.00441997330738947, 0.00437799055732722,
0.00435021150904479, 0.00434881306458859), `EUR/GBP_RGV t+1,t+22` = c(0.00310674728131117,
0.00311502965608506, 0.00313756204195853, 0.00312923997431178,
0.00310846773074243, 0.00309755540903969), `EUR/GBP_RBV t+1,t+22` = c(0.00304961980133602,
0.00306866297401415, 0.00307794319983677, 0.00302801249035602,
0.00300946121851254, 0.00302272755554915), `EUR/GBP_RV t+1,t+5` = c(0.00425938711995146,
0.00442030721926592, 0.00471470868108043, 0.00487869292442023,
0.00476849421943949, 0.0046067439660438), `EUR/GBP_RGV t+1,t+5` = c(0.00287718093809447,
0.00311308998902836, 0.00344398536439729, 0.00376911066284235,
0.00377425759242542, 0.00353909902900148), `EUR/GBP_RBV t+1,t+5` = c(0.00313771439501486,
0.00310626895475871, 0.0031789431316576, 0.00305962424370556,
0.00288671182187571, 0.00291630955829613), `EUR/GBP_RV t+1` = c(0.00401994700051122,
0.00407732180013827, 0.00466624428620966, 0.00458235106134663,
0.00395107145155152, 0.00554932910921084), `EUR/GBP_RGV t+1` = c(0.00280067842079775,
0.00275522601341373, 0.00296142025653418, 0.00320716195737542,
0.00266141804235125, 0.00440970289025837), `EUR/GBP_RBV t+1` = c(0.00288377777753365,
0.00300554199386584, 0.00360608177982326, 0.00327292734850446,
0.0029202430753471, 0.00336891287836027), `EUR/GBP_RV` = c(0.00446710941914797,
0.00401994700051122, 0.00407732180013827, 0.00466624428620966,
0.00458235106134663, 0.00482454749708351), `EUR/GBP_RV_5` = c(0.00499598016427624,
0.00470474196716823, 0.00456452150727461, 0.00453292965488229,
0.00436259471347075, 0.00442030721926592), `EUR/GBP_RV_22` = c(0.00515060219897263,
0.00509920878086075, 0.00502079002092667, 0.00501107755050095,
0.00499963428727425, 0.00495435807685843), `EUR/GBP_RBV` = c(0.00324667045338159,
0.00288377777753365, 0.00300554199386584, 0.00360608177982326,
0.00327292734850446, 0.00272655057625291), `EUR/GBP_RBV_5` = c(0.0034985439252634,
0.00318731350301598, 0.00319529774619179, 0.0032799330165155,
0.00320299987062176, 0.00310626895475871), `EUR/GBP_RBV_22` = c(0.0036581887941976,
0.00362298829344015, 0.00355498498935768, 0.0035465419934449,
0.00355752455210586, 0.00351669973034298), `EUR/GBP_RGV` = c(0.00306825643155514,
0.00280067842079775, 0.00275522601341373, 0.00296142025653418,
0.00320716195737542, 0.00398022367546721), `EUR/GBP_RGV_5` = c(0.00353290218424469,
0.00345194162523714, 0.00325362896209417, 0.00312087362386985,
0.00295854861593525, 0.00311308998902836), `EUR/GBP_RGV_22` = c(0.00359974659692405,
0.00356342531619103, 0.00352224165959556, 0.00351722666683608,
0.00349184335907274, 0.00346394410318992), `EUR/GBP_TotalCount` = structure(c(-0.179518680545716,
-0.0757259172924681, 0.333514120677483, 0.759064450015801, -0.419724789788948,
-0.360414639358521), .Dim = c(6L, 1L)), `EUR/GBP_BloombergCount` = structure(c(-0.701694550941621,
-0.669811381311996, -0.574161872423118, -0.644304845608295, -0.784590791978649,
-0.631551577756444), .Dim = c(6L, 1L)), `EUR/GBP_SocialMediaCount` = structure(c(-1.68861759789696,
-1.66829994393287, -1.5910928588693, -1.59515638966212, -1.6967446594826,
-1.63172816679749), .Dim = c(6L, 1L)), `EUR/GBP_NewsCount` = structure(c(0.76560533722738,
0.879161625683434, 1.33717198912285, 1.90306082659552, 0.487392430510049,
0.487392430510049), .Dim = c(6L, 1L))), na.action = structure(c(`6` = 6L,
`38` = 38L, `74` = 74L, `101` = 101L, `140` = 140L, `165` = 165L,
`189` = 189L, `197` = 197L, `236` = 236L, `256` = 256L, `323` = 323L,
`351` = 351L, `393` = 393L, `423` = 423L, `442` = 442L, `455` = 455L,
`490` = 490L, `510` = 510L, `551` = 551L, `576` = 576L, `605` = 605L,
`646` = 646L, `676` = 676L, `696` = 696L, `708` = 708L, `742` = 742L,
`762` = 762L, `793` = 793L, `829` = 829L, `858` = 858L, `904` = 904L,
`929` = 929L, `950` = 950L, `961` = 961L, `996` = 996L, `1016` = 1016L,
`1089` = 1089L, `1114` = 1114L, `1159` = 1159L, `1184` = 1184L,
`1207` = 1207L, `1216` = 1216L, `1238` = 1238L, `1243` = 1243L,
`1253` = 1253L, `1278` = 1278L, `1315` = 1315L, `1346` = 1346L,
`1372` = 1372L, `1416` = 1416L, `1441` = 1441L, `1473` = 1473L,
`1532` = 1532L, `1599` = 1599L, `1626` = 1626L, `1669` = 1669L,
`1694` = 1694L, `1718` = 1718L, `1726` = 1726L, `1766` = 1766L,
`1786` = 1786L, `1827` = 1827L, `1853` = 1853L, `1881` = 1881L,
`1922` = 1922L, `1952` = 1952L, `1971` = 1971L, `1984` = 1984L,
`2019` = 2019L, `2039` = 2039L, `2075` = 2075L, `2106` = 2106L,
`2135` = 2135L, `2181` = 2181L, `2206` = 2206L, `2227` = 2227L,
`2238` = 2238L, `2273` = 2273L, `2293` = 2293L, `2325` = 2325L,
`2366` = 2366L, `2391` = 2391L, `2436` = 2436L, `2461` = 2461L,
`2483` = 2483L, `2493` = 2493L), class = "omit"), row.names = c(1L,
2L, 3L, 4L, 5L, 7L), class = "data.frame")
I have built 9 regression models per forecast horizon (t+1, t+5 and t+22) and I am using the predict function to make my forecasts. I have coded this in an R loop, where I also try to assign each forecast to a matrix. My code is the following:
EUR/GBP_RV t+1,t+5`~data.estimateI am trying to calculate realized volatility forecasts using a rolling window forecast. My aim is to use the first 500 observations to forecast the 501st observations, then shift the window forward one step using observations 2 to 501 to predict the 502nd observation. I want this to repeat until I have a complete pseudo out-of-sample forecast.
My df contains 2411 observations of 23 variables, here is small example:
Date
EUR/GBP_RV t+1
EUR/GBP_RV
EUR/GBP_RV_5
EUR/GBP_RV_22
2012-02-13
0.004019947
0.004467109
0.004995980
0.005150602
2012-02-14
0.004077322
0.004019947
0.004704742
0.005099209
2012-02-15
0.004666244
0.004077322
0.004564522
0.005020790
2012-02-16
0.004582351
0.004666244
0.004532930
0.005011078
2012-02-17
0.003951071
0.004582351
0.004362595
0.004999634
2012-02-21
0.005549329
0.004824547
0.004467109
0.004954358
The head of the df can be reproduced with
structure(list(Date = structure(c(15383, 15384, 15385, 15386,
15387, 15391), class = "Date"), `EUR/GBP_RV t+1,t+22` = c(0.00437808494654599,
0.00439764887779732, 0.00441997330738947, 0.00437799055732722,
0.00435021150904479, 0.00434881306458859), `EUR/GBP_RGV t+1,t+22` = c(0.00310674728131117,
0.00311502965608506, 0.00313756204195853, 0.00312923997431178,
0.00310846773074243, 0.00309755540903969), `EUR/GBP_RBV t+1,t+22` = c(0.00304961980133602,
0.00306866297401415, 0.00307794319983677, 0.00302801249035602,
0.00300946121851254, 0.00302272755554915), `EUR/GBP_RV t+1,t+5` = c(0.00425938711995146,
0.00442030721926592, 0.00471470868108043, 0.00487869292442023,
0.00476849421943949, 0.0046067439660438), `EUR/GBP_RGV t+1,t+5` = c(0.00287718093809447,
0.00311308998902836, 0.00344398536439729, 0.00376911066284235,
0.00377425759242542, 0.00353909902900148), `EUR/GBP_RBV t+1,t+5` = c(0.00313771439501486,
0.00310626895475871, 0.0031789431316576, 0.00305962424370556,
0.00288671182187571, 0.00291630955829613), `EUR/GBP_RV t+1` = c(0.00401994700051122,
0.00407732180013827, 0.00466624428620966, 0.00458235106134663,
0.00395107145155152, 0.00554932910921084), `EUR/GBP_RGV t+1` = c(0.00280067842079775,
0.00275522601341373, 0.00296142025653418, 0.00320716195737542,
0.00266141804235125, 0.00440970289025837), `EUR/GBP_RBV t+1` = c(0.00288377777753365,
0.00300554199386584, 0.00360608177982326, 0.00327292734850446,
0.0029202430753471, 0.00336891287836027), `EUR/GBP_RV` = c(0.00446710941914797,
0.00401994700051122, 0.00407732180013827, 0.00466624428620966,
0.00458235106134663, 0.00482454749708351), `EUR/GBP_RV_5` = c(0.00499598016427624,
0.00470474196716823, 0.00456452150727461, 0.00453292965488229,
0.00436259471347075, 0.00442030721926592), `EUR/GBP_RV_22` = c(0.00515060219897263,
0.00509920878086075, 0.00502079002092667, 0.00501107755050095,
0.00499963428727425, 0.00495435807685843), `EUR/GBP_RBV` = c(0.00324667045338159,
0.00288377777753365, 0.00300554199386584, 0.00360608177982326,
0.00327292734850446, 0.00272655057625291), `EUR/GBP_RBV_5` = c(0.0034985439252634,
0.00318731350301598, 0.00319529774619179, 0.0032799330165155,
0.00320299987062176, 0.00310626895475871), `EUR/GBP_RBV_22` = c(0.0036581887941976,
0.00362298829344015, 0.00355498498935768, 0.0035465419934449,
0.00355752455210586, 0.00351669973034298), `EUR/GBP_RGV` = c(0.00306825643155514,
0.00280067842079775, 0.00275522601341373, 0.00296142025653418,
0.00320716195737542, 0.00398022367546721), `EUR/GBP_RGV_5` = c(0.00353290218424469,
0.00345194162523714, 0.00325362896209417, 0.00312087362386985,
0.00295854861593525, 0.00311308998902836), `EUR/GBP_RGV_22` = c(0.00359974659692405,
0.00356342531619103, 0.00352224165959556, 0.00351722666683608,
0.00349184335907274, 0.00346394410318992), `EUR/GBP_TotalCount` = structure(c(-0.179518680545716,
-0.0757259172924681, 0.333514120677483, 0.759064450015801, -0.419724789788948,
-0.360414639358521), .Dim = c(6L, 1L)), `EUR/GBP_BloombergCount` = structure(c(-0.701694550941621,
-0.669811381311996, -0.574161872423118, -0.644304845608295, -0.784590791978649,
-0.631551577756444), .Dim = c(6L, 1L)), `EUR/GBP_SocialMediaCount` = structure(c(-1.68861759789696,
-1.66829994393287, -1.5910928588693, -1.59515638966212, -1.6967446594826,
-1.63172816679749), .Dim = c(6L, 1L)), `EUR/GBP_NewsCount` = structure(c(0.76560533722738,
0.879161625683434, 1.33717198912285, 1.90306082659552, 0.487392430510049,
0.487392430510049), .Dim = c(6L, 1L))), na.action = structure(c(`6` = 6L,
`38` = 38L, `74` = 74L, `101` = 101L, `140` = 140L, `165` = 165L,
`189` = 189L, `197` = 197L, `236` = 236L, `256` = 256L, `323` = 323L,
`351` = 351L, `393` = 393L, `423` = 423L, `442` = 442L, `455` = 455L,
`490` = 490L, `510` = 510L, `551` = 551L, `576` = 576L, `605` = 605L,
`646` = 646L, `676` = 676L, `696` = 696L, `708` = 708L, `742` = 742L,
`762` = 762L, `793` = 793L, `829` = 829L, `858` = 858L, `904` = 904L,
`929` = 929L, `950` = 950L, `961` = 961L, `996` = 996L, `1016` = 1016L,
`1089` = 1089L, `1114` = 1114L, `1159` = 1159L, `1184` = 1184L,
`1207` = 1207L, `1216` = 1216L, `1238` = 1238L, `1243` = 1243L,
`1253` = 1253L, `1278` = 1278L, `1315` = 1315L, `1346` = 1346L,
`1372` = 1372L, `1416` = 1416L, `1441` = 1441L, `1473` = 1473L,
`1532` = 1532L, `1599` = 1599L, `1626` = 1626L, `1669` = 1669L,
`1694` = 1694L, `1718` = 1718L, `1726` = 1726L, `1766` = 1766L,
`1786` = 1786L, `1827` = 1827L, `1853` = 1853L, `1881` = 1881L,
`1922` = 1922L, `1952` = 1952L, `1971` = 1971L, `1984` = 1984L,
`2019` = 2019L, `2039` = 2039L, `2075` = 2075L, `2106` = 2106L,
`2135` = 2135L, `2181` = 2181L, `2206` = 2206L, `2227` = 2227L,
`2238` = 2238L, `2273` = 2273L, `2293` = 2293L, `2325` = 2325L,
`2366` = 2366L, `2391` = 2391L, `2436` = 2436L, `2461` = 2461L,
`2483` = 2483L, `2493` = 2493L), class = "omit"), row.names = c(1L,
2L, 3L, 4L, 5L, 7L), class = "data.frame")
I have built 9 regression models per forecast horizon (t+1, t+5 and t+22) and I am using the predict function to make my forecasts. I have coded this in an R loop, where I also try to assign each forecast to a matrix. My code is the following:
EUR/GBP_RV`+data.estimateI am trying to calculate realized volatility forecasts using a rolling window forecast. My aim is to use the first 500 observations to forecast the 501st observations, then shift the window forward one step using observations 2 to 501 to predict the 502nd observation. I want this to repeat until I have a complete pseudo out-of-sample forecast.
My df contains 2411 observations of 23 variables, here is small example:
Date
EUR/GBP_RV t+1
EUR/GBP_RV
EUR/GBP_RV_5
EUR/GBP_RV_22
2012-02-13
0.004019947
0.004467109
0.004995980
0.005150602
2012-02-14
0.004077322
0.004019947
0.004704742
0.005099209
2012-02-15
0.004666244
0.004077322
0.004564522
0.005020790
2012-02-16
0.004582351
0.004666244
0.004532930
0.005011078
2012-02-17
0.003951071
0.004582351
0.004362595
0.004999634
2012-02-21
0.005549329
0.004824547
0.004467109
0.004954358
The head of the df can be reproduced with
structure(list(Date = structure(c(15383, 15384, 15385, 15386,
15387, 15391), class = "Date"), `EUR/GBP_RV t+1,t+22` = c(0.00437808494654599,
0.00439764887779732, 0.00441997330738947, 0.00437799055732722,
0.00435021150904479, 0.00434881306458859), `EUR/GBP_RGV t+1,t+22` = c(0.00310674728131117,
0.00311502965608506, 0.00313756204195853, 0.00312923997431178,
0.00310846773074243, 0.00309755540903969), `EUR/GBP_RBV t+1,t+22` = c(0.00304961980133602,
0.00306866297401415, 0.00307794319983677, 0.00302801249035602,
0.00300946121851254, 0.00302272755554915), `EUR/GBP_RV t+1,t+5` = c(0.00425938711995146,
0.00442030721926592, 0.00471470868108043, 0.00487869292442023,
0.00476849421943949, 0.0046067439660438), `EUR/GBP_RGV t+1,t+5` = c(0.00287718093809447,
0.00311308998902836, 0.00344398536439729, 0.00376911066284235,
0.00377425759242542, 0.00353909902900148), `EUR/GBP_RBV t+1,t+5` = c(0.00313771439501486,
0.00310626895475871, 0.0031789431316576, 0.00305962424370556,
0.00288671182187571, 0.00291630955829613), `EUR/GBP_RV t+1` = c(0.00401994700051122,
0.00407732180013827, 0.00466624428620966, 0.00458235106134663,
0.00395107145155152, 0.00554932910921084), `EUR/GBP_RGV t+1` = c(0.00280067842079775,
0.00275522601341373, 0.00296142025653418, 0.00320716195737542,
0.00266141804235125, 0.00440970289025837), `EUR/GBP_RBV t+1` = c(0.00288377777753365,
0.00300554199386584, 0.00360608177982326, 0.00327292734850446,
0.0029202430753471, 0.00336891287836027), `EUR/GBP_RV` = c(0.00446710941914797,
0.00401994700051122, 0.00407732180013827, 0.00466624428620966,
0.00458235106134663, 0.00482454749708351), `EUR/GBP_RV_5` = c(0.00499598016427624,
0.00470474196716823, 0.00456452150727461, 0.00453292965488229,
0.00436259471347075, 0.00442030721926592), `EUR/GBP_RV_22` = c(0.00515060219897263,
0.00509920878086075, 0.00502079002092667, 0.00501107755050095,
0.00499963428727425, 0.00495435807685843), `EUR/GBP_RBV` = c(0.00324667045338159,
0.00288377777753365, 0.00300554199386584, 0.00360608177982326,
0.00327292734850446, 0.00272655057625291), `EUR/GBP_RBV_5` = c(0.0034985439252634,
0.00318731350301598, 0.00319529774619179, 0.0032799330165155,
0.00320299987062176, 0.00310626895475871), `EUR/GBP_RBV_22` = c(0.0036581887941976,
0.00362298829344015, 0.00355498498935768, 0.0035465419934449,
0.00355752455210586, 0.00351669973034298), `EUR/GBP_RGV` = c(0.00306825643155514,
0.00280067842079775, 0.00275522601341373, 0.00296142025653418,
0.00320716195737542, 0.00398022367546721), `EUR/GBP_RGV_5` = c(0.00353290218424469,
0.00345194162523714, 0.00325362896209417, 0.00312087362386985,
0.00295854861593525, 0.00311308998902836), `EUR/GBP_RGV_22` = c(0.00359974659692405,
0.00356342531619103, 0.00352224165959556, 0.00351722666683608,
0.00349184335907274, 0.00346394410318992), `EUR/GBP_TotalCount` = structure(c(-0.179518680545716,
-0.0757259172924681, 0.333514120677483, 0.759064450015801, -0.419724789788948,
-0.360414639358521), .Dim = c(6L, 1L)), `EUR/GBP_BloombergCount` = structure(c(-0.701694550941621,
-0.669811381311996, -0.574161872423118, -0.644304845608295, -0.784590791978649,
-0.631551577756444), .Dim = c(6L, 1L)), `EUR/GBP_SocialMediaCount` = structure(c(-1.68861759789696,
-1.66829994393287, -1.5910928588693, -1.59515638966212, -1.6967446594826,
-1.63172816679749), .Dim = c(6L, 1L)), `EUR/GBP_NewsCount` = structure(c(0.76560533722738,
0.879161625683434, 1.33717198912285, 1.90306082659552, 0.487392430510049,
0.487392430510049), .Dim = c(6L, 1L))), na.action = structure(c(`6` = 6L,
`38` = 38L, `74` = 74L, `101` = 101L, `140` = 140L, `165` = 165L,
`189` = 189L, `197` = 197L, `236` = 236L, `256` = 256L, `323` = 323L,
`351` = 351L, `393` = 393L, `423` = 423L, `442` = 442L, `455` = 455L,
`490` = 490L, `510` = 510L, `551` = 551L, `576` = 576L, `605` = 605L,
`646` = 646L, `676` = 676L, `696` = 696L, `708` = 708L, `742` = 742L,
`762` = 762L, `793` = 793L, `829` = 829L, `858` = 858L, `904` = 904L,
`929` = 929L, `950` = 950L, `961` = 961L, `996` = 996L, `1016` = 1016L,
`1089` = 1089L, `1114` = 1114L, `1159` = 1159L, `1184` = 1184L,
`1207` = 1207L, `1216` = 1216L, `1238` = 1238L, `1243` = 1243L,
`1253` = 1253L, `1278` = 1278L, `1315` = 1315L, `1346` = 1346L,
`1372` = 1372L, `1416` = 1416L, `1441` = 1441L, `1473` = 1473L,
`1532` = 1532L, `1599` = 1599L, `1626` = 1626L, `1669` = 1669L,
`1694` = 1694L, `1718` = 1718L, `1726` = 1726L, `1766` = 1766L,
`1786` = 1786L, `1827` = 1827L, `1853` = 1853L, `1881` = 1881L,
`1922` = 1922L, `1952` = 1952L, `1971` = 1971L, `1984` = 1984L,
`2019` = 2019L, `2039` = 2039L, `2075` = 2075L, `2106` = 2106L,
`2135` = 2135L, `2181` = 2181L, `2206` = 2206L, `2227` = 2227L,
`2238` = 2238L, `2273` = 2273L, `2293` = 2293L, `2325` = 2325L,
`2366` = 2366L, `2391` = 2391L, `2436` = 2436L, `2461` = 2461L,
`2483` = 2483L, `2493` = 2493L), class = "omit"), row.names = c(1L,
2L, 3L, 4L, 5L, 7L), class = "data.frame")
I have built 9 regression models per forecast horizon (t+1, t+5 and t+22) and I am using the predict function to make my forecasts. I have coded this in an R loop, where I also try to assign each forecast to a matrix. My code is the following:
EUR/GBP_RV_5`+data.estimateI am trying to calculate realized volatility forecasts using a rolling window forecast. My aim is to use the first 500 observations to forecast the 501st observations, then shift the window forward one step using observations 2 to 501 to predict the 502nd observation. I want this to repeat until I have a complete pseudo out-of-sample forecast.
My df contains 2411 observations of 23 variables, here is small example:
Date
EUR/GBP_RV t+1
EUR/GBP_RV
EUR/GBP_RV_5
EUR/GBP_RV_22
2012-02-13
0.004019947
0.004467109
0.004995980
0.005150602
2012-02-14
0.004077322
0.004019947
0.004704742
0.005099209
2012-02-15
0.004666244
0.004077322
0.004564522
0.005020790
2012-02-16
0.004582351
0.004666244
0.004532930
0.005011078
2012-02-17
0.003951071
0.004582351
0.004362595
0.004999634
2012-02-21
0.005549329
0.004824547
0.004467109
0.004954358
The head of the df can be reproduced with
structure(list(Date = structure(c(15383, 15384, 15385, 15386,
15387, 15391), class = "Date"), `EUR/GBP_RV t+1,t+22` = c(0.00437808494654599,
0.00439764887779732, 0.00441997330738947, 0.00437799055732722,
0.00435021150904479, 0.00434881306458859), `EUR/GBP_RGV t+1,t+22` = c(0.00310674728131117,
0.00311502965608506, 0.00313756204195853, 0.00312923997431178,
0.00310846773074243, 0.00309755540903969), `EUR/GBP_RBV t+1,t+22` = c(0.00304961980133602,
0.00306866297401415, 0.00307794319983677, 0.00302801249035602,
0.00300946121851254, 0.00302272755554915), `EUR/GBP_RV t+1,t+5` = c(0.00425938711995146,
0.00442030721926592, 0.00471470868108043, 0.00487869292442023,
0.00476849421943949, 0.0046067439660438), `EUR/GBP_RGV t+1,t+5` = c(0.00287718093809447,
0.00311308998902836, 0.00344398536439729, 0.00376911066284235,
0.00377425759242542, 0.00353909902900148), `EUR/GBP_RBV t+1,t+5` = c(0.00313771439501486,
0.00310626895475871, 0.0031789431316576, 0.00305962424370556,
0.00288671182187571, 0.00291630955829613), `EUR/GBP_RV t+1` = c(0.00401994700051122,
0.00407732180013827, 0.00466624428620966, 0.00458235106134663,
0.00395107145155152, 0.00554932910921084), `EUR/GBP_RGV t+1` = c(0.00280067842079775,
0.00275522601341373, 0.00296142025653418, 0.00320716195737542,
0.00266141804235125, 0.00440970289025837), `EUR/GBP_RBV t+1` = c(0.00288377777753365,
0.00300554199386584, 0.00360608177982326, 0.00327292734850446,
0.0029202430753471, 0.00336891287836027), `EUR/GBP_RV` = c(0.00446710941914797,
0.00401994700051122, 0.00407732180013827, 0.00466624428620966,
0.00458235106134663, 0.00482454749708351), `EUR/GBP_RV_5` = c(0.00499598016427624,
0.00470474196716823, 0.00456452150727461, 0.00453292965488229,
0.00436259471347075, 0.00442030721926592), `EUR/GBP_RV_22` = c(0.00515060219897263,
0.00509920878086075, 0.00502079002092667, 0.00501107755050095,
0.00499963428727425, 0.00495435807685843), `EUR/GBP_RBV` = c(0.00324667045338159,
0.00288377777753365, 0.00300554199386584, 0.00360608177982326,
0.00327292734850446, 0.00272655057625291), `EUR/GBP_RBV_5` = c(0.0034985439252634,
0.00318731350301598, 0.00319529774619179, 0.0032799330165155,
0.00320299987062176, 0.00310626895475871), `EUR/GBP_RBV_22` = c(0.0036581887941976,
0.00362298829344015, 0.00355498498935768, 0.0035465419934449,
0.00355752455210586, 0.00351669973034298), `EUR/GBP_RGV` = c(0.00306825643155514,
0.00280067842079775, 0.00275522601341373, 0.00296142025653418,
0.00320716195737542, 0.00398022367546721), `EUR/GBP_RGV_5` = c(0.00353290218424469,
0.00345194162523714, 0.00325362896209417, 0.00312087362386985,
0.00295854861593525, 0.00311308998902836), `EUR/GBP_RGV_22` = c(0.00359974659692405,
0.00356342531619103, 0.00352224165959556, 0.00351722666683608,
0.00349184335907274, 0.00346394410318992), `EUR/GBP_TotalCount` = structure(c(-0.179518680545716,
-0.0757259172924681, 0.333514120677483, 0.759064450015801, -0.419724789788948,
-0.360414639358521), .Dim = c(6L, 1L)), `EUR/GBP_BloombergCount` = structure(c(-0.701694550941621,
-0.669811381311996, -0.574161872423118, -0.644304845608295, -0.784590791978649,
-0.631551577756444), .Dim = c(6L, 1L)), `EUR/GBP_SocialMediaCount` = structure(c(-1.68861759789696,
-1.66829994393287, -1.5910928588693, -1.59515638966212, -1.6967446594826,
-1.63172816679749), .Dim = c(6L, 1L)), `EUR/GBP_NewsCount` = structure(c(0.76560533722738,
0.879161625683434, 1.33717198912285, 1.90306082659552, 0.487392430510049,
0.487392430510049), .Dim = c(6L, 1L))), na.action = structure(c(`6` = 6L,
`38` = 38L, `74` = 74L, `101` = 101L, `140` = 140L, `165` = 165L,
`189` = 189L, `197` = 197L, `236` = 236L, `256` = 256L, `323` = 323L,
`351` = 351L, `393` = 393L, `423` = 423L, `442` = 442L, `455` = 455L,
`490` = 490L, `510` = 510L, `551` = 551L, `576` = 576L, `605` = 605L,
`646` = 646L, `676` = 676L, `696` = 696L, `708` = 708L, `742` = 742L,
`762` = 762L, `793` = 793L, `829` = 829L, `858` = 858L, `904` = 904L,
`929` = 929L, `950` = 950L, `961` = 961L, `996` = 996L, `1016` = 1016L,
`1089` = 1089L, `1114` = 1114L, `1159` = 1159L, `1184` = 1184L,
`1207` = 1207L, `1216` = 1216L, `1238` = 1238L, `1243` = 1243L,
`1253` = 1253L, `1278` = 1278L, `1315` = 1315L, `1346` = 1346L,
`1372` = 1372L, `1416` = 1416L, `1441` = 1441L, `1473` = 1473L,
`1532` = 1532L, `1599` = 1599L, `1626` = 1626L, `1669` = 1669L,
`1694` = 1694L, `1718` = 1718L, `1726` = 1726L, `1766` = 1766L,
`1786` = 1786L, `1827` = 1827L, `1853` = 1853L, `1881` = 1881L,
`1922` = 1922L, `1952` = 1952L, `1971` = 1971L, `1984` = 1984L,
`2019` = 2019L, `2039` = 2039L, `2075` = 2075L, `2106` = 2106L,
`2135` = 2135L, `2181` = 2181L, `2206` = 2206L, `2227` = 2227L,
`2238` = 2238L, `2273` = 2273L, `2293` = 2293L, `2325` = 2325L,
`2366` = 2366L, `2391` = 2391L, `2436` = 2436L, `2461` = 2461L,
`2483` = 2483L, `2493` = 2493L), class = "omit"), row.names = c(1L,
2L, 3L, 4L, 5L, 7L), class = "data.frame")
I have built 9 regression models per forecast horizon (t+1, t+5 and t+22) and I am using the predict function to make my forecasts. I have coded this in an R loop, where I also try to assign each forecast to a matrix. My code is the following:
EUR/GBP_RV_22`+data.estimateI am trying to calculate realized volatility forecasts using a rolling window forecast. My aim is to use the first 500 observations to forecast the 501st observations, then shift the window forward one step using observations 2 to 501 to predict the 502nd observation. I want this to repeat until I have a complete pseudo out-of-sample forecast.
My df contains 2411 observations of 23 variables, here is small example:
Date
EUR/GBP_RV t+1
EUR/GBP_RV
EUR/GBP_RV_5
EUR/GBP_RV_22
2012-02-13
0.004019947
0.004467109
0.004995980
0.005150602
2012-02-14
0.004077322
0.004019947
0.004704742
0.005099209
2012-02-15
0.004666244
0.004077322
0.004564522
0.005020790
2012-02-16
0.004582351
0.004666244
0.004532930
0.005011078
2012-02-17
0.003951071
0.004582351
0.004362595
0.004999634
2012-02-21
0.005549329
0.004824547
0.004467109
0.004954358
The head of the df can be reproduced with
structure(list(Date = structure(c(15383, 15384, 15385, 15386,
15387, 15391), class = "Date"), `EUR/GBP_RV t+1,t+22` = c(0.00437808494654599,
0.00439764887779732, 0.00441997330738947, 0.00437799055732722,
0.00435021150904479, 0.00434881306458859), `EUR/GBP_RGV t+1,t+22` = c(0.00310674728131117,
0.00311502965608506, 0.00313756204195853, 0.00312923997431178,
0.00310846773074243, 0.00309755540903969), `EUR/GBP_RBV t+1,t+22` = c(0.00304961980133602,
0.00306866297401415, 0.00307794319983677, 0.00302801249035602,
0.00300946121851254, 0.00302272755554915), `EUR/GBP_RV t+1,t+5` = c(0.00425938711995146,
0.00442030721926592, 0.00471470868108043, 0.00487869292442023,
0.00476849421943949, 0.0046067439660438), `EUR/GBP_RGV t+1,t+5` = c(0.00287718093809447,
0.00311308998902836, 0.00344398536439729, 0.00376911066284235,
0.00377425759242542, 0.00353909902900148), `EUR/GBP_RBV t+1,t+5` = c(0.00313771439501486,
0.00310626895475871, 0.0031789431316576, 0.00305962424370556,
0.00288671182187571, 0.00291630955829613), `EUR/GBP_RV t+1` = c(0.00401994700051122,
0.00407732180013827, 0.00466624428620966, 0.00458235106134663,
0.00395107145155152, 0.00554932910921084), `EUR/GBP_RGV t+1` = c(0.00280067842079775,
0.00275522601341373, 0.00296142025653418, 0.00320716195737542,
0.00266141804235125, 0.00440970289025837), `EUR/GBP_RBV t+1` = c(0.00288377777753365,
0.00300554199386584, 0.00360608177982326, 0.00327292734850446,
0.0029202430753471, 0.00336891287836027), `EUR/GBP_RV` = c(0.00446710941914797,
0.00401994700051122, 0.00407732180013827, 0.00466624428620966,
0.00458235106134663, 0.00482454749708351), `EUR/GBP_RV_5` = c(0.00499598016427624,
0.00470474196716823, 0.00456452150727461, 0.00453292965488229,
0.00436259471347075, 0.00442030721926592), `EUR/GBP_RV_22` = c(0.00515060219897263,
0.00509920878086075, 0.00502079002092667, 0.00501107755050095,
0.00499963428727425, 0.00495435807685843), `EUR/GBP_RBV` = c(0.00324667045338159,
0.00288377777753365, 0.00300554199386584, 0.00360608177982326,
0.00327292734850446, 0.00272655057625291), `EUR/GBP_RBV_5` = c(0.0034985439252634,
0.00318731350301598, 0.00319529774619179, 0.0032799330165155,
0.00320299987062176, 0.00310626895475871), `EUR/GBP_RBV_22` = c(0.0036581887941976,
0.00362298829344015, 0.00355498498935768, 0.0035465419934449,
0.00355752455210586, 0.00351669973034298), `EUR/GBP_RGV` = c(0.00306825643155514,
0.00280067842079775, 0.00275522601341373, 0.00296142025653418,
0.00320716195737542, 0.00398022367546721), `EUR/GBP_RGV_5` = c(0.00353290218424469,
0.00345194162523714, 0.00325362896209417, 0.00312087362386985,
0.00295854861593525, 0.00311308998902836), `EUR/GBP_RGV_22` = c(0.00359974659692405,
0.00356342531619103, 0.00352224165959556, 0.00351722666683608,
0.00349184335907274, 0.00346394410318992), `EUR/GBP_TotalCount` = structure(c(-0.179518680545716,
-0.0757259172924681, 0.333514120677483, 0.759064450015801, -0.419724789788948,
-0.360414639358521), .Dim = c(6L, 1L)), `EUR/GBP_BloombergCount` = structure(c(-0.701694550941621,
-0.669811381311996, -0.574161872423118, -0.644304845608295, -0.784590791978649,
-0.631551577756444), .Dim = c(6L, 1L)), `EUR/GBP_SocialMediaCount` = structure(c(-1.68861759789696,
-1.66829994393287, -1.5910928588693, -1.59515638966212, -1.6967446594826,
-1.63172816679749), .Dim = c(6L, 1L)), `EUR/GBP_NewsCount` = structure(c(0.76560533722738,
0.879161625683434, 1.33717198912285, 1.90306082659552, 0.487392430510049,
0.487392430510049), .Dim = c(6L, 1L))), na.action = structure(c(`6` = 6L,
`38` = 38L, `74` = 74L, `101` = 101L, `140` = 140L, `165` = 165L,
`189` = 189L, `197` = 197L, `236` = 236L, `256` = 256L, `323` = 323L,
`351` = 351L, `393` = 393L, `423` = 423L, `442` = 442L, `455` = 455L,
`490` = 490L, `510` = 510L, `551` = 551L, `576` = 576L, `605` = 605L,
`646` = 646L, `676` = 676L, `696` = 696L, `708` = 708L, `742` = 742L,
`762` = 762L, `793` = 793L, `829` = 829L, `858` = 858L, `904` = 904L,
`929` = 929L, `950` = 950L, `961` = 961L, `996` = 996L, `1016` = 1016L,
`1089` = 1089L, `1114` = 1114L, `1159` = 1159L, `1184` = 1184L,
`1207` = 1207L, `1216` = 1216L, `1238` = 1238L, `1243` = 1243L,
`1253` = 1253L, `1278` = 1278L, `1315` = 1315L, `1346` = 1346L,
`1372` = 1372L, `1416` = 1416L, `1441` = 1441L, `1473` = 1473L,
`1532` = 1532L, `1599` = 1599L, `1626` = 1626L, `1669` = 1669L,
`1694` = 1694L, `1718` = 1718L, `1726` = 1726L, `1766` = 1766L,
`1786` = 1786L, `1827` = 1827L, `1853` = 1853L, `1881` = 1881L,
`1922` = 1922L, `1952` = 1952L, `1971` = 1971L, `1984` = 1984L,
`2019` = 2019L, `2039` = 2039L, `2075` = 2075L, `2106` = 2106L,
`2135` = 2135L, `2181` = 2181L, `2206` = 2206L, `2227` = 2227L,
`2238` = 2238L, `2273` = 2273L, `2293` = 2293L, `2325` = 2325L,
`2366` = 2366L, `2391` = 2391L, `2436` = 2436L, `2461` = 2461L,
`2483` = 2483L, `2493` = 2493L), class = "omit"), row.names = c(1L,
2L, 3L, 4L, 5L, 7L), class = "data.frame")
I have built 9 regression models per forecast horizon (t+1, t+5 and t+22) and I am using the predict function to make my forecasts. I have coded this in an R loop, where I also try to assign each forecast to a matrix. My code is the following:
EUR/GBP_SocialMediaCount`)
EURGBP_HAR_RVt5_News_train <- lm(data.estimateI am trying to calculate realized volatility forecasts using a rolling window forecast. My aim is to use the first 500 observations to forecast the 501st observations, then shift the window forward one step using observations 2 to 501 to predict the 502nd observation. I want this to repeat until I have a complete pseudo out-of-sample forecast.
My df contains 2411 observations of 23 variables, here is small example:
Date
EUR/GBP_RV t+1
EUR/GBP_RV
EUR/GBP_RV_5
EUR/GBP_RV_22
2012-02-13
0.004019947
0.004467109
0.004995980
0.005150602
2012-02-14
0.004077322
0.004019947
0.004704742
0.005099209
2012-02-15
0.004666244
0.004077322
0.004564522
0.005020790
2012-02-16
0.004582351
0.004666244
0.004532930
0.005011078
2012-02-17
0.003951071
0.004582351
0.004362595
0.004999634
2012-02-21
0.005549329
0.004824547
0.004467109
0.004954358
The head of the df can be reproduced with
structure(list(Date = structure(c(15383, 15384, 15385, 15386,
15387, 15391), class = "Date"), `EUR/GBP_RV t+1,t+22` = c(0.00437808494654599,
0.00439764887779732, 0.00441997330738947, 0.00437799055732722,
0.00435021150904479, 0.00434881306458859), `EUR/GBP_RGV t+1,t+22` = c(0.00310674728131117,
0.00311502965608506, 0.00313756204195853, 0.00312923997431178,
0.00310846773074243, 0.00309755540903969), `EUR/GBP_RBV t+1,t+22` = c(0.00304961980133602,
0.00306866297401415, 0.00307794319983677, 0.00302801249035602,
0.00300946121851254, 0.00302272755554915), `EUR/GBP_RV t+1,t+5` = c(0.00425938711995146,
0.00442030721926592, 0.00471470868108043, 0.00487869292442023,
0.00476849421943949, 0.0046067439660438), `EUR/GBP_RGV t+1,t+5` = c(0.00287718093809447,
0.00311308998902836, 0.00344398536439729, 0.00376911066284235,
0.00377425759242542, 0.00353909902900148), `EUR/GBP_RBV t+1,t+5` = c(0.00313771439501486,
0.00310626895475871, 0.0031789431316576, 0.00305962424370556,
0.00288671182187571, 0.00291630955829613), `EUR/GBP_RV t+1` = c(0.00401994700051122,
0.00407732180013827, 0.00466624428620966, 0.00458235106134663,
0.00395107145155152, 0.00554932910921084), `EUR/GBP_RGV t+1` = c(0.00280067842079775,
0.00275522601341373, 0.00296142025653418, 0.00320716195737542,
0.00266141804235125, 0.00440970289025837), `EUR/GBP_RBV t+1` = c(0.00288377777753365,
0.00300554199386584, 0.00360608177982326, 0.00327292734850446,
0.0029202430753471, 0.00336891287836027), `EUR/GBP_RV` = c(0.00446710941914797,
0.00401994700051122, 0.00407732180013827, 0.00466624428620966,
0.00458235106134663, 0.00482454749708351), `EUR/GBP_RV_5` = c(0.00499598016427624,
0.00470474196716823, 0.00456452150727461, 0.00453292965488229,
0.00436259471347075, 0.00442030721926592), `EUR/GBP_RV_22` = c(0.00515060219897263,
0.00509920878086075, 0.00502079002092667, 0.00501107755050095,
0.00499963428727425, 0.00495435807685843), `EUR/GBP_RBV` = c(0.00324667045338159,
0.00288377777753365, 0.00300554199386584, 0.00360608177982326,
0.00327292734850446, 0.00272655057625291), `EUR/GBP_RBV_5` = c(0.0034985439252634,
0.00318731350301598, 0.00319529774619179, 0.0032799330165155,
0.00320299987062176, 0.00310626895475871), `EUR/GBP_RBV_22` = c(0.0036581887941976,
0.00362298829344015, 0.00355498498935768, 0.0035465419934449,
0.00355752455210586, 0.00351669973034298), `EUR/GBP_RGV` = c(0.00306825643155514,
0.00280067842079775, 0.00275522601341373, 0.00296142025653418,
0.00320716195737542, 0.00398022367546721), `EUR/GBP_RGV_5` = c(0.00353290218424469,
0.00345194162523714, 0.00325362896209417, 0.00312087362386985,
0.00295854861593525, 0.00311308998902836), `EUR/GBP_RGV_22` = c(0.00359974659692405,
0.00356342531619103, 0.00352224165959556, 0.00351722666683608,
0.00349184335907274, 0.00346394410318992), `EUR/GBP_TotalCount` = structure(c(-0.179518680545716,
-0.0757259172924681, 0.333514120677483, 0.759064450015801, -0.419724789788948,
-0.360414639358521), .Dim = c(6L, 1L)), `EUR/GBP_BloombergCount` = structure(c(-0.701694550941621,
-0.669811381311996, -0.574161872423118, -0.644304845608295, -0.784590791978649,
-0.631551577756444), .Dim = c(6L, 1L)), `EUR/GBP_SocialMediaCount` = structure(c(-1.68861759789696,
-1.66829994393287, -1.5910928588693, -1.59515638966212, -1.6967446594826,
-1.63172816679749), .Dim = c(6L, 1L)), `EUR/GBP_NewsCount` = structure(c(0.76560533722738,
0.879161625683434, 1.33717198912285, 1.90306082659552, 0.487392430510049,
0.487392430510049), .Dim = c(6L, 1L))), na.action = structure(c(`6` = 6L,
`38` = 38L, `74` = 74L, `101` = 101L, `140` = 140L, `165` = 165L,
`189` = 189L, `197` = 197L, `236` = 236L, `256` = 256L, `323` = 323L,
`351` = 351L, `393` = 393L, `423` = 423L, `442` = 442L, `455` = 455L,
`490` = 490L, `510` = 510L, `551` = 551L, `576` = 576L, `605` = 605L,
`646` = 646L, `676` = 676L, `696` = 696L, `708` = 708L, `742` = 742L,
`762` = 762L, `793` = 793L, `829` = 829L, `858` = 858L, `904` = 904L,
`929` = 929L, `950` = 950L, `961` = 961L, `996` = 996L, `1016` = 1016L,
`1089` = 1089L, `1114` = 1114L, `1159` = 1159L, `1184` = 1184L,
`1207` = 1207L, `1216` = 1216L, `1238` = 1238L, `1243` = 1243L,
`1253` = 1253L, `1278` = 1278L, `1315` = 1315L, `1346` = 1346L,
`1372` = 1372L, `1416` = 1416L, `1441` = 1441L, `1473` = 1473L,
`1532` = 1532L, `1599` = 1599L, `1626` = 1626L, `1669` = 1669L,
`1694` = 1694L, `1718` = 1718L, `1726` = 1726L, `1766` = 1766L,
`1786` = 1786L, `1827` = 1827L, `1853` = 1853L, `1881` = 1881L,
`1922` = 1922L, `1952` = 1952L, `1971` = 1971L, `1984` = 1984L,
`2019` = 2019L, `2039` = 2039L, `2075` = 2075L, `2106` = 2106L,
`2135` = 2135L, `2181` = 2181L, `2206` = 2206L, `2227` = 2227L,
`2238` = 2238L, `2273` = 2273L, `2293` = 2293L, `2325` = 2325L,
`2366` = 2366L, `2391` = 2391L, `2436` = 2436L, `2461` = 2461L,
`2483` = 2483L, `2493` = 2493L), class = "omit"), row.names = c(1L,
2L, 3L, 4L, 5L, 7L), class = "data.frame")
I have built 9 regression models per forecast horizon (t+1, t+5 and t+22) and I am using the predict function to make my forecasts. I have coded this in an R loop, where I also try to assign each forecast to a matrix. My code is the following:
EUR/GBP_RV t+1,t+5`~data.estimateI am trying to calculate realized volatility forecasts using a rolling window forecast. My aim is to use the first 500 observations to forecast the 501st observations, then shift the window forward one step using observations 2 to 501 to predict the 502nd observation. I want this to repeat until I have a complete pseudo out-of-sample forecast.
My df contains 2411 observations of 23 variables, here is small example:
Date
EUR/GBP_RV t+1
EUR/GBP_RV
EUR/GBP_RV_5
EUR/GBP_RV_22
2012-02-13
0.004019947
0.004467109
0.004995980
0.005150602
2012-02-14
0.004077322
0.004019947
0.004704742
0.005099209
2012-02-15
0.004666244
0.004077322
0.004564522
0.005020790
2012-02-16
0.004582351
0.004666244
0.004532930
0.005011078
2012-02-17
0.003951071
0.004582351
0.004362595
0.004999634
2012-02-21
0.005549329
0.004824547
0.004467109
0.004954358
The head of the df can be reproduced with
structure(list(Date = structure(c(15383, 15384, 15385, 15386,
15387, 15391), class = "Date"), `EUR/GBP_RV t+1,t+22` = c(0.00437808494654599,
0.00439764887779732, 0.00441997330738947, 0.00437799055732722,
0.00435021150904479, 0.00434881306458859), `EUR/GBP_RGV t+1,t+22` = c(0.00310674728131117,
0.00311502965608506, 0.00313756204195853, 0.00312923997431178,
0.00310846773074243, 0.00309755540903969), `EUR/GBP_RBV t+1,t+22` = c(0.00304961980133602,
0.00306866297401415, 0.00307794319983677, 0.00302801249035602,
0.00300946121851254, 0.00302272755554915), `EUR/GBP_RV t+1,t+5` = c(0.00425938711995146,
0.00442030721926592, 0.00471470868108043, 0.00487869292442023,
0.00476849421943949, 0.0046067439660438), `EUR/GBP_RGV t+1,t+5` = c(0.00287718093809447,
0.00311308998902836, 0.00344398536439729, 0.00376911066284235,
0.00377425759242542, 0.00353909902900148), `EUR/GBP_RBV t+1,t+5` = c(0.00313771439501486,
0.00310626895475871, 0.0031789431316576, 0.00305962424370556,
0.00288671182187571, 0.00291630955829613), `EUR/GBP_RV t+1` = c(0.00401994700051122,
0.00407732180013827, 0.00466624428620966, 0.00458235106134663,
0.00395107145155152, 0.00554932910921084), `EUR/GBP_RGV t+1` = c(0.00280067842079775,
0.00275522601341373, 0.00296142025653418, 0.00320716195737542,
0.00266141804235125, 0.00440970289025837), `EUR/GBP_RBV t+1` = c(0.00288377777753365,
0.00300554199386584, 0.00360608177982326, 0.00327292734850446,
0.0029202430753471, 0.00336891287836027), `EUR/GBP_RV` = c(0.00446710941914797,
0.00401994700051122, 0.00407732180013827, 0.00466624428620966,
0.00458235106134663, 0.00482454749708351), `EUR/GBP_RV_5` = c(0.00499598016427624,
0.00470474196716823, 0.00456452150727461, 0.00453292965488229,
0.00436259471347075, 0.00442030721926592), `EUR/GBP_RV_22` = c(0.00515060219897263,
0.00509920878086075, 0.00502079002092667, 0.00501107755050095,
0.00499963428727425, 0.00495435807685843), `EUR/GBP_RBV` = c(0.00324667045338159,
0.00288377777753365, 0.00300554199386584, 0.00360608177982326,
0.00327292734850446, 0.00272655057625291), `EUR/GBP_RBV_5` = c(0.0034985439252634,
0.00318731350301598, 0.00319529774619179, 0.0032799330165155,
0.00320299987062176, 0.00310626895475871), `EUR/GBP_RBV_22` = c(0.0036581887941976,
0.00362298829344015, 0.00355498498935768, 0.0035465419934449,
0.00355752455210586, 0.00351669973034298), `EUR/GBP_RGV` = c(0.00306825643155514,
0.00280067842079775, 0.00275522601341373, 0.00296142025653418,
0.00320716195737542, 0.00398022367546721), `EUR/GBP_RGV_5` = c(0.00353290218424469,
0.00345194162523714, 0.00325362896209417, 0.00312087362386985,
0.00295854861593525, 0.00311308998902836), `EUR/GBP_RGV_22` = c(0.00359974659692405,
0.00356342531619103, 0.00352224165959556, 0.00351722666683608,
0.00349184335907274, 0.00346394410318992), `EUR/GBP_TotalCount` = structure(c(-0.179518680545716,
-0.0757259172924681, 0.333514120677483, 0.759064450015801, -0.419724789788948,
-0.360414639358521), .Dim = c(6L, 1L)), `EUR/GBP_BloombergCount` = structure(c(-0.701694550941621,
-0.669811381311996, -0.574161872423118, -0.644304845608295, -0.784590791978649,
-0.631551577756444), .Dim = c(6L, 1L)), `EUR/GBP_SocialMediaCount` = structure(c(-1.68861759789696,
-1.66829994393287, -1.5910928588693, -1.59515638966212, -1.6967446594826,
-1.63172816679749), .Dim = c(6L, 1L)), `EUR/GBP_NewsCount` = structure(c(0.76560533722738,
0.879161625683434, 1.33717198912285, 1.90306082659552, 0.487392430510049,
0.487392430510049), .Dim = c(6L, 1L))), na.action = structure(c(`6` = 6L,
`38` = 38L, `74` = 74L, `101` = 101L, `140` = 140L, `165` = 165L,
`189` = 189L, `197` = 197L, `236` = 236L, `256` = 256L, `323` = 323L,
`351` = 351L, `393` = 393L, `423` = 423L, `442` = 442L, `455` = 455L,
`490` = 490L, `510` = 510L, `551` = 551L, `576` = 576L, `605` = 605L,
`646` = 646L, `676` = 676L, `696` = 696L, `708` = 708L, `742` = 742L,
`762` = 762L, `793` = 793L, `829` = 829L, `858` = 858L, `904` = 904L,
`929` = 929L, `950` = 950L, `961` = 961L, `996` = 996L, `1016` = 1016L,
`1089` = 1089L, `1114` = 1114L, `1159` = 1159L, `1184` = 1184L,
`1207` = 1207L, `1216` = 1216L, `1238` = 1238L, `1243` = 1243L,
`1253` = 1253L, `1278` = 1278L, `1315` = 1315L, `1346` = 1346L,
`1372` = 1372L, `1416` = 1416L, `1441` = 1441L, `1473` = 1473L,
`1532` = 1532L, `1599` = 1599L, `1626` = 1626L, `1669` = 1669L,
`1694` = 1694L, `1718` = 1718L, `1726` = 1726L, `1766` = 1766L,
`1786` = 1786L, `1827` = 1827L, `1853` = 1853L, `1881` = 1881L,
`1922` = 1922L, `1952` = 1952L, `1971` = 1971L, `1984` = 1984L,
`2019` = 2019L, `2039` = 2039L, `2075` = 2075L, `2106` = 2106L,
`2135` = 2135L, `2181` = 2181L, `2206` = 2206L, `2227` = 2227L,
`2238` = 2238L, `2273` = 2273L, `2293` = 2293L, `2325` = 2325L,
`2366` = 2366L, `2391` = 2391L, `2436` = 2436L, `2461` = 2461L,
`2483` = 2483L, `2493` = 2493L), class = "omit"), row.names = c(1L,
2L, 3L, 4L, 5L, 7L), class = "data.frame")
I have built 9 regression models per forecast horizon (t+1, t+5 and t+22) and I am using the predict function to make my forecasts. I have coded this in an R loop, where I also try to assign each forecast to a matrix. My code is the following:
EUR/GBP_RV`+data.estimateI am trying to calculate realized volatility forecasts using a rolling window forecast. My aim is to use the first 500 observations to forecast the 501st observations, then shift the window forward one step using observations 2 to 501 to predict the 502nd observation. I want this to repeat until I have a complete pseudo out-of-sample forecast.
My df contains 2411 observations of 23 variables, here is small example:
Date
EUR/GBP_RV t+1
EUR/GBP_RV
EUR/GBP_RV_5
EUR/GBP_RV_22
2012-02-13
0.004019947
0.004467109
0.004995980
0.005150602
2012-02-14
0.004077322
0.004019947
0.004704742
0.005099209
2012-02-15
0.004666244
0.004077322
0.004564522
0.005020790
2012-02-16
0.004582351
0.004666244
0.004532930
0.005011078
2012-02-17
0.003951071
0.004582351
0.004362595
0.004999634
2012-02-21
0.005549329
0.004824547
0.004467109
0.004954358
The head of the df can be reproduced with
structure(list(Date = structure(c(15383, 15384, 15385, 15386,
15387, 15391), class = "Date"), `EUR/GBP_RV t+1,t+22` = c(0.00437808494654599,
0.00439764887779732, 0.00441997330738947, 0.00437799055732722,
0.00435021150904479, 0.00434881306458859), `EUR/GBP_RGV t+1,t+22` = c(0.00310674728131117,
0.00311502965608506, 0.00313756204195853, 0.00312923997431178,
0.00310846773074243, 0.00309755540903969), `EUR/GBP_RBV t+1,t+22` = c(0.00304961980133602,
0.00306866297401415, 0.00307794319983677, 0.00302801249035602,
0.00300946121851254, 0.00302272755554915), `EUR/GBP_RV t+1,t+5` = c(0.00425938711995146,
0.00442030721926592, 0.00471470868108043, 0.00487869292442023,
0.00476849421943949, 0.0046067439660438), `EUR/GBP_RGV t+1,t+5` = c(0.00287718093809447,
0.00311308998902836, 0.00344398536439729, 0.00376911066284235,
0.00377425759242542, 0.00353909902900148), `EUR/GBP_RBV t+1,t+5` = c(0.00313771439501486,
0.00310626895475871, 0.0031789431316576, 0.00305962424370556,
0.00288671182187571, 0.00291630955829613), `EUR/GBP_RV t+1` = c(0.00401994700051122,
0.00407732180013827, 0.00466624428620966, 0.00458235106134663,
0.00395107145155152, 0.00554932910921084), `EUR/GBP_RGV t+1` = c(0.00280067842079775,
0.00275522601341373, 0.00296142025653418, 0.00320716195737542,
0.00266141804235125, 0.00440970289025837), `EUR/GBP_RBV t+1` = c(0.00288377777753365,
0.00300554199386584, 0.00360608177982326, 0.00327292734850446,
0.0029202430753471, 0.00336891287836027), `EUR/GBP_RV` = c(0.00446710941914797,
0.00401994700051122, 0.00407732180013827, 0.00466624428620966,
0.00458235106134663, 0.00482454749708351), `EUR/GBP_RV_5` = c(0.00499598016427624,
0.00470474196716823, 0.00456452150727461, 0.00453292965488229,
0.00436259471347075, 0.00442030721926592), `EUR/GBP_RV_22` = c(0.00515060219897263,
0.00509920878086075, 0.00502079002092667, 0.00501107755050095,
0.00499963428727425, 0.00495435807685843), `EUR/GBP_RBV` = c(0.00324667045338159,
0.00288377777753365, 0.00300554199386584, 0.00360608177982326,
0.00327292734850446, 0.00272655057625291), `EUR/GBP_RBV_5` = c(0.0034985439252634,
0.00318731350301598, 0.00319529774619179, 0.0032799330165155,
0.00320299987062176, 0.00310626895475871), `EUR/GBP_RBV_22` = c(0.0036581887941976,
0.00362298829344015, 0.00355498498935768, 0.0035465419934449,
0.00355752455210586, 0.00351669973034298), `EUR/GBP_RGV` = c(0.00306825643155514,
0.00280067842079775, 0.00275522601341373, 0.00296142025653418,
0.00320716195737542, 0.00398022367546721), `EUR/GBP_RGV_5` = c(0.00353290218424469,
0.00345194162523714, 0.00325362896209417, 0.00312087362386985,
0.00295854861593525, 0.00311308998902836), `EUR/GBP_RGV_22` = c(0.00359974659692405,
0.00356342531619103, 0.00352224165959556, 0.00351722666683608,
0.00349184335907274, 0.00346394410318992), `EUR/GBP_TotalCount` = structure(c(-0.179518680545716,
-0.0757259172924681, 0.333514120677483, 0.759064450015801, -0.419724789788948,
-0.360414639358521), .Dim = c(6L, 1L)), `EUR/GBP_BloombergCount` = structure(c(-0.701694550941621,
-0.669811381311996, -0.574161872423118, -0.644304845608295, -0.784590791978649,
-0.631551577756444), .Dim = c(6L, 1L)), `EUR/GBP_SocialMediaCount` = structure(c(-1.68861759789696,
-1.66829994393287, -1.5910928588693, -1.59515638966212, -1.6967446594826,
-1.63172816679749), .Dim = c(6L, 1L)), `EUR/GBP_NewsCount` = structure(c(0.76560533722738,
0.879161625683434, 1.33717198912285, 1.90306082659552, 0.487392430510049,
0.487392430510049), .Dim = c(6L, 1L))), na.action = structure(c(`6` = 6L,
`38` = 38L, `74` = 74L, `101` = 101L, `140` = 140L, `165` = 165L,
`189` = 189L, `197` = 197L, `236` = 236L, `256` = 256L, `323` = 323L,
`351` = 351L, `393` = 393L, `423` = 423L, `442` = 442L, `455` = 455L,
`490` = 490L, `510` = 510L, `551` = 551L, `576` = 576L, `605` = 605L,
`646` = 646L, `676` = 676L, `696` = 696L, `708` = 708L, `742` = 742L,
`762` = 762L, `793` = 793L, `829` = 829L, `858` = 858L, `904` = 904L,
`929` = 929L, `950` = 950L, `961` = 961L, `996` = 996L, `1016` = 1016L,
`1089` = 1089L, `1114` = 1114L, `1159` = 1159L, `1184` = 1184L,
`1207` = 1207L, `1216` = 1216L, `1238` = 1238L, `1243` = 1243L,
`1253` = 1253L, `1278` = 1278L, `1315` = 1315L, `1346` = 1346L,
`1372` = 1372L, `1416` = 1416L, `1441` = 1441L, `1473` = 1473L,
`1532` = 1532L, `1599` = 1599L, `1626` = 1626L, `1669` = 1669L,
`1694` = 1694L, `1718` = 1718L, `1726` = 1726L, `1766` = 1766L,
`1786` = 1786L, `1827` = 1827L, `1853` = 1853L, `1881` = 1881L,
`1922` = 1922L, `1952` = 1952L, `1971` = 1971L, `1984` = 1984L,
`2019` = 2019L, `2039` = 2039L, `2075` = 2075L, `2106` = 2106L,
`2135` = 2135L, `2181` = 2181L, `2206` = 2206L, `2227` = 2227L,
`2238` = 2238L, `2273` = 2273L, `2293` = 2293L, `2325` = 2325L,
`2366` = 2366L, `2391` = 2391L, `2436` = 2436L, `2461` = 2461L,
`2483` = 2483L, `2493` = 2493L), class = "omit"), row.names = c(1L,
2L, 3L, 4L, 5L, 7L), class = "data.frame")
I have built 9 regression models per forecast horizon (t+1, t+5 and t+22) and I am using the predict function to make my forecasts. I have coded this in an R loop, where I also try to assign each forecast to a matrix. My code is the following:
EUR/GBP_RV_5`+data.estimateI am trying to calculate realized volatility forecasts using a rolling window forecast. My aim is to use the first 500 observations to forecast the 501st observations, then shift the window forward one step using observations 2 to 501 to predict the 502nd observation. I want this to repeat until I have a complete pseudo out-of-sample forecast.
My df contains 2411 observations of 23 variables, here is small example:
Date
EUR/GBP_RV t+1
EUR/GBP_RV
EUR/GBP_RV_5
EUR/GBP_RV_22
2012-02-13
0.004019947
0.004467109
0.004995980
0.005150602
2012-02-14
0.004077322
0.004019947
0.004704742
0.005099209
2012-02-15
0.004666244
0.004077322
0.004564522
0.005020790
2012-02-16
0.004582351
0.004666244
0.004532930
0.005011078
2012-02-17
0.003951071
0.004582351
0.004362595
0.004999634
2012-02-21
0.005549329
0.004824547
0.004467109
0.004954358
The head of the df can be reproduced with
structure(list(Date = structure(c(15383, 15384, 15385, 15386,
15387, 15391), class = "Date"), `EUR/GBP_RV t+1,t+22` = c(0.00437808494654599,
0.00439764887779732, 0.00441997330738947, 0.00437799055732722,
0.00435021150904479, 0.00434881306458859), `EUR/GBP_RGV t+1,t+22` = c(0.00310674728131117,
0.00311502965608506, 0.00313756204195853, 0.00312923997431178,
0.00310846773074243, 0.00309755540903969), `EUR/GBP_RBV t+1,t+22` = c(0.00304961980133602,
0.00306866297401415, 0.00307794319983677, 0.00302801249035602,
0.00300946121851254, 0.00302272755554915), `EUR/GBP_RV t+1,t+5` = c(0.00425938711995146,
0.00442030721926592, 0.00471470868108043, 0.00487869292442023,
0.00476849421943949, 0.0046067439660438), `EUR/GBP_RGV t+1,t+5` = c(0.00287718093809447,
0.00311308998902836, 0.00344398536439729, 0.00376911066284235,
0.00377425759242542, 0.00353909902900148), `EUR/GBP_RBV t+1,t+5` = c(0.00313771439501486,
0.00310626895475871, 0.0031789431316576, 0.00305962424370556,
0.00288671182187571, 0.00291630955829613), `EUR/GBP_RV t+1` = c(0.00401994700051122,
0.00407732180013827, 0.00466624428620966, 0.00458235106134663,
0.00395107145155152, 0.00554932910921084), `EUR/GBP_RGV t+1` = c(0.00280067842079775,
0.00275522601341373, 0.00296142025653418, 0.00320716195737542,
0.00266141804235125, 0.00440970289025837), `EUR/GBP_RBV t+1` = c(0.00288377777753365,
0.00300554199386584, 0.00360608177982326, 0.00327292734850446,
0.0029202430753471, 0.00336891287836027), `EUR/GBP_RV` = c(0.00446710941914797,
0.00401994700051122, 0.00407732180013827, 0.00466624428620966,
0.00458235106134663, 0.00482454749708351), `EUR/GBP_RV_5` = c(0.00499598016427624,
0.00470474196716823, 0.00456452150727461, 0.00453292965488229,
0.00436259471347075, 0.00442030721926592), `EUR/GBP_RV_22` = c(0.00515060219897263,
0.00509920878086075, 0.00502079002092667, 0.00501107755050095,
0.00499963428727425, 0.00495435807685843), `EUR/GBP_RBV` = c(0.00324667045338159,
0.00288377777753365, 0.00300554199386584, 0.00360608177982326,
0.00327292734850446, 0.00272655057625291), `EUR/GBP_RBV_5` = c(0.0034985439252634,
0.00318731350301598, 0.00319529774619179, 0.0032799330165155,
0.00320299987062176, 0.00310626895475871), `EUR/GBP_RBV_22` = c(0.0036581887941976,
0.00362298829344015, 0.00355498498935768, 0.0035465419934449,
0.00355752455210586, 0.00351669973034298), `EUR/GBP_RGV` = c(0.00306825643155514,
0.00280067842079775, 0.00275522601341373, 0.00296142025653418,
0.00320716195737542, 0.00398022367546721), `EUR/GBP_RGV_5` = c(0.00353290218424469,
0.00345194162523714, 0.00325362896209417, 0.00312087362386985,
0.00295854861593525, 0.00311308998902836), `EUR/GBP_RGV_22` = c(0.00359974659692405,
0.00356342531619103, 0.00352224165959556, 0.00351722666683608,
0.00349184335907274, 0.00346394410318992), `EUR/GBP_TotalCount` = structure(c(-0.179518680545716,
-0.0757259172924681, 0.333514120677483, 0.759064450015801, -0.419724789788948,
-0.360414639358521), .Dim = c(6L, 1L)), `EUR/GBP_BloombergCount` = structure(c(-0.701694550941621,
-0.669811381311996, -0.574161872423118, -0.644304845608295, -0.784590791978649,
-0.631551577756444), .Dim = c(6L, 1L)), `EUR/GBP_SocialMediaCount` = structure(c(-1.68861759789696,
-1.66829994393287, -1.5910928588693, -1.59515638966212, -1.6967446594826,
-1.63172816679749), .Dim = c(6L, 1L)), `EUR/GBP_NewsCount` = structure(c(0.76560533722738,
0.879161625683434, 1.33717198912285, 1.90306082659552, 0.487392430510049,
0.487392430510049), .Dim = c(6L, 1L))), na.action = structure(c(`6` = 6L,
`38` = 38L, `74` = 74L, `101` = 101L, `140` = 140L, `165` = 165L,
`189` = 189L, `197` = 197L, `236` = 236L, `256` = 256L, `323` = 323L,
`351` = 351L, `393` = 393L, `423` = 423L, `442` = 442L, `455` = 455L,
`490` = 490L, `510` = 510L, `551` = 551L, `576` = 576L, `605` = 605L,
`646` = 646L, `676` = 676L, `696` = 696L, `708` = 708L, `742` = 742L,
`762` = 762L, `793` = 793L, `829` = 829L, `858` = 858L, `904` = 904L,
`929` = 929L, `950` = 950L, `961` = 961L, `996` = 996L, `1016` = 1016L,
`1089` = 1089L, `1114` = 1114L, `1159` = 1159L, `1184` = 1184L,
`1207` = 1207L, `1216` = 1216L, `1238` = 1238L, `1243` = 1243L,
`1253` = 1253L, `1278` = 1278L, `1315` = 1315L, `1346` = 1346L,
`1372` = 1372L, `1416` = 1416L, `1441` = 1441L, `1473` = 1473L,
`1532` = 1532L, `1599` = 1599L, `1626` = 1626L, `1669` = 1669L,
`1694` = 1694L, `1718` = 1718L, `1726` = 1726L, `1766` = 1766L,
`1786` = 1786L, `1827` = 1827L, `1853` = 1853L, `1881` = 1881L,
`1922` = 1922L, `1952` = 1952L, `1971` = 1971L, `1984` = 1984L,
`2019` = 2019L, `2039` = 2039L, `2075` = 2075L, `2106` = 2106L,
`2135` = 2135L, `2181` = 2181L, `2206` = 2206L, `2227` = 2227L,
`2238` = 2238L, `2273` = 2273L, `2293` = 2293L, `2325` = 2325L,
`2366` = 2366L, `2391` = 2391L, `2436` = 2436L, `2461` = 2461L,
`2483` = 2483L, `2493` = 2493L), class = "omit"), row.names = c(1L,
2L, 3L, 4L, 5L, 7L), class = "data.frame")
I have built 9 regression models per forecast horizon (t+1, t+5 and t+22) and I am using the predict function to make my forecasts. I have coded this in an R loop, where I also try to assign each forecast to a matrix. My code is the following:
EUR/GBP_RV_22`+data.estimateI am trying to calculate realized volatility forecasts using a rolling window forecast. My aim is to use the first 500 observations to forecast the 501st observations, then shift the window forward one step using observations 2 to 501 to predict the 502nd observation. I want this to repeat until I have a complete pseudo out-of-sample forecast.
My df contains 2411 observations of 23 variables, here is small example:
Date
EUR/GBP_RV t+1
EUR/GBP_RV
EUR/GBP_RV_5
EUR/GBP_RV_22
2012-02-13
0.004019947
0.004467109
0.004995980
0.005150602
2012-02-14
0.004077322
0.004019947
0.004704742
0.005099209
2012-02-15
0.004666244
0.004077322
0.004564522
0.005020790
2012-02-16
0.004582351
0.004666244
0.004532930
0.005011078
2012-02-17
0.003951071
0.004582351
0.004362595
0.004999634
2012-02-21
0.005549329
0.004824547
0.004467109
0.004954358
The head of the df can be reproduced with
structure(list(Date = structure(c(15383, 15384, 15385, 15386,
15387, 15391), class = "Date"), `EUR/GBP_RV t+1,t+22` = c(0.00437808494654599,
0.00439764887779732, 0.00441997330738947, 0.00437799055732722,
0.00435021150904479, 0.00434881306458859), `EUR/GBP_RGV t+1,t+22` = c(0.00310674728131117,
0.00311502965608506, 0.00313756204195853, 0.00312923997431178,
0.00310846773074243, 0.00309755540903969), `EUR/GBP_RBV t+1,t+22` = c(0.00304961980133602,
0.00306866297401415, 0.00307794319983677, 0.00302801249035602,
0.00300946121851254, 0.00302272755554915), `EUR/GBP_RV t+1,t+5` = c(0.00425938711995146,
0.00442030721926592, 0.00471470868108043, 0.00487869292442023,
0.00476849421943949, 0.0046067439660438), `EUR/GBP_RGV t+1,t+5` = c(0.00287718093809447,
0.00311308998902836, 0.00344398536439729, 0.00376911066284235,
0.00377425759242542, 0.00353909902900148), `EUR/GBP_RBV t+1,t+5` = c(0.00313771439501486,
0.00310626895475871, 0.0031789431316576, 0.00305962424370556,
0.00288671182187571, 0.00291630955829613), `EUR/GBP_RV t+1` = c(0.00401994700051122,
0.00407732180013827, 0.00466624428620966, 0.00458235106134663,
0.00395107145155152, 0.00554932910921084), `EUR/GBP_RGV t+1` = c(0.00280067842079775,
0.00275522601341373, 0.00296142025653418, 0.00320716195737542,
0.00266141804235125, 0.00440970289025837), `EUR/GBP_RBV t+1` = c(0.00288377777753365,
0.00300554199386584, 0.00360608177982326, 0.00327292734850446,
0.0029202430753471, 0.00336891287836027), `EUR/GBP_RV` = c(0.00446710941914797,
0.00401994700051122, 0.00407732180013827, 0.00466624428620966,
0.00458235106134663, 0.00482454749708351), `EUR/GBP_RV_5` = c(0.00499598016427624,
0.00470474196716823, 0.00456452150727461, 0.00453292965488229,
0.00436259471347075, 0.00442030721926592), `EUR/GBP_RV_22` = c(0.00515060219897263,
0.00509920878086075, 0.00502079002092667, 0.00501107755050095,
0.00499963428727425, 0.00495435807685843), `EUR/GBP_RBV` = c(0.00324667045338159,
0.00288377777753365, 0.00300554199386584, 0.00360608177982326,
0.00327292734850446, 0.00272655057625291), `EUR/GBP_RBV_5` = c(0.0034985439252634,
0.00318731350301598, 0.00319529774619179, 0.0032799330165155,
0.00320299987062176, 0.00310626895475871), `EUR/GBP_RBV_22` = c(0.0036581887941976,
0.00362298829344015, 0.00355498498935768, 0.0035465419934449,
0.00355752455210586, 0.00351669973034298), `EUR/GBP_RGV` = c(0.00306825643155514,
0.00280067842079775, 0.00275522601341373, 0.00296142025653418,
0.00320716195737542, 0.00398022367546721), `EUR/GBP_RGV_5` = c(0.00353290218424469,
0.00345194162523714, 0.00325362896209417, 0.00312087362386985,
0.00295854861593525, 0.00311308998902836), `EUR/GBP_RGV_22` = c(0.00359974659692405,
0.00356342531619103, 0.00352224165959556, 0.00351722666683608,
0.00349184335907274, 0.00346394410318992), `EUR/GBP_TotalCount` = structure(c(-0.179518680545716,
-0.0757259172924681, 0.333514120677483, 0.759064450015801, -0.419724789788948,
-0.360414639358521), .Dim = c(6L, 1L)), `EUR/GBP_BloombergCount` = structure(c(-0.701694550941621,
-0.669811381311996, -0.574161872423118, -0.644304845608295, -0.784590791978649,
-0.631551577756444), .Dim = c(6L, 1L)), `EUR/GBP_SocialMediaCount` = structure(c(-1.68861759789696,
-1.66829994393287, -1.5910928588693, -1.59515638966212, -1.6967446594826,
-1.63172816679749), .Dim = c(6L, 1L)), `EUR/GBP_NewsCount` = structure(c(0.76560533722738,
0.879161625683434, 1.33717198912285, 1.90306082659552, 0.487392430510049,
0.487392430510049), .Dim = c(6L, 1L))), na.action = structure(c(`6` = 6L,
`38` = 38L, `74` = 74L, `101` = 101L, `140` = 140L, `165` = 165L,
`189` = 189L, `197` = 197L, `236` = 236L, `256` = 256L, `323` = 323L,
`351` = 351L, `393` = 393L, `423` = 423L, `442` = 442L, `455` = 455L,
`490` = 490L, `510` = 510L, `551` = 551L, `576` = 576L, `605` = 605L,
`646` = 646L, `676` = 676L, `696` = 696L, `708` = 708L, `742` = 742L,
`762` = 762L, `793` = 793L, `829` = 829L, `858` = 858L, `904` = 904L,
`929` = 929L, `950` = 950L, `961` = 961L, `996` = 996L, `1016` = 1016L,
`1089` = 1089L, `1114` = 1114L, `1159` = 1159L, `1184` = 1184L,
`1207` = 1207L, `1216` = 1216L, `1238` = 1238L, `1243` = 1243L,
`1253` = 1253L, `1278` = 1278L, `1315` = 1315L, `1346` = 1346L,
`1372` = 1372L, `1416` = 1416L, `1441` = 1441L, `1473` = 1473L,
`1532` = 1532L, `1599` = 1599L, `1626` = 1626L, `1669` = 1669L,
`1694` = 1694L, `1718` = 1718L, `1726` = 1726L, `1766` = 1766L,
`1786` = 1786L, `1827` = 1827L, `1853` = 1853L, `1881` = 1881L,
`1922` = 1922L, `1952` = 1952L, `1971` = 1971L, `1984` = 1984L,
`2019` = 2019L, `2039` = 2039L, `2075` = 2075L, `2106` = 2106L,
`2135` = 2135L, `2181` = 2181L, `2206` = 2206L, `2227` = 2227L,
`2238` = 2238L, `2273` = 2273L, `2293` = 2293L, `2325` = 2325L,
`2366` = 2366L, `2391` = 2391L, `2436` = 2436L, `2461` = 2461L,
`2483` = 2483L, `2493` = 2493L), class = "omit"), row.names = c(1L,
2L, 3L, 4L, 5L, 7L), class = "data.frame")
I have built 9 regression models per forecast horizon (t+1, t+5 and t+22) and I am using the predict function to make my forecasts. I have coded this in an R loop, where I also try to assign each forecast to a matrix. My code is the following:
EUR/GBP_NewsCount`)
EURGBP_forecast.5[, 1 ] <- predict( EURGBP_HAR_RVt5_train, newdata=data.forecast )
EURGBP_forecast.5[, 2 ] <- predict( EURGBP_HAR_RVt5_NT_train, newdata=data.forecast )
EURGBP_forecast.5[, 3 ] <- predict( EURGBP_HAR_RVBt5_train, newdata=data.forecast )
EURGBP_forecast.5[, 4 ] <- predict( EURGBP_HAR_RVBt5_NT_train, newdata=data.forecast )
EURGBP_forecast.5[, 5 ] <- predict( EURGBP_HAR_RVGt5_train, newdata=data.forecast )
EURGBP_forecast.5[, 6 ] <- predict( EURGBP_HAR_RVGt5_NT_train, newdata=data.forecast )
EURGBP_forecast.5[, 7 ] <- predict( EURGBP_HAR_RVt5_Bloomberg_train, newdata=data.forecast )
EURGBP_forecast.5[, 8 ] <- predict( EURGBP_HAR_RVt5_SocialMedia_train, newdata=data.forecast )
EURGBP_forecast.5[, 9 ] <- predict( EURGBP_HAR_RVt5_News_train, newdata=data.forecast )
EURGBP_actuals.5[, 1] <- data.forecastI am trying to calculate realized volatility forecasts using a rolling window forecast. My aim is to use the first 500 observations to forecast the 501st observations, then shift the window forward one step using observations 2 to 501 to predict the 502nd observation. I want this to repeat until I have a complete pseudo out-of-sample forecast.
My df contains 2411 observations of 23 variables, here is small example:
Date
EUR/GBP_RV t+1
EUR/GBP_RV
EUR/GBP_RV_5
EUR/GBP_RV_22
2012-02-13
0.004019947
0.004467109
0.004995980
0.005150602
2012-02-14
0.004077322
0.004019947
0.004704742
0.005099209
2012-02-15
0.004666244
0.004077322
0.004564522
0.005020790
2012-02-16
0.004582351
0.004666244
0.004532930
0.005011078
2012-02-17
0.003951071
0.004582351
0.004362595
0.004999634
2012-02-21
0.005549329
0.004824547
0.004467109
0.004954358
The head of the df can be reproduced with
structure(list(Date = structure(c(15383, 15384, 15385, 15386,
15387, 15391), class = "Date"), `EUR/GBP_RV t+1,t+22` = c(0.00437808494654599,
0.00439764887779732, 0.00441997330738947, 0.00437799055732722,
0.00435021150904479, 0.00434881306458859), `EUR/GBP_RGV t+1,t+22` = c(0.00310674728131117,
0.00311502965608506, 0.00313756204195853, 0.00312923997431178,
0.00310846773074243, 0.00309755540903969), `EUR/GBP_RBV t+1,t+22` = c(0.00304961980133602,
0.00306866297401415, 0.00307794319983677, 0.00302801249035602,
0.00300946121851254, 0.00302272755554915), `EUR/GBP_RV t+1,t+5` = c(0.00425938711995146,
0.00442030721926592, 0.00471470868108043, 0.00487869292442023,
0.00476849421943949, 0.0046067439660438), `EUR/GBP_RGV t+1,t+5` = c(0.00287718093809447,
0.00311308998902836, 0.00344398536439729, 0.00376911066284235,
0.00377425759242542, 0.00353909902900148), `EUR/GBP_RBV t+1,t+5` = c(0.00313771439501486,
0.00310626895475871, 0.0031789431316576, 0.00305962424370556,
0.00288671182187571, 0.00291630955829613), `EUR/GBP_RV t+1` = c(0.00401994700051122,
0.00407732180013827, 0.00466624428620966, 0.00458235106134663,
0.00395107145155152, 0.00554932910921084), `EUR/GBP_RGV t+1` = c(0.00280067842079775,
0.00275522601341373, 0.00296142025653418, 0.00320716195737542,
0.00266141804235125, 0.00440970289025837), `EUR/GBP_RBV t+1` = c(0.00288377777753365,
0.00300554199386584, 0.00360608177982326, 0.00327292734850446,
0.0029202430753471, 0.00336891287836027), `EUR/GBP_RV` = c(0.00446710941914797,
0.00401994700051122, 0.00407732180013827, 0.00466624428620966,
0.00458235106134663, 0.00482454749708351), `EUR/GBP_RV_5` = c(0.00499598016427624,
0.00470474196716823, 0.00456452150727461, 0.00453292965488229,
0.00436259471347075, 0.00442030721926592), `EUR/GBP_RV_22` = c(0.00515060219897263,
0.00509920878086075, 0.00502079002092667, 0.00501107755050095,
0.00499963428727425, 0.00495435807685843), `EUR/GBP_RBV` = c(0.00324667045338159,
0.00288377777753365, 0.00300554199386584, 0.00360608177982326,
0.00327292734850446, 0.00272655057625291), `EUR/GBP_RBV_5` = c(0.0034985439252634,
0.00318731350301598, 0.00319529774619179, 0.0032799330165155,
0.00320299987062176, 0.00310626895475871), `EUR/GBP_RBV_22` = c(0.0036581887941976,
0.00362298829344015, 0.00355498498935768, 0.0035465419934449,
0.00355752455210586, 0.00351669973034298), `EUR/GBP_RGV` = c(0.00306825643155514,
0.00280067842079775, 0.00275522601341373, 0.00296142025653418,
0.00320716195737542, 0.00398022367546721), `EUR/GBP_RGV_5` = c(0.00353290218424469,
0.00345194162523714, 0.00325362896209417, 0.00312087362386985,
0.00295854861593525, 0.00311308998902836), `EUR/GBP_RGV_22` = c(0.00359974659692405,
0.00356342531619103, 0.00352224165959556, 0.00351722666683608,
0.00349184335907274, 0.00346394410318992), `EUR/GBP_TotalCount` = structure(c(-0.179518680545716,
-0.0757259172924681, 0.333514120677483, 0.759064450015801, -0.419724789788948,
-0.360414639358521), .Dim = c(6L, 1L)), `EUR/GBP_BloombergCount` = structure(c(-0.701694550941621,
-0.669811381311996, -0.574161872423118, -0.644304845608295, -0.784590791978649,
-0.631551577756444), .Dim = c(6L, 1L)), `EUR/GBP_SocialMediaCount` = structure(c(-1.68861759789696,
-1.66829994393287, -1.5910928588693, -1.59515638966212, -1.6967446594826,
-1.63172816679749), .Dim = c(6L, 1L)), `EUR/GBP_NewsCount` = structure(c(0.76560533722738,
0.879161625683434, 1.33717198912285, 1.90306082659552, 0.487392430510049,
0.487392430510049), .Dim = c(6L, 1L))), na.action = structure(c(`6` = 6L,
`38` = 38L, `74` = 74L, `101` = 101L, `140` = 140L, `165` = 165L,
`189` = 189L, `197` = 197L, `236` = 236L, `256` = 256L, `323` = 323L,
`351` = 351L, `393` = 393L, `423` = 423L, `442` = 442L, `455` = 455L,
`490` = 490L, `510` = 510L, `551` = 551L, `576` = 576L, `605` = 605L,
`646` = 646L, `676` = 676L, `696` = 696L, `708` = 708L, `742` = 742L,
`762` = 762L, `793` = 793L, `829` = 829L, `858` = 858L, `904` = 904L,
`929` = 929L, `950` = 950L, `961` = 961L, `996` = 996L, `1016` = 1016L,
`1089` = 1089L, `1114` = 1114L, `1159` = 1159L, `1184` = 1184L,
`1207` = 1207L, `1216` = 1216L, `1238` = 1238L, `1243` = 1243L,
`1253` = 1253L, `1278` = 1278L, `1315` = 1315L, `1346` = 1346L,
`1372` = 1372L, `1416` = 1416L, `1441` = 1441L, `1473` = 1473L,
`1532` = 1532L, `1599` = 1599L, `1626` = 1626L, `1669` = 1669L,
`1694` = 1694L, `1718` = 1718L, `1726` = 1726L, `1766` = 1766L,
`1786` = 1786L, `1827` = 1827L, `1853` = 1853L, `1881` = 1881L,
`1922` = 1922L, `1952` = 1952L, `1971` = 1971L, `1984` = 1984L,
`2019` = 2019L, `2039` = 2039L, `2075` = 2075L, `2106` = 2106L,
`2135` = 2135L, `2181` = 2181L, `2206` = 2206L, `2227` = 2227L,
`2238` = 2238L, `2273` = 2273L, `2293` = 2293L, `2325` = 2325L,
`2366` = 2366L, `2391` = 2391L, `2436` = 2436L, `2461` = 2461L,
`2483` = 2483L, `2493` = 2493L), class = "omit"), row.names = c(1L,
2L, 3L, 4L, 5L, 7L), class = "data.frame")
I have built 9 regression models per forecast horizon (t+1, t+5 and t+22) and I am using the predict function to make my forecasts. I have coded this in an R loop, where I also try to assign each forecast to a matrix. My code is the following:
EUR/GBP_RV t+1,t+5`
# --------------------------------------
# Forecast horizon 22
# --------------------------------------
EURGBP_HAR_RVt22_train <- lm(data.estimateI am trying to calculate realized volatility forecasts using a rolling window forecast. My aim is to use the first 500 observations to forecast the 501st observations, then shift the window forward one step using observations 2 to 501 to predict the 502nd observation. I want this to repeat until I have a complete pseudo out-of-sample forecast.
My df contains 2411 observations of 23 variables, here is small example:
Date
EUR/GBP_RV t+1
EUR/GBP_RV
EUR/GBP_RV_5
EUR/GBP_RV_22
2012-02-13
0.004019947
0.004467109
0.004995980
0.005150602
2012-02-14
0.004077322
0.004019947
0.004704742
0.005099209
2012-02-15
0.004666244
0.004077322
0.004564522
0.005020790
2012-02-16
0.004582351
0.004666244
0.004532930
0.005011078
2012-02-17
0.003951071
0.004582351
0.004362595
0.004999634
2012-02-21
0.005549329
0.004824547
0.004467109
0.004954358
The head of the df can be reproduced with
structure(list(Date = structure(c(15383, 15384, 15385, 15386,
15387, 15391), class = "Date"), `EUR/GBP_RV t+1,t+22` = c(0.00437808494654599,
0.00439764887779732, 0.00441997330738947, 0.00437799055732722,
0.00435021150904479, 0.00434881306458859), `EUR/GBP_RGV t+1,t+22` = c(0.00310674728131117,
0.00311502965608506, 0.00313756204195853, 0.00312923997431178,
0.00310846773074243, 0.00309755540903969), `EUR/GBP_RBV t+1,t+22` = c(0.00304961980133602,
0.00306866297401415, 0.00307794319983677, 0.00302801249035602,
0.00300946121851254, 0.00302272755554915), `EUR/GBP_RV t+1,t+5` = c(0.00425938711995146,
0.00442030721926592, 0.00471470868108043, 0.00487869292442023,
0.00476849421943949, 0.0046067439660438), `EUR/GBP_RGV t+1,t+5` = c(0.00287718093809447,
0.00311308998902836, 0.00344398536439729, 0.00376911066284235,
0.00377425759242542, 0.00353909902900148), `EUR/GBP_RBV t+1,t+5` = c(0.00313771439501486,
0.00310626895475871, 0.0031789431316576, 0.00305962424370556,
0.00288671182187571, 0.00291630955829613), `EUR/GBP_RV t+1` = c(0.00401994700051122,
0.00407732180013827, 0.00466624428620966, 0.00458235106134663,
0.00395107145155152, 0.00554932910921084), `EUR/GBP_RGV t+1` = c(0.00280067842079775,
0.00275522601341373, 0.00296142025653418, 0.00320716195737542,
0.00266141804235125, 0.00440970289025837), `EUR/GBP_RBV t+1` = c(0.00288377777753365,
0.00300554199386584, 0.00360608177982326, 0.00327292734850446,
0.0029202430753471, 0.00336891287836027), `EUR/GBP_RV` = c(0.00446710941914797,
0.00401994700051122, 0.00407732180013827, 0.00466624428620966,
0.00458235106134663, 0.00482454749708351), `EUR/GBP_RV_5` = c(0.00499598016427624,
0.00470474196716823, 0.00456452150727461, 0.00453292965488229,
0.00436259471347075, 0.00442030721926592), `EUR/GBP_RV_22` = c(0.00515060219897263,
0.00509920878086075, 0.00502079002092667, 0.00501107755050095,
0.00499963428727425, 0.00495435807685843), `EUR/GBP_RBV` = c(0.00324667045338159,
0.00288377777753365, 0.00300554199386584, 0.00360608177982326,
0.00327292734850446, 0.00272655057625291), `EUR/GBP_RBV_5` = c(0.0034985439252634,
0.00318731350301598, 0.00319529774619179, 0.0032799330165155,
0.00320299987062176, 0.00310626895475871), `EUR/GBP_RBV_22` = c(0.0036581887941976,
0.00362298829344015, 0.00355498498935768, 0.0035465419934449,
0.00355752455210586, 0.00351669973034298), `EUR/GBP_RGV` = c(0.00306825643155514,
0.00280067842079775, 0.00275522601341373, 0.00296142025653418,
0.00320716195737542, 0.00398022367546721), `EUR/GBP_RGV_5` = c(0.00353290218424469,
0.00345194162523714, 0.00325362896209417, 0.00312087362386985,
0.00295854861593525, 0.00311308998902836), `EUR/GBP_RGV_22` = c(0.00359974659692405,
0.00356342531619103, 0.00352224165959556, 0.00351722666683608,
0.00349184335907274, 0.00346394410318992), `EUR/GBP_TotalCount` = structure(c(-0.179518680545716,
-0.0757259172924681, 0.333514120677483, 0.759064450015801, -0.419724789788948,
-0.360414639358521), .Dim = c(6L, 1L)), `EUR/GBP_BloombergCount` = structure(c(-0.701694550941621,
-0.669811381311996, -0.574161872423118, -0.644304845608295, -0.784590791978649,
-0.631551577756444), .Dim = c(6L, 1L)), `EUR/GBP_SocialMediaCount` = structure(c(-1.68861759789696,
-1.66829994393287, -1.5910928588693, -1.59515638966212, -1.6967446594826,
-1.63172816679749), .Dim = c(6L, 1L)), `EUR/GBP_NewsCount` = structure(c(0.76560533722738,
0.879161625683434, 1.33717198912285, 1.90306082659552, 0.487392430510049,
0.487392430510049), .Dim = c(6L, 1L))), na.action = structure(c(`6` = 6L,
`38` = 38L, `74` = 74L, `101` = 101L, `140` = 140L, `165` = 165L,
`189` = 189L, `197` = 197L, `236` = 236L, `256` = 256L, `323` = 323L,
`351` = 351L, `393` = 393L, `423` = 423L, `442` = 442L, `455` = 455L,
`490` = 490L, `510` = 510L, `551` = 551L, `576` = 576L, `605` = 605L,
`646` = 646L, `676` = 676L, `696` = 696L, `708` = 708L, `742` = 742L,
`762` = 762L, `793` = 793L, `829` = 829L, `858` = 858L, `904` = 904L,
`929` = 929L, `950` = 950L, `961` = 961L, `996` = 996L, `1016` = 1016L,
`1089` = 1089L, `1114` = 1114L, `1159` = 1159L, `1184` = 1184L,
`1207` = 1207L, `1216` = 1216L, `1238` = 1238L, `1243` = 1243L,
`1253` = 1253L, `1278` = 1278L, `1315` = 1315L, `1346` = 1346L,
`1372` = 1372L, `1416` = 1416L, `1441` = 1441L, `1473` = 1473L,
`1532` = 1532L, `1599` = 1599L, `1626` = 1626L, `1669` = 1669L,
`1694` = 1694L, `1718` = 1718L, `1726` = 1726L, `1766` = 1766L,
`1786` = 1786L, `1827` = 1827L, `1853` = 1853L, `1881` = 1881L,
`1922` = 1922L, `1952` = 1952L, `1971` = 1971L, `1984` = 1984L,
`2019` = 2019L, `2039` = 2039L, `2075` = 2075L, `2106` = 2106L,
`2135` = 2135L, `2181` = 2181L, `2206` = 2206L, `2227` = 2227L,
`2238` = 2238L, `2273` = 2273L, `2293` = 2293L, `2325` = 2325L,
`2366` = 2366L, `2391` = 2391L, `2436` = 2436L, `2461` = 2461L,
`2483` = 2483L, `2493` = 2493L), class = "omit"), row.names = c(1L,
2L, 3L, 4L, 5L, 7L), class = "data.frame")
I have built 9 regression models per forecast horizon (t+1, t+5 and t+22) and I am using the predict function to make my forecasts. I have coded this in an R loop, where I also try to assign each forecast to a matrix. My code is the following:
EUR/GBP_RV t+1,t+22`~data.estimateI am trying to calculate realized volatility forecasts using a rolling window forecast. My aim is to use the first 500 observations to forecast the 501st observations, then shift the window forward one step using observations 2 to 501 to predict the 502nd observation. I want this to repeat until I have a complete pseudo out-of-sample forecast.
My df contains 2411 observations of 23 variables, here is small example:
Date
EUR/GBP_RV t+1
EUR/GBP_RV
EUR/GBP_RV_5
EUR/GBP_RV_22
2012-02-13
0.004019947
0.004467109
0.004995980
0.005150602
2012-02-14
0.004077322
0.004019947
0.004704742
0.005099209
2012-02-15
0.004666244
0.004077322
0.004564522
0.005020790
2012-02-16
0.004582351
0.004666244
0.004532930
0.005011078
2012-02-17
0.003951071
0.004582351
0.004362595
0.004999634
2012-02-21
0.005549329
0.004824547
0.004467109
0.004954358
The head of the df can be reproduced with
structure(list(Date = structure(c(15383, 15384, 15385, 15386,
15387, 15391), class = "Date"), `EUR/GBP_RV t+1,t+22` = c(0.00437808494654599,
0.00439764887779732, 0.00441997330738947, 0.00437799055732722,
0.00435021150904479, 0.00434881306458859), `EUR/GBP_RGV t+1,t+22` = c(0.00310674728131117,
0.00311502965608506, 0.00313756204195853, 0.00312923997431178,
0.00310846773074243, 0.00309755540903969), `EUR/GBP_RBV t+1,t+22` = c(0.00304961980133602,
0.00306866297401415, 0.00307794319983677, 0.00302801249035602,
0.00300946121851254, 0.00302272755554915), `EUR/GBP_RV t+1,t+5` = c(0.00425938711995146,
0.00442030721926592, 0.00471470868108043, 0.00487869292442023,
0.00476849421943949, 0.0046067439660438), `EUR/GBP_RGV t+1,t+5` = c(0.00287718093809447,
0.00311308998902836, 0.00344398536439729, 0.00376911066284235,
0.00377425759242542, 0.00353909902900148), `EUR/GBP_RBV t+1,t+5` = c(0.00313771439501486,
0.00310626895475871, 0.0031789431316576, 0.00305962424370556,
0.00288671182187571, 0.00291630955829613), `EUR/GBP_RV t+1` = c(0.00401994700051122,
0.00407732180013827, 0.00466624428620966, 0.00458235106134663,
0.00395107145155152, 0.00554932910921084), `EUR/GBP_RGV t+1` = c(0.00280067842079775,
0.00275522601341373, 0.00296142025653418, 0.00320716195737542,
0.00266141804235125, 0.00440970289025837), `EUR/GBP_RBV t+1` = c(0.00288377777753365,
0.00300554199386584, 0.00360608177982326, 0.00327292734850446,
0.0029202430753471, 0.00336891287836027), `EUR/GBP_RV` = c(0.00446710941914797,
0.00401994700051122, 0.00407732180013827, 0.00466624428620966,
0.00458235106134663, 0.00482454749708351), `EUR/GBP_RV_5` = c(0.00499598016427624,
0.00470474196716823, 0.00456452150727461, 0.00453292965488229,
0.00436259471347075, 0.00442030721926592), `EUR/GBP_RV_22` = c(0.00515060219897263,
0.00509920878086075, 0.00502079002092667, 0.00501107755050095,
0.00499963428727425, 0.00495435807685843), `EUR/GBP_RBV` = c(0.00324667045338159,
0.00288377777753365, 0.00300554199386584, 0.00360608177982326,
0.00327292734850446, 0.00272655057625291), `EUR/GBP_RBV_5` = c(0.0034985439252634,
0.00318731350301598, 0.00319529774619179, 0.0032799330165155,
0.00320299987062176, 0.00310626895475871), `EUR/GBP_RBV_22` = c(0.0036581887941976,
0.00362298829344015, 0.00355498498935768, 0.0035465419934449,
0.00355752455210586, 0.00351669973034298), `EUR/GBP_RGV` = c(0.00306825643155514,
0.00280067842079775, 0.00275522601341373, 0.00296142025653418,
0.00320716195737542, 0.00398022367546721), `EUR/GBP_RGV_5` = c(0.00353290218424469,
0.00345194162523714, 0.00325362896209417, 0.00312087362386985,
0.00295854861593525, 0.00311308998902836), `EUR/GBP_RGV_22` = c(0.00359974659692405,
0.00356342531619103, 0.00352224165959556, 0.00351722666683608,
0.00349184335907274, 0.00346394410318992), `EUR/GBP_TotalCount` = structure(c(-0.179518680545716,
-0.0757259172924681, 0.333514120677483, 0.759064450015801, -0.419724789788948,
-0.360414639358521), .Dim = c(6L, 1L)), `EUR/GBP_BloombergCount` = structure(c(-0.701694550941621,
-0.669811381311996, -0.574161872423118, -0.644304845608295, -0.784590791978649,
-0.631551577756444), .Dim = c(6L, 1L)), `EUR/GBP_SocialMediaCount` = structure(c(-1.68861759789696,
-1.66829994393287, -1.5910928588693, -1.59515638966212, -1.6967446594826,
-1.63172816679749), .Dim = c(6L, 1L)), `EUR/GBP_NewsCount` = structure(c(0.76560533722738,
0.879161625683434, 1.33717198912285, 1.90306082659552, 0.487392430510049,
0.487392430510049), .Dim = c(6L, 1L))), na.action = structure(c(`6` = 6L,
`38` = 38L, `74` = 74L, `101` = 101L, `140` = 140L, `165` = 165L,
`189` = 189L, `197` = 197L, `236` = 236L, `256` = 256L, `323` = 323L,
`351` = 351L, `393` = 393L, `423` = 423L, `442` = 442L, `455` = 455L,
`490` = 490L, `510` = 510L, `551` = 551L, `576` = 576L, `605` = 605L,
`646` = 646L, `676` = 676L, `696` = 696L, `708` = 708L, `742` = 742L,
`762` = 762L, `793` = 793L, `829` = 829L, `858` = 858L, `904` = 904L,
`929` = 929L, `950` = 950L, `961` = 961L, `996` = 996L, `1016` = 1016L,
`1089` = 1089L, `1114` = 1114L, `1159` = 1159L, `1184` = 1184L,
`1207` = 1207L, `1216` = 1216L, `1238` = 1238L, `1243` = 1243L,
`1253` = 1253L, `1278` = 1278L, `1315` = 1315L, `1346` = 1346L,
`1372` = 1372L, `1416` = 1416L, `1441` = 1441L, `1473` = 1473L,
`1532` = 1532L, `1599` = 1599L, `1626` = 1626L, `1669` = 1669L,
`1694` = 1694L, `1718` = 1718L, `1726` = 1726L, `1766` = 1766L,
`1786` = 1786L, `1827` = 1827L, `1853` = 1853L, `1881` = 1881L,
`1922` = 1922L, `1952` = 1952L, `1971` = 1971L, `1984` = 1984L,
`2019` = 2019L, `2039` = 2039L, `2075` = 2075L, `2106` = 2106L,
`2135` = 2135L, `2181` = 2181L, `2206` = 2206L, `2227` = 2227L,
`2238` = 2238L, `2273` = 2273L, `2293` = 2293L, `2325` = 2325L,
`2366` = 2366L, `2391` = 2391L, `2436` = 2436L, `2461` = 2461L,
`2483` = 2483L, `2493` = 2493L), class = "omit"), row.names = c(1L,
2L, 3L, 4L, 5L, 7L), class = "data.frame")
I have built 9 regression models per forecast horizon (t+1, t+5 and t+22) and I am using the predict function to make my forecasts. I have coded this in an R loop, where I also try to assign each forecast to a matrix. My code is the following:
EUR/GBP_RV`+data.estimateI am trying to calculate realized volatility forecasts using a rolling window forecast. My aim is to use the first 500 observations to forecast the 501st observations, then shift the window forward one step using observations 2 to 501 to predict the 502nd observation. I want this to repeat until I have a complete pseudo out-of-sample forecast.
My df contains 2411 observations of 23 variables, here is small example:
Date
EUR/GBP_RV t+1
EUR/GBP_RV
EUR/GBP_RV_5
EUR/GBP_RV_22
2012-02-13
0.004019947
0.004467109
0.004995980
0.005150602
2012-02-14
0.004077322
0.004019947
0.004704742
0.005099209
2012-02-15
0.004666244
0.004077322
0.004564522
0.005020790
2012-02-16
0.004582351
0.004666244
0.004532930
0.005011078
2012-02-17
0.003951071
0.004582351
0.004362595
0.004999634
2012-02-21
0.005549329
0.004824547
0.004467109
0.004954358
The head of the df can be reproduced with
structure(list(Date = structure(c(15383, 15384, 15385, 15386,
15387, 15391), class = "Date"), `EUR/GBP_RV t+1,t+22` = c(0.00437808494654599,
0.00439764887779732, 0.00441997330738947, 0.00437799055732722,
0.00435021150904479, 0.00434881306458859), `EUR/GBP_RGV t+1,t+22` = c(0.00310674728131117,
0.00311502965608506, 0.00313756204195853, 0.00312923997431178,
0.00310846773074243, 0.00309755540903969), `EUR/GBP_RBV t+1,t+22` = c(0.00304961980133602,
0.00306866297401415, 0.00307794319983677, 0.00302801249035602,
0.00300946121851254, 0.00302272755554915), `EUR/GBP_RV t+1,t+5` = c(0.00425938711995146,
0.00442030721926592, 0.00471470868108043, 0.00487869292442023,
0.00476849421943949, 0.0046067439660438), `EUR/GBP_RGV t+1,t+5` = c(0.00287718093809447,
0.00311308998902836, 0.00344398536439729, 0.00376911066284235,
0.00377425759242542, 0.00353909902900148), `EUR/GBP_RBV t+1,t+5` = c(0.00313771439501486,
0.00310626895475871, 0.0031789431316576, 0.00305962424370556,
0.00288671182187571, 0.00291630955829613), `EUR/GBP_RV t+1` = c(0.00401994700051122,
0.00407732180013827, 0.00466624428620966, 0.00458235106134663,
0.00395107145155152, 0.00554932910921084), `EUR/GBP_RGV t+1` = c(0.00280067842079775,
0.00275522601341373, 0.00296142025653418, 0.00320716195737542,
0.00266141804235125, 0.00440970289025837), `EUR/GBP_RBV t+1` = c(0.00288377777753365,
0.00300554199386584, 0.00360608177982326, 0.00327292734850446,
0.0029202430753471, 0.00336891287836027), `EUR/GBP_RV` = c(0.00446710941914797,
0.00401994700051122, 0.00407732180013827, 0.00466624428620966,
0.00458235106134663, 0.00482454749708351), `EUR/GBP_RV_5` = c(0.00499598016427624,
0.00470474196716823, 0.00456452150727461, 0.00453292965488229,
0.00436259471347075, 0.00442030721926592), `EUR/GBP_RV_22` = c(0.00515060219897263,
0.00509920878086075, 0.00502079002092667, 0.00501107755050095,
0.00499963428727425, 0.00495435807685843), `EUR/GBP_RBV` = c(0.00324667045338159,
0.00288377777753365, 0.00300554199386584, 0.00360608177982326,
0.00327292734850446, 0.00272655057625291), `EUR/GBP_RBV_5` = c(0.0034985439252634,
0.00318731350301598, 0.00319529774619179, 0.0032799330165155,
0.00320299987062176, 0.00310626895475871), `EUR/GBP_RBV_22` = c(0.0036581887941976,
0.00362298829344015, 0.00355498498935768, 0.0035465419934449,
0.00355752455210586, 0.00351669973034298), `EUR/GBP_RGV` = c(0.00306825643155514,
0.00280067842079775, 0.00275522601341373, 0.00296142025653418,
0.00320716195737542, 0.00398022367546721), `EUR/GBP_RGV_5` = c(0.00353290218424469,
0.00345194162523714, 0.00325362896209417, 0.00312087362386985,
0.00295854861593525, 0.00311308998902836), `EUR/GBP_RGV_22` = c(0.00359974659692405,
0.00356342531619103, 0.00352224165959556, 0.00351722666683608,
0.00349184335907274, 0.00346394410318992), `EUR/GBP_TotalCount` = structure(c(-0.179518680545716,
-0.0757259172924681, 0.333514120677483, 0.759064450015801, -0.419724789788948,
-0.360414639358521), .Dim = c(6L, 1L)), `EUR/GBP_BloombergCount` = structure(c(-0.701694550941621,
-0.669811381311996, -0.574161872423118, -0.644304845608295, -0.784590791978649,
-0.631551577756444), .Dim = c(6L, 1L)), `EUR/GBP_SocialMediaCount` = structure(c(-1.68861759789696,
-1.66829994393287, -1.5910928588693, -1.59515638966212, -1.6967446594826,
-1.63172816679749), .Dim = c(6L, 1L)), `EUR/GBP_NewsCount` = structure(c(0.76560533722738,
0.879161625683434, 1.33717198912285, 1.90306082659552, 0.487392430510049,
0.487392430510049), .Dim = c(6L, 1L))), na.action = structure(c(`6` = 6L,
`38` = 38L, `74` = 74L, `101` = 101L, `140` = 140L, `165` = 165L,
`189` = 189L, `197` = 197L, `236` = 236L, `256` = 256L, `323` = 323L,
`351` = 351L, `393` = 393L, `423` = 423L, `442` = 442L, `455` = 455L,
`490` = 490L, `510` = 510L, `551` = 551L, `576` = 576L, `605` = 605L,
`646` = 646L, `676` = 676L, `696` = 696L, `708` = 708L, `742` = 742L,
`762` = 762L, `793` = 793L, `829` = 829L, `858` = 858L, `904` = 904L,
`929` = 929L, `950` = 950L, `961` = 961L, `996` = 996L, `1016` = 1016L,
`1089` = 1089L, `1114` = 1114L, `1159` = 1159L, `1184` = 1184L,
`1207` = 1207L, `1216` = 1216L, `1238` = 1238L, `1243` = 1243L,
`1253` = 1253L, `1278` = 1278L, `1315` = 1315L, `1346` = 1346L,
`1372` = 1372L, `1416` = 1416L, `1441` = 1441L, `1473` = 1473L,
`1532` = 1532L, `1599` = 1599L, `1626` = 1626L, `1669` = 1669L,
`1694` = 1694L, `1718` = 1718L, `1726` = 1726L, `1766` = 1766L,
`1786` = 1786L, `1827` = 1827L, `1853` = 1853L, `1881` = 1881L,
`1922` = 1922L, `1952` = 1952L, `1971` = 1971L, `1984` = 1984L,
`2019` = 2019L, `2039` = 2039L, `2075` = 2075L, `2106` = 2106L,
`2135` = 2135L, `2181` = 2181L, `2206` = 2206L, `2227` = 2227L,
`2238` = 2238L, `2273` = 2273L, `2293` = 2293L, `2325` = 2325L,
`2366` = 2366L, `2391` = 2391L, `2436` = 2436L, `2461` = 2461L,
`2483` = 2483L, `2493` = 2493L), class = "omit"), row.names = c(1L,
2L, 3L, 4L, 5L, 7L), class = "data.frame")
I have built 9 regression models per forecast horizon (t+1, t+5 and t+22) and I am using the predict function to make my forecasts. I have coded this in an R loop, where I also try to assign each forecast to a matrix. My code is the following:
EUR/GBP_RV_5`+data.estimateI am trying to calculate realized volatility forecasts using a rolling window forecast. My aim is to use the first 500 observations to forecast the 501st observations, then shift the window forward one step using observations 2 to 501 to predict the 502nd observation. I want this to repeat until I have a complete pseudo out-of-sample forecast.
My df contains 2411 observations of 23 variables, here is small example:
Date
EUR/GBP_RV t+1
EUR/GBP_RV
EUR/GBP_RV_5
EUR/GBP_RV_22
2012-02-13
0.004019947
0.004467109
0.004995980
0.005150602
2012-02-14
0.004077322
0.004019947
0.004704742
0.005099209
2012-02-15
0.004666244
0.004077322
0.004564522
0.005020790
2012-02-16
0.004582351
0.004666244
0.004532930
0.005011078
2012-02-17
0.003951071
0.004582351
0.004362595
0.004999634
2012-02-21
0.005549329
0.004824547
0.004467109
0.004954358
The head of the df can be reproduced with
structure(list(Date = structure(c(15383, 15384, 15385, 15386,
15387, 15391), class = "Date"), `EUR/GBP_RV t+1,t+22` = c(0.00437808494654599,
0.00439764887779732, 0.00441997330738947, 0.00437799055732722,
0.00435021150904479, 0.00434881306458859), `EUR/GBP_RGV t+1,t+22` = c(0.00310674728131117,
0.00311502965608506, 0.00313756204195853, 0.00312923997431178,
0.00310846773074243, 0.00309755540903969), `EUR/GBP_RBV t+1,t+22` = c(0.00304961980133602,
0.00306866297401415, 0.00307794319983677, 0.00302801249035602,
0.00300946121851254, 0.00302272755554915), `EUR/GBP_RV t+1,t+5` = c(0.00425938711995146,
0.00442030721926592, 0.00471470868108043, 0.00487869292442023,
0.00476849421943949, 0.0046067439660438), `EUR/GBP_RGV t+1,t+5` = c(0.00287718093809447,
0.00311308998902836, 0.00344398536439729, 0.00376911066284235,
0.00377425759242542, 0.00353909902900148), `EUR/GBP_RBV t+1,t+5` = c(0.00313771439501486,
0.00310626895475871, 0.0031789431316576, 0.00305962424370556,
0.00288671182187571, 0.00291630955829613), `EUR/GBP_RV t+1` = c(0.00401994700051122,
0.00407732180013827, 0.00466624428620966, 0.00458235106134663,
0.00395107145155152, 0.00554932910921084), `EUR/GBP_RGV t+1` = c(0.00280067842079775,
0.00275522601341373, 0.00296142025653418, 0.00320716195737542,
0.00266141804235125, 0.00440970289025837), `EUR/GBP_RBV t+1` = c(0.00288377777753365,
0.00300554199386584, 0.00360608177982326, 0.00327292734850446,
0.0029202430753471, 0.00336891287836027), `EUR/GBP_RV` = c(0.00446710941914797,
0.00401994700051122, 0.00407732180013827, 0.00466624428620966,
0.00458235106134663, 0.00482454749708351), `EUR/GBP_RV_5` = c(0.00499598016427624,
0.00470474196716823, 0.00456452150727461, 0.00453292965488229,
0.00436259471347075, 0.00442030721926592), `EUR/GBP_RV_22` = c(0.00515060219897263,
0.00509920878086075, 0.00502079002092667, 0.00501107755050095,
0.00499963428727425, 0.00495435807685843), `EUR/GBP_RBV` = c(0.00324667045338159,
0.00288377777753365, 0.00300554199386584, 0.00360608177982326,
0.00327292734850446, 0.00272655057625291), `EUR/GBP_RBV_5` = c(0.0034985439252634,
0.00318731350301598, 0.00319529774619179, 0.0032799330165155,
0.00320299987062176, 0.00310626895475871), `EUR/GBP_RBV_22` = c(0.0036581887941976,
0.00362298829344015, 0.00355498498935768, 0.0035465419934449,
0.00355752455210586, 0.00351669973034298), `EUR/GBP_RGV` = c(0.00306825643155514,
0.00280067842079775, 0.00275522601341373, 0.00296142025653418,
0.00320716195737542, 0.00398022367546721), `EUR/GBP_RGV_5` = c(0.00353290218424469,
0.00345194162523714, 0.00325362896209417, 0.00312087362386985,
0.00295854861593525, 0.00311308998902836), `EUR/GBP_RGV_22` = c(0.00359974659692405,
0.00356342531619103, 0.00352224165959556, 0.00351722666683608,
0.00349184335907274, 0.00346394410318992), `EUR/GBP_TotalCount` = structure(c(-0.179518680545716,
-0.0757259172924681, 0.333514120677483, 0.759064450015801, -0.419724789788948,
-0.360414639358521), .Dim = c(6L, 1L)), `EUR/GBP_BloombergCount` = structure(c(-0.701694550941621,
-0.669811381311996, -0.574161872423118, -0.644304845608295, -0.784590791978649,
-0.631551577756444), .Dim = c(6L, 1L)), `EUR/GBP_SocialMediaCount` = structure(c(-1.68861759789696,
-1.66829994393287, -1.5910928588693, -1.59515638966212, -1.6967446594826,
-1.63172816679749), .Dim = c(6L, 1L)), `EUR/GBP_NewsCount` = structure(c(0.76560533722738,
0.879161625683434, 1.33717198912285, 1.90306082659552, 0.487392430510049,
0.487392430510049), .Dim = c(6L, 1L))), na.action = structure(c(`6` = 6L,
`38` = 38L, `74` = 74L, `101` = 101L, `140` = 140L, `165` = 165L,
`189` = 189L, `197` = 197L, `236` = 236L, `256` = 256L, `323` = 323L,
`351` = 351L, `393` = 393L, `423` = 423L, `442` = 442L, `455` = 455L,
`490` = 490L, `510` = 510L, `551` = 551L, `576` = 576L, `605` = 605L,
`646` = 646L, `676` = 676L, `696` = 696L, `708` = 708L, `742` = 742L,
`762` = 762L, `793` = 793L, `829` = 829L, `858` = 858L, `904` = 904L,
`929` = 929L, `950` = 950L, `961` = 961L, `996` = 996L, `1016` = 1016L,
`1089` = 1089L, `1114` = 1114L, `1159` = 1159L, `1184` = 1184L,
`1207` = 1207L, `1216` = 1216L, `1238` = 1238L, `1243` = 1243L,
`1253` = 1253L, `1278` = 1278L, `1315` = 1315L, `1346` = 1346L,
`1372` = 1372L, `1416` = 1416L, `1441` = 1441L, `1473` = 1473L,
`1532` = 1532L, `1599` = 1599L, `1626` = 1626L, `1669` = 1669L,
`1694` = 1694L, `1718` = 1718L, `1726` = 1726L, `1766` = 1766L,
`1786` = 1786L, `1827` = 1827L, `1853` = 1853L, `1881` = 1881L,
`1922` = 1922L, `1952` = 1952L, `1971` = 1971L, `1984` = 1984L,
`2019` = 2019L, `2039` = 2039L, `2075` = 2075L, `2106` = 2106L,
`2135` = 2135L, `2181` = 2181L, `2206` = 2206L, `2227` = 2227L,
`2238` = 2238L, `2273` = 2273L, `2293` = 2293L, `2325` = 2325L,
`2366` = 2366L, `2391` = 2391L, `2436` = 2436L, `2461` = 2461L,
`2483` = 2483L, `2493` = 2493L), class = "omit"), row.names = c(1L,
2L, 3L, 4L, 5L, 7L), class = "data.frame")
I have built 9 regression models per forecast horizon (t+1, t+5 and t+22) and I am using the predict function to make my forecasts. I have coded this in an R loop, where I also try to assign each forecast to a matrix. My code is the following:
EUR/GBP_RV_22`)
EURGBP_HAR_RVt22_NT_train <- lm(data.estimateI am trying to calculate realized volatility forecasts using a rolling window forecast. My aim is to use the first 500 observations to forecast the 501st observations, then shift the window forward one step using observations 2 to 501 to predict the 502nd observation. I want this to repeat until I have a complete pseudo out-of-sample forecast.
My df contains 2411 observations of 23 variables, here is small example:
Date
EUR/GBP_RV t+1
EUR/GBP_RV
EUR/GBP_RV_5
EUR/GBP_RV_22
2012-02-13
0.004019947
0.004467109
0.004995980
0.005150602
2012-02-14
0.004077322
0.004019947
0.004704742
0.005099209
2012-02-15
0.004666244
0.004077322
0.004564522
0.005020790
2012-02-16
0.004582351
0.004666244
0.004532930
0.005011078
2012-02-17
0.003951071
0.004582351
0.004362595
0.004999634
2012-02-21
0.005549329
0.004824547
0.004467109
0.004954358
The head of the df can be reproduced with
structure(list(Date = structure(c(15383, 15384, 15385, 15386,
15387, 15391), class = "Date"), `EUR/GBP_RV t+1,t+22` = c(0.00437808494654599,
0.00439764887779732, 0.00441997330738947, 0.00437799055732722,
0.00435021150904479, 0.00434881306458859), `EUR/GBP_RGV t+1,t+22` = c(0.00310674728131117,
0.00311502965608506, 0.00313756204195853, 0.00312923997431178,
0.00310846773074243, 0.00309755540903969), `EUR/GBP_RBV t+1,t+22` = c(0.00304961980133602,
0.00306866297401415, 0.00307794319983677, 0.00302801249035602,
0.00300946121851254, 0.00302272755554915), `EUR/GBP_RV t+1,t+5` = c(0.00425938711995146,
0.00442030721926592, 0.00471470868108043, 0.00487869292442023,
0.00476849421943949, 0.0046067439660438), `EUR/GBP_RGV t+1,t+5` = c(0.00287718093809447,
0.00311308998902836, 0.00344398536439729, 0.00376911066284235,
0.00377425759242542, 0.00353909902900148), `EUR/GBP_RBV t+1,t+5` = c(0.00313771439501486,
0.00310626895475871, 0.0031789431316576, 0.00305962424370556,
0.00288671182187571, 0.00291630955829613), `EUR/GBP_RV t+1` = c(0.00401994700051122,
0.00407732180013827, 0.00466624428620966, 0.00458235106134663,
0.00395107145155152, 0.00554932910921084), `EUR/GBP_RGV t+1` = c(0.00280067842079775,
0.00275522601341373, 0.00296142025653418, 0.00320716195737542,
0.00266141804235125, 0.00440970289025837), `EUR/GBP_RBV t+1` = c(0.00288377777753365,
0.00300554199386584, 0.00360608177982326, 0.00327292734850446,
0.0029202430753471, 0.00336891287836027), `EUR/GBP_RV` = c(0.00446710941914797,
0.00401994700051122, 0.00407732180013827, 0.00466624428620966,
0.00458235106134663, 0.00482454749708351), `EUR/GBP_RV_5` = c(0.00499598016427624,
0.00470474196716823, 0.00456452150727461, 0.00453292965488229,
0.00436259471347075, 0.00442030721926592), `EUR/GBP_RV_22` = c(0.00515060219897263,
0.00509920878086075, 0.00502079002092667, 0.00501107755050095,
0.00499963428727425, 0.00495435807685843), `EUR/GBP_RBV` = c(0.00324667045338159,
0.00288377777753365, 0.00300554199386584, 0.00360608177982326,
0.00327292734850446, 0.00272655057625291), `EUR/GBP_RBV_5` = c(0.0034985439252634,
0.00318731350301598, 0.00319529774619179, 0.0032799330165155,
0.00320299987062176, 0.00310626895475871), `EUR/GBP_RBV_22` = c(0.0036581887941976,
0.00362298829344015, 0.00355498498935768, 0.0035465419934449,
0.00355752455210586, 0.00351669973034298), `EUR/GBP_RGV` = c(0.00306825643155514,
0.00280067842079775, 0.00275522601341373, 0.00296142025653418,
0.00320716195737542, 0.00398022367546721), `EUR/GBP_RGV_5` = c(0.00353290218424469,
0.00345194162523714, 0.00325362896209417, 0.00312087362386985,
0.00295854861593525, 0.00311308998902836), `EUR/GBP_RGV_22` = c(0.00359974659692405,
0.00356342531619103, 0.00352224165959556, 0.00351722666683608,
0.00349184335907274, 0.00346394410318992), `EUR/GBP_TotalCount` = structure(c(-0.179518680545716,
-0.0757259172924681, 0.333514120677483, 0.759064450015801, -0.419724789788948,
-0.360414639358521), .Dim = c(6L, 1L)), `EUR/GBP_BloombergCount` = structure(c(-0.701694550941621,
-0.669811381311996, -0.574161872423118, -0.644304845608295, -0.784590791978649,
-0.631551577756444), .Dim = c(6L, 1L)), `EUR/GBP_SocialMediaCount` = structure(c(-1.68861759789696,
-1.66829994393287, -1.5910928588693, -1.59515638966212, -1.6967446594826,
-1.63172816679749), .Dim = c(6L, 1L)), `EUR/GBP_NewsCount` = structure(c(0.76560533722738,
0.879161625683434, 1.33717198912285, 1.90306082659552, 0.487392430510049,
0.487392430510049), .Dim = c(6L, 1L))), na.action = structure(c(`6` = 6L,
`38` = 38L, `74` = 74L, `101` = 101L, `140` = 140L, `165` = 165L,
`189` = 189L, `197` = 197L, `236` = 236L, `256` = 256L, `323` = 323L,
`351` = 351L, `393` = 393L, `423` = 423L, `442` = 442L, `455` = 455L,
`490` = 490L, `510` = 510L, `551` = 551L, `576` = 576L, `605` = 605L,
`646` = 646L, `676` = 676L, `696` = 696L, `708` = 708L, `742` = 742L,
`762` = 762L, `793` = 793L, `829` = 829L, `858` = 858L, `904` = 904L,
`929` = 929L, `950` = 950L, `961` = 961L, `996` = 996L, `1016` = 1016L,
`1089` = 1089L, `1114` = 1114L, `1159` = 1159L, `1184` = 1184L,
`1207` = 1207L, `1216` = 1216L, `1238` = 1238L, `1243` = 1243L,
`1253` = 1253L, `1278` = 1278L, `1315` = 1315L, `1346` = 1346L,
`1372` = 1372L, `1416` = 1416L, `1441` = 1441L, `1473` = 1473L,
`1532` = 1532L, `1599` = 1599L, `1626` = 1626L, `1669` = 1669L,
`1694` = 1694L, `1718` = 1718L, `1726` = 1726L, `1766` = 1766L,
`1786` = 1786L, `1827` = 1827L, `1853` = 1853L, `1881` = 1881L,
`1922` = 1922L, `1952` = 1952L, `1971` = 1971L, `1984` = 1984L,
`2019` = 2019L, `2039` = 2039L, `2075` = 2075L, `2106` = 2106L,
`2135` = 2135L, `2181` = 2181L, `2206` = 2206L, `2227` = 2227L,
`2238` = 2238L, `2273` = 2273L, `2293` = 2293L, `2325` = 2325L,
`2366` = 2366L, `2391` = 2391L, `2436` = 2436L, `2461` = 2461L,
`2483` = 2483L, `2493` = 2493L), class = "omit"), row.names = c(1L,
2L, 3L, 4L, 5L, 7L), class = "data.frame")
I have built 9 regression models per forecast horizon (t+1, t+5 and t+22) and I am using the predict function to make my forecasts. I have coded this in an R loop, where I also try to assign each forecast to a matrix. My code is the following:
EUR/GBP_RV t+1,t+22`~data.estimateI am trying to calculate realized volatility forecasts using a rolling window forecast. My aim is to use the first 500 observations to forecast the 501st observations, then shift the window forward one step using observations 2 to 501 to predict the 502nd observation. I want this to repeat until I have a complete pseudo out-of-sample forecast.
My df contains 2411 observations of 23 variables, here is small example:
Date
EUR/GBP_RV t+1
EUR/GBP_RV
EUR/GBP_RV_5
EUR/GBP_RV_22
2012-02-13
0.004019947
0.004467109
0.004995980
0.005150602
2012-02-14
0.004077322
0.004019947
0.004704742
0.005099209
2012-02-15
0.004666244
0.004077322
0.004564522
0.005020790
2012-02-16
0.004582351
0.004666244
0.004532930
0.005011078
2012-02-17
0.003951071
0.004582351
0.004362595
0.004999634
2012-02-21
0.005549329
0.004824547
0.004467109
0.004954358
The head of the df can be reproduced with
structure(list(Date = structure(c(15383, 15384, 15385, 15386,
15387, 15391), class = "Date"), `EUR/GBP_RV t+1,t+22` = c(0.00437808494654599,
0.00439764887779732, 0.00441997330738947, 0.00437799055732722,
0.00435021150904479, 0.00434881306458859), `EUR/GBP_RGV t+1,t+22` = c(0.00310674728131117,
0.00311502965608506, 0.00313756204195853, 0.00312923997431178,
0.00310846773074243, 0.00309755540903969), `EUR/GBP_RBV t+1,t+22` = c(0.00304961980133602,
0.00306866297401415, 0.00307794319983677, 0.00302801249035602,
0.00300946121851254, 0.00302272755554915), `EUR/GBP_RV t+1,t+5` = c(0.00425938711995146,
0.00442030721926592, 0.00471470868108043, 0.00487869292442023,
0.00476849421943949, 0.0046067439660438), `EUR/GBP_RGV t+1,t+5` = c(0.00287718093809447,
0.00311308998902836, 0.00344398536439729, 0.00376911066284235,
0.00377425759242542, 0.00353909902900148), `EUR/GBP_RBV t+1,t+5` = c(0.00313771439501486,
0.00310626895475871, 0.0031789431316576, 0.00305962424370556,
0.00288671182187571, 0.00291630955829613), `EUR/GBP_RV t+1` = c(0.00401994700051122,
0.00407732180013827, 0.00466624428620966, 0.00458235106134663,
0.00395107145155152, 0.00554932910921084), `EUR/GBP_RGV t+1` = c(0.00280067842079775,
0.00275522601341373, 0.00296142025653418, 0.00320716195737542,
0.00266141804235125, 0.00440970289025837), `EUR/GBP_RBV t+1` = c(0.00288377777753365,
0.00300554199386584, 0.00360608177982326, 0.00327292734850446,
0.0029202430753471, 0.00336891287836027), `EUR/GBP_RV` = c(0.00446710941914797,
0.00401994700051122, 0.00407732180013827, 0.00466624428620966,
0.00458235106134663, 0.00482454749708351), `EUR/GBP_RV_5` = c(0.00499598016427624,
0.00470474196716823, 0.00456452150727461, 0.00453292965488229,
0.00436259471347075, 0.00442030721926592), `EUR/GBP_RV_22` = c(0.00515060219897263,
0.00509920878086075, 0.00502079002092667, 0.00501107755050095,
0.00499963428727425, 0.00495435807685843), `EUR/GBP_RBV` = c(0.00324667045338159,
0.00288377777753365, 0.00300554199386584, 0.00360608177982326,
0.00327292734850446, 0.00272655057625291), `EUR/GBP_RBV_5` = c(0.0034985439252634,
0.00318731350301598, 0.00319529774619179, 0.0032799330165155,
0.00320299987062176, 0.00310626895475871), `EUR/GBP_RBV_22` = c(0.0036581887941976,
0.00362298829344015, 0.00355498498935768, 0.0035465419934449,
0.00355752455210586, 0.00351669973034298), `EUR/GBP_RGV` = c(0.00306825643155514,
0.00280067842079775, 0.00275522601341373, 0.00296142025653418,
0.00320716195737542, 0.00398022367546721), `EUR/GBP_RGV_5` = c(0.00353290218424469,
0.00345194162523714, 0.00325362896209417, 0.00312087362386985,
0.00295854861593525, 0.00311308998902836), `EUR/GBP_RGV_22` = c(0.00359974659692405,
0.00356342531619103, 0.00352224165959556, 0.00351722666683608,
0.00349184335907274, 0.00346394410318992), `EUR/GBP_TotalCount` = structure(c(-0.179518680545716,
-0.0757259172924681, 0.333514120677483, 0.759064450015801, -0.419724789788948,
-0.360414639358521), .Dim = c(6L, 1L)), `EUR/GBP_BloombergCount` = structure(c(-0.701694550941621,
-0.669811381311996, -0.574161872423118, -0.644304845608295, -0.784590791978649,
-0.631551577756444), .Dim = c(6L, 1L)), `EUR/GBP_SocialMediaCount` = structure(c(-1.68861759789696,
-1.66829994393287, -1.5910928588693, -1.59515638966212, -1.6967446594826,
-1.63172816679749), .Dim = c(6L, 1L)), `EUR/GBP_NewsCount` = structure(c(0.76560533722738,
0.879161625683434, 1.33717198912285, 1.90306082659552, 0.487392430510049,
0.487392430510049), .Dim = c(6L, 1L))), na.action = structure(c(`6` = 6L,
`38` = 38L, `74` = 74L, `101` = 101L, `140` = 140L, `165` = 165L,
`189` = 189L, `197` = 197L, `236` = 236L, `256` = 256L, `323` = 323L,
`351` = 351L, `393` = 393L, `423` = 423L, `442` = 442L, `455` = 455L,
`490` = 490L, `510` = 510L, `551` = 551L, `576` = 576L, `605` = 605L,
`646` = 646L, `676` = 676L, `696` = 696L, `708` = 708L, `742` = 742L,
`762` = 762L, `793` = 793L, `829` = 829L, `858` = 858L, `904` = 904L,
`929` = 929L, `950` = 950L, `961` = 961L, `996` = 996L, `1016` = 1016L,
`1089` = 1089L, `1114` = 1114L, `1159` = 1159L, `1184` = 1184L,
`1207` = 1207L, `1216` = 1216L, `1238` = 1238L, `1243` = 1243L,
`1253` = 1253L, `1278` = 1278L, `1315` = 1315L, `1346` = 1346L,
`1372` = 1372L, `1416` = 1416L, `1441` = 1441L, `1473` = 1473L,
`1532` = 1532L, `1599` = 1599L, `1626` = 1626L, `1669` = 1669L,
`1694` = 1694L, `1718` = 1718L, `1726` = 1726L, `1766` = 1766L,
`1786` = 1786L, `1827` = 1827L, `1853` = 1853L, `1881` = 1881L,
`1922` = 1922L, `1952` = 1952L, `1971` = 1971L, `1984` = 1984L,
`2019` = 2019L, `2039` = 2039L, `2075` = 2075L, `2106` = 2106L,
`2135` = 2135L, `2181` = 2181L, `2206` = 2206L, `2227` = 2227L,
`2238` = 2238L, `2273` = 2273L, `2293` = 2293L, `2325` = 2325L,
`2366` = 2366L, `2391` = 2391L, `2436` = 2436L, `2461` = 2461L,
`2483` = 2483L, `2493` = 2493L), class = "omit"), row.names = c(1L,
2L, 3L, 4L, 5L, 7L), class = "data.frame")
I have built 9 regression models per forecast horizon (t+1, t+5 and t+22) and I am using the predict function to make my forecasts. I have coded this in an R loop, where I also try to assign each forecast to a matrix. My code is the following:
EUR/GBP_RV`+data.estimateI am trying to calculate realized volatility forecasts using a rolling window forecast. My aim is to use the first 500 observations to forecast the 501st observations, then shift the window forward one step using observations 2 to 501 to predict the 502nd observation. I want this to repeat until I have a complete pseudo out-of-sample forecast.
My df contains 2411 observations of 23 variables, here is small example:
Date
EUR/GBP_RV t+1
EUR/GBP_RV
EUR/GBP_RV_5
EUR/GBP_RV_22
2012-02-13
0.004019947
0.004467109
0.004995980
0.005150602
2012-02-14
0.004077322
0.004019947
0.004704742
0.005099209
2012-02-15
0.004666244
0.004077322
0.004564522
0.005020790
2012-02-16
0.004582351
0.004666244
0.004532930
0.005011078
2012-02-17
0.003951071
0.004582351
0.004362595
0.004999634
2012-02-21
0.005549329
0.004824547
0.004467109
0.004954358
The head of the df can be reproduced with
structure(list(Date = structure(c(15383, 15384, 15385, 15386,
15387, 15391), class = "Date"), `EUR/GBP_RV t+1,t+22` = c(0.00437808494654599,
0.00439764887779732, 0.00441997330738947, 0.00437799055732722,
0.00435021150904479, 0.00434881306458859), `EUR/GBP_RGV t+1,t+22` = c(0.00310674728131117,
0.00311502965608506, 0.00313756204195853, 0.00312923997431178,
0.00310846773074243, 0.00309755540903969), `EUR/GBP_RBV t+1,t+22` = c(0.00304961980133602,
0.00306866297401415, 0.00307794319983677, 0.00302801249035602,
0.00300946121851254, 0.00302272755554915), `EUR/GBP_RV t+1,t+5` = c(0.00425938711995146,
0.00442030721926592, 0.00471470868108043, 0.00487869292442023,
0.00476849421943949, 0.0046067439660438), `EUR/GBP_RGV t+1,t+5` = c(0.00287718093809447,
0.00311308998902836, 0.00344398536439729, 0.00376911066284235,
0.00377425759242542, 0.00353909902900148), `EUR/GBP_RBV t+1,t+5` = c(0.00313771439501486,
0.00310626895475871, 0.0031789431316576, 0.00305962424370556,
0.00288671182187571, 0.00291630955829613), `EUR/GBP_RV t+1` = c(0.00401994700051122,
0.00407732180013827, 0.00466624428620966, 0.00458235106134663,
0.00395107145155152, 0.00554932910921084), `EUR/GBP_RGV t+1` = c(0.00280067842079775,
0.00275522601341373, 0.00296142025653418, 0.00320716195737542,
0.00266141804235125, 0.00440970289025837), `EUR/GBP_RBV t+1` = c(0.00288377777753365,
0.00300554199386584, 0.00360608177982326, 0.00327292734850446,
0.0029202430753471, 0.00336891287836027), `EUR/GBP_RV` = c(0.00446710941914797,
0.00401994700051122, 0.00407732180013827, 0.00466624428620966,
0.00458235106134663, 0.00482454749708351), `EUR/GBP_RV_5` = c(0.00499598016427624,
0.00470474196716823, 0.00456452150727461, 0.00453292965488229,
0.00436259471347075, 0.00442030721926592), `EUR/GBP_RV_22` = c(0.00515060219897263,
0.00509920878086075, 0.00502079002092667, 0.00501107755050095,
0.00499963428727425, 0.00495435807685843), `EUR/GBP_RBV` = c(0.00324667045338159,
0.00288377777753365, 0.00300554199386584, 0.00360608177982326,
0.00327292734850446, 0.00272655057625291), `EUR/GBP_RBV_5` = c(0.0034985439252634,
0.00318731350301598, 0.00319529774619179, 0.0032799330165155,
0.00320299987062176, 0.00310626895475871), `EUR/GBP_RBV_22` = c(0.0036581887941976,
0.00362298829344015, 0.00355498498935768, 0.0035465419934449,
0.00355752455210586, 0.00351669973034298), `EUR/GBP_RGV` = c(0.00306825643155514,
0.00280067842079775, 0.00275522601341373, 0.00296142025653418,
0.00320716195737542, 0.00398022367546721), `EUR/GBP_RGV_5` = c(0.00353290218424469,
0.00345194162523714, 0.00325362896209417, 0.00312087362386985,
0.00295854861593525, 0.00311308998902836), `EUR/GBP_RGV_22` = c(0.00359974659692405,
0.00356342531619103, 0.00352224165959556, 0.00351722666683608,
0.00349184335907274, 0.00346394410318992), `EUR/GBP_TotalCount` = structure(c(-0.179518680545716,
-0.0757259172924681, 0.333514120677483, 0.759064450015801, -0.419724789788948,
-0.360414639358521), .Dim = c(6L, 1L)), `EUR/GBP_BloombergCount` = structure(c(-0.701694550941621,
-0.669811381311996, -0.574161872423118, -0.644304845608295, -0.784590791978649,
-0.631551577756444), .Dim = c(6L, 1L)), `EUR/GBP_SocialMediaCount` = structure(c(-1.68861759789696,
-1.66829994393287, -1.5910928588693, -1.59515638966212, -1.6967446594826,
-1.63172816679749), .Dim = c(6L, 1L)), `EUR/GBP_NewsCount` = structure(c(0.76560533722738,
0.879161625683434, 1.33717198912285, 1.90306082659552, 0.487392430510049,
0.487392430510049), .Dim = c(6L, 1L))), na.action = structure(c(`6` = 6L,
`38` = 38L, `74` = 74L, `101` = 101L, `140` = 140L, `165` = 165L,
`189` = 189L, `197` = 197L, `236` = 236L, `256` = 256L, `323` = 323L,
`351` = 351L, `393` = 393L, `423` = 423L, `442` = 442L, `455` = 455L,
`490` = 490L, `510` = 510L, `551` = 551L, `576` = 576L, `605` = 605L,
`646` = 646L, `676` = 676L, `696` = 696L, `708` = 708L, `742` = 742L,
`762` = 762L, `793` = 793L, `829` = 829L, `858` = 858L, `904` = 904L,
`929` = 929L, `950` = 950L, `961` = 961L, `996` = 996L, `1016` = 1016L,
`1089` = 1089L, `1114` = 1114L, `1159` = 1159L, `1184` = 1184L,
`1207` = 1207L, `1216` = 1216L, `1238` = 1238L, `1243` = 1243L,
`1253` = 1253L, `1278` = 1278L, `1315` = 1315L, `1346` = 1346L,
`1372` = 1372L, `1416` = 1416L, `1441` = 1441L, `1473` = 1473L,
`1532` = 1532L, `1599` = 1599L, `1626` = 1626L, `1669` = 1669L,
`1694` = 1694L, `1718` = 1718L, `1726` = 1726L, `1766` = 1766L,
`1786` = 1786L, `1827` = 1827L, `1853` = 1853L, `1881` = 1881L,
`1922` = 1922L, `1952` = 1952L, `1971` = 1971L, `1984` = 1984L,
`2019` = 2019L, `2039` = 2039L, `2075` = 2075L, `2106` = 2106L,
`2135` = 2135L, `2181` = 2181L, `2206` = 2206L, `2227` = 2227L,
`2238` = 2238L, `2273` = 2273L, `2293` = 2293L, `2325` = 2325L,
`2366` = 2366L, `2391` = 2391L, `2436` = 2436L, `2461` = 2461L,
`2483` = 2483L, `2493` = 2493L), class = "omit"), row.names = c(1L,
2L, 3L, 4L, 5L, 7L), class = "data.frame")
I have built 9 regression models per forecast horizon (t+1, t+5 and t+22) and I am using the predict function to make my forecasts. I have coded this in an R loop, where I also try to assign each forecast to a matrix. My code is the following:
EUR/GBP_RV_5`+data.estimateI am trying to calculate realized volatility forecasts using a rolling window forecast. My aim is to use the first 500 observations to forecast the 501st observations, then shift the window forward one step using observations 2 to 501 to predict the 502nd observation. I want this to repeat until I have a complete pseudo out-of-sample forecast.
My df contains 2411 observations of 23 variables, here is small example:
Date
EUR/GBP_RV t+1
EUR/GBP_RV
EUR/GBP_RV_5
EUR/GBP_RV_22
2012-02-13
0.004019947
0.004467109
0.004995980
0.005150602
2012-02-14
0.004077322
0.004019947
0.004704742
0.005099209
2012-02-15
0.004666244
0.004077322
0.004564522
0.005020790
2012-02-16
0.004582351
0.004666244
0.004532930
0.005011078
2012-02-17
0.003951071
0.004582351
0.004362595
0.004999634
2012-02-21
0.005549329
0.004824547
0.004467109
0.004954358
The head of the df can be reproduced with
structure(list(Date = structure(c(15383, 15384, 15385, 15386,
15387, 15391), class = "Date"), `EUR/GBP_RV t+1,t+22` = c(0.00437808494654599,
0.00439764887779732, 0.00441997330738947, 0.00437799055732722,
0.00435021150904479, 0.00434881306458859), `EUR/GBP_RGV t+1,t+22` = c(0.00310674728131117,
0.00311502965608506, 0.00313756204195853, 0.00312923997431178,
0.00310846773074243, 0.00309755540903969), `EUR/GBP_RBV t+1,t+22` = c(0.00304961980133602,
0.00306866297401415, 0.00307794319983677, 0.00302801249035602,
0.00300946121851254, 0.00302272755554915), `EUR/GBP_RV t+1,t+5` = c(0.00425938711995146,
0.00442030721926592, 0.00471470868108043, 0.00487869292442023,
0.00476849421943949, 0.0046067439660438), `EUR/GBP_RGV t+1,t+5` = c(0.00287718093809447,
0.00311308998902836, 0.00344398536439729, 0.00376911066284235,
0.00377425759242542, 0.00353909902900148), `EUR/GBP_RBV t+1,t+5` = c(0.00313771439501486,
0.00310626895475871, 0.0031789431316576, 0.00305962424370556,
0.00288671182187571, 0.00291630955829613), `EUR/GBP_RV t+1` = c(0.00401994700051122,
0.00407732180013827, 0.00466624428620966, 0.00458235106134663,
0.00395107145155152, 0.00554932910921084), `EUR/GBP_RGV t+1` = c(0.00280067842079775,
0.00275522601341373, 0.00296142025653418, 0.00320716195737542,
0.00266141804235125, 0.00440970289025837), `EUR/GBP_RBV t+1` = c(0.00288377777753365,
0.00300554199386584, 0.00360608177982326, 0.00327292734850446,
0.0029202430753471, 0.00336891287836027), `EUR/GBP_RV` = c(0.00446710941914797,
0.00401994700051122, 0.00407732180013827, 0.00466624428620966,
0.00458235106134663, 0.00482454749708351), `EUR/GBP_RV_5` = c(0.00499598016427624,
0.00470474196716823, 0.00456452150727461, 0.00453292965488229,
0.00436259471347075, 0.00442030721926592), `EUR/GBP_RV_22` = c(0.00515060219897263,
0.00509920878086075, 0.00502079002092667, 0.00501107755050095,
0.00499963428727425, 0.00495435807685843), `EUR/GBP_RBV` = c(0.00324667045338159,
0.00288377777753365, 0.00300554199386584, 0.00360608177982326,
0.00327292734850446, 0.00272655057625291), `EUR/GBP_RBV_5` = c(0.0034985439252634,
0.00318731350301598, 0.00319529774619179, 0.0032799330165155,
0.00320299987062176, 0.00310626895475871), `EUR/GBP_RBV_22` = c(0.0036581887941976,
0.00362298829344015, 0.00355498498935768, 0.0035465419934449,
0.00355752455210586, 0.00351669973034298), `EUR/GBP_RGV` = c(0.00306825643155514,
0.00280067842079775, 0.00275522601341373, 0.00296142025653418,
0.00320716195737542, 0.00398022367546721), `EUR/GBP_RGV_5` = c(0.00353290218424469,
0.00345194162523714, 0.00325362896209417, 0.00312087362386985,
0.00295854861593525, 0.00311308998902836), `EUR/GBP_RGV_22` = c(0.00359974659692405,
0.00356342531619103, 0.00352224165959556, 0.00351722666683608,
0.00349184335907274, 0.00346394410318992), `EUR/GBP_TotalCount` = structure(c(-0.179518680545716,
-0.0757259172924681, 0.333514120677483, 0.759064450015801, -0.419724789788948,
-0.360414639358521), .Dim = c(6L, 1L)), `EUR/GBP_BloombergCount` = structure(c(-0.701694550941621,
-0.669811381311996, -0.574161872423118, -0.644304845608295, -0.784590791978649,
-0.631551577756444), .Dim = c(6L, 1L)), `EUR/GBP_SocialMediaCount` = structure(c(-1.68861759789696,
-1.66829994393287, -1.5910928588693, -1.59515638966212, -1.6967446594826,
-1.63172816679749), .Dim = c(6L, 1L)), `EUR/GBP_NewsCount` = structure(c(0.76560533722738,
0.879161625683434, 1.33717198912285, 1.90306082659552, 0.487392430510049,
0.487392430510049), .Dim = c(6L, 1L))), na.action = structure(c(`6` = 6L,
`38` = 38L, `74` = 74L, `101` = 101L, `140` = 140L, `165` = 165L,
`189` = 189L, `197` = 197L, `236` = 236L, `256` = 256L, `323` = 323L,
`351` = 351L, `393` = 393L, `423` = 423L, `442` = 442L, `455` = 455L,
`490` = 490L, `510` = 510L, `551` = 551L, `576` = 576L, `605` = 605L,
`646` = 646L, `676` = 676L, `696` = 696L, `708` = 708L, `742` = 742L,
`762` = 762L, `793` = 793L, `829` = 829L, `858` = 858L, `904` = 904L,
`929` = 929L, `950` = 950L, `961` = 961L, `996` = 996L, `1016` = 1016L,
`1089` = 1089L, `1114` = 1114L, `1159` = 1159L, `1184` = 1184L,
`1207` = 1207L, `1216` = 1216L, `1238` = 1238L, `1243` = 1243L,
`1253` = 1253L, `1278` = 1278L, `1315` = 1315L, `1346` = 1346L,
`1372` = 1372L, `1416` = 1416L, `1441` = 1441L, `1473` = 1473L,
`1532` = 1532L, `1599` = 1599L, `1626` = 1626L, `1669` = 1669L,
`1694` = 1694L, `1718` = 1718L, `1726` = 1726L, `1766` = 1766L,
`1786` = 1786L, `1827` = 1827L, `1853` = 1853L, `1881` = 1881L,
`1922` = 1922L, `1952` = 1952L, `1971` = 1971L, `1984` = 1984L,
`2019` = 2019L, `2039` = 2039L, `2075` = 2075L, `2106` = 2106L,
`2135` = 2135L, `2181` = 2181L, `2206` = 2206L, `2227` = 2227L,
`2238` = 2238L, `2273` = 2273L, `2293` = 2293L, `2325` = 2325L,
`2366` = 2366L, `2391` = 2391L, `2436` = 2436L, `2461` = 2461L,
`2483` = 2483L, `2493` = 2493L), class = "omit"), row.names = c(1L,
2L, 3L, 4L, 5L, 7L), class = "data.frame")
I have built 9 regression models per forecast horizon (t+1, t+5 and t+22) and I am using the predict function to make my forecasts. I have coded this in an R loop, where I also try to assign each forecast to a matrix. My code is the following:
EUR/GBP_RV_22`+data.estimateI am trying to calculate realized volatility forecasts using a rolling window forecast. My aim is to use the first 500 observations to forecast the 501st observations, then shift the window forward one step using observations 2 to 501 to predict the 502nd observation. I want this to repeat until I have a complete pseudo out-of-sample forecast.
My df contains 2411 observations of 23 variables, here is small example:
Date
EUR/GBP_RV t+1
EUR/GBP_RV
EUR/GBP_RV_5
EUR/GBP_RV_22
2012-02-13
0.004019947
0.004467109
0.004995980
0.005150602
2012-02-14
0.004077322
0.004019947
0.004704742
0.005099209
2012-02-15
0.004666244
0.004077322
0.004564522
0.005020790
2012-02-16
0.004582351
0.004666244
0.004532930
0.005011078
2012-02-17
0.003951071
0.004582351
0.004362595
0.004999634
2012-02-21
0.005549329
0.004824547
0.004467109
0.004954358
The head of the df can be reproduced with
structure(list(Date = structure(c(15383, 15384, 15385, 15386,
15387, 15391), class = "Date"), `EUR/GBP_RV t+1,t+22` = c(0.00437808494654599,
0.00439764887779732, 0.00441997330738947, 0.00437799055732722,
0.00435021150904479, 0.00434881306458859), `EUR/GBP_RGV t+1,t+22` = c(0.00310674728131117,
0.00311502965608506, 0.00313756204195853, 0.00312923997431178,
0.00310846773074243, 0.00309755540903969), `EUR/GBP_RBV t+1,t+22` = c(0.00304961980133602,
0.00306866297401415, 0.00307794319983677, 0.00302801249035602,
0.00300946121851254, 0.00302272755554915), `EUR/GBP_RV t+1,t+5` = c(0.00425938711995146,
0.00442030721926592, 0.00471470868108043, 0.00487869292442023,
0.00476849421943949, 0.0046067439660438), `EUR/GBP_RGV t+1,t+5` = c(0.00287718093809447,
0.00311308998902836, 0.00344398536439729, 0.00376911066284235,
0.00377425759242542, 0.00353909902900148), `EUR/GBP_RBV t+1,t+5` = c(0.00313771439501486,
0.00310626895475871, 0.0031789431316576, 0.00305962424370556,
0.00288671182187571, 0.00291630955829613), `EUR/GBP_RV t+1` = c(0.00401994700051122,
0.00407732180013827, 0.00466624428620966, 0.00458235106134663,
0.00395107145155152, 0.00554932910921084), `EUR/GBP_RGV t+1` = c(0.00280067842079775,
0.00275522601341373, 0.00296142025653418, 0.00320716195737542,
0.00266141804235125, 0.00440970289025837), `EUR/GBP_RBV t+1` = c(0.00288377777753365,
0.00300554199386584, 0.00360608177982326, 0.00327292734850446,
0.0029202430753471, 0.00336891287836027), `EUR/GBP_RV` = c(0.00446710941914797,
0.00401994700051122, 0.00407732180013827, 0.00466624428620966,
0.00458235106134663, 0.00482454749708351), `EUR/GBP_RV_5` = c(0.00499598016427624,
0.00470474196716823, 0.00456452150727461, 0.00453292965488229,
0.00436259471347075, 0.00442030721926592), `EUR/GBP_RV_22` = c(0.00515060219897263,
0.00509920878086075, 0.00502079002092667, 0.00501107755050095,
0.00499963428727425, 0.00495435807685843), `EUR/GBP_RBV` = c(0.00324667045338159,
0.00288377777753365, 0.00300554199386584, 0.00360608177982326,
0.00327292734850446, 0.00272655057625291), `EUR/GBP_RBV_5` = c(0.0034985439252634,
0.00318731350301598, 0.00319529774619179, 0.0032799330165155,
0.00320299987062176, 0.00310626895475871), `EUR/GBP_RBV_22` = c(0.0036581887941976,
0.00362298829344015, 0.00355498498935768, 0.0035465419934449,
0.00355752455210586, 0.00351669973034298), `EUR/GBP_RGV` = c(0.00306825643155514,
0.00280067842079775, 0.00275522601341373, 0.00296142025653418,
0.00320716195737542, 0.00398022367546721), `EUR/GBP_RGV_5` = c(0.00353290218424469,
0.00345194162523714, 0.00325362896209417, 0.00312087362386985,
0.00295854861593525, 0.00311308998902836), `EUR/GBP_RGV_22` = c(0.00359974659692405,
0.00356342531619103, 0.00352224165959556, 0.00351722666683608,
0.00349184335907274, 0.00346394410318992), `EUR/GBP_TotalCount` = structure(c(-0.179518680545716,
-0.0757259172924681, 0.333514120677483, 0.759064450015801, -0.419724789788948,
-0.360414639358521), .Dim = c(6L, 1L)), `EUR/GBP_BloombergCount` = structure(c(-0.701694550941621,
-0.669811381311996, -0.574161872423118, -0.644304845608295, -0.784590791978649,
-0.631551577756444), .Dim = c(6L, 1L)), `EUR/GBP_SocialMediaCount` = structure(c(-1.68861759789696,
-1.66829994393287, -1.5910928588693, -1.59515638966212, -1.6967446594826,
-1.63172816679749), .Dim = c(6L, 1L)), `EUR/GBP_NewsCount` = structure(c(0.76560533722738,
0.879161625683434, 1.33717198912285, 1.90306082659552, 0.487392430510049,
0.487392430510049), .Dim = c(6L, 1L))), na.action = structure(c(`6` = 6L,
`38` = 38L, `74` = 74L, `101` = 101L, `140` = 140L, `165` = 165L,
`189` = 189L, `197` = 197L, `236` = 236L, `256` = 256L, `323` = 323L,
`351` = 351L, `393` = 393L, `423` = 423L, `442` = 442L, `455` = 455L,
`490` = 490L, `510` = 510L, `551` = 551L, `576` = 576L, `605` = 605L,
`646` = 646L, `676` = 676L, `696` = 696L, `708` = 708L, `742` = 742L,
`762` = 762L, `793` = 793L, `829` = 829L, `858` = 858L, `904` = 904L,
`929` = 929L, `950` = 950L, `961` = 961L, `996` = 996L, `1016` = 1016L,
`1089` = 1089L, `1114` = 1114L, `1159` = 1159L, `1184` = 1184L,
`1207` = 1207L, `1216` = 1216L, `1238` = 1238L, `1243` = 1243L,
`1253` = 1253L, `1278` = 1278L, `1315` = 1315L, `1346` = 1346L,
`1372` = 1372L, `1416` = 1416L, `1441` = 1441L, `1473` = 1473L,
`1532` = 1532L, `1599` = 1599L, `1626` = 1626L, `1669` = 1669L,
`1694` = 1694L, `1718` = 1718L, `1726` = 1726L, `1766` = 1766L,
`1786` = 1786L, `1827` = 1827L, `1853` = 1853L, `1881` = 1881L,
`1922` = 1922L, `1952` = 1952L, `1971` = 1971L, `1984` = 1984L,
`2019` = 2019L, `2039` = 2039L, `2075` = 2075L, `2106` = 2106L,
`2135` = 2135L, `2181` = 2181L, `2206` = 2206L, `2227` = 2227L,
`2238` = 2238L, `2273` = 2273L, `2293` = 2293L, `2325` = 2325L,
`2366` = 2366L, `2391` = 2391L, `2436` = 2436L, `2461` = 2461L,
`2483` = 2483L, `2493` = 2493L), class = "omit"), row.names = c(1L,
2L, 3L, 4L, 5L, 7L), class = "data.frame")
I have built 9 regression models per forecast horizon (t+1, t+5 and t+22) and I am using the predict function to make my forecasts. I have coded this in an R loop, where I also try to assign each forecast to a matrix. My code is the following:
EUR/GBP_TotalCount`)
EURGBP_HAR_RVBt22_train <- lm(data.estimateI am trying to calculate realized volatility forecasts using a rolling window forecast. My aim is to use the first 500 observations to forecast the 501st observations, then shift the window forward one step using observations 2 to 501 to predict the 502nd observation. I want this to repeat until I have a complete pseudo out-of-sample forecast.
My df contains 2411 observations of 23 variables, here is small example:
Date
EUR/GBP_RV t+1
EUR/GBP_RV
EUR/GBP_RV_5
EUR/GBP_RV_22
2012-02-13
0.004019947
0.004467109
0.004995980
0.005150602
2012-02-14
0.004077322
0.004019947
0.004704742
0.005099209
2012-02-15
0.004666244
0.004077322
0.004564522
0.005020790
2012-02-16
0.004582351
0.004666244
0.004532930
0.005011078
2012-02-17
0.003951071
0.004582351
0.004362595
0.004999634
2012-02-21
0.005549329
0.004824547
0.004467109
0.004954358
The head of the df can be reproduced with
structure(list(Date = structure(c(15383, 15384, 15385, 15386,
15387, 15391), class = "Date"), `EUR/GBP_RV t+1,t+22` = c(0.00437808494654599,
0.00439764887779732, 0.00441997330738947, 0.00437799055732722,
0.00435021150904479, 0.00434881306458859), `EUR/GBP_RGV t+1,t+22` = c(0.00310674728131117,
0.00311502965608506, 0.00313756204195853, 0.00312923997431178,
0.00310846773074243, 0.00309755540903969), `EUR/GBP_RBV t+1,t+22` = c(0.00304961980133602,
0.00306866297401415, 0.00307794319983677, 0.00302801249035602,
0.00300946121851254, 0.00302272755554915), `EUR/GBP_RV t+1,t+5` = c(0.00425938711995146,
0.00442030721926592, 0.00471470868108043, 0.00487869292442023,
0.00476849421943949, 0.0046067439660438), `EUR/GBP_RGV t+1,t+5` = c(0.00287718093809447,
0.00311308998902836, 0.00344398536439729, 0.00376911066284235,
0.00377425759242542, 0.00353909902900148), `EUR/GBP_RBV t+1,t+5` = c(0.00313771439501486,
0.00310626895475871, 0.0031789431316576, 0.00305962424370556,
0.00288671182187571, 0.00291630955829613), `EUR/GBP_RV t+1` = c(0.00401994700051122,
0.00407732180013827, 0.00466624428620966, 0.00458235106134663,
0.00395107145155152, 0.00554932910921084), `EUR/GBP_RGV t+1` = c(0.00280067842079775,
0.00275522601341373, 0.00296142025653418, 0.00320716195737542,
0.00266141804235125, 0.00440970289025837), `EUR/GBP_RBV t+1` = c(0.00288377777753365,
0.00300554199386584, 0.00360608177982326, 0.00327292734850446,
0.0029202430753471, 0.00336891287836027), `EUR/GBP_RV` = c(0.00446710941914797,
0.00401994700051122, 0.00407732180013827, 0.00466624428620966,
0.00458235106134663, 0.00482454749708351), `EUR/GBP_RV_5` = c(0.00499598016427624,
0.00470474196716823, 0.00456452150727461, 0.00453292965488229,
0.00436259471347075, 0.00442030721926592), `EUR/GBP_RV_22` = c(0.00515060219897263,
0.00509920878086075, 0.00502079002092667, 0.00501107755050095,
0.00499963428727425, 0.00495435807685843), `EUR/GBP_RBV` = c(0.00324667045338159,
0.00288377777753365, 0.00300554199386584, 0.00360608177982326,
0.00327292734850446, 0.00272655057625291), `EUR/GBP_RBV_5` = c(0.0034985439252634,
0.00318731350301598, 0.00319529774619179, 0.0032799330165155,
0.00320299987062176, 0.00310626895475871), `EUR/GBP_RBV_22` = c(0.0036581887941976,
0.00362298829344015, 0.00355498498935768, 0.0035465419934449,
0.00355752455210586, 0.00351669973034298), `EUR/GBP_RGV` = c(0.00306825643155514,
0.00280067842079775, 0.00275522601341373, 0.00296142025653418,
0.00320716195737542, 0.00398022367546721), `EUR/GBP_RGV_5` = c(0.00353290218424469,
0.00345194162523714, 0.00325362896209417, 0.00312087362386985,
0.00295854861593525, 0.00311308998902836), `EUR/GBP_RGV_22` = c(0.00359974659692405,
0.00356342531619103, 0.00352224165959556, 0.00351722666683608,
0.00349184335907274, 0.00346394410318992), `EUR/GBP_TotalCount` = structure(c(-0.179518680545716,
-0.0757259172924681, 0.333514120677483, 0.759064450015801, -0.419724789788948,
-0.360414639358521), .Dim = c(6L, 1L)), `EUR/GBP_BloombergCount` = structure(c(-0.701694550941621,
-0.669811381311996, -0.574161872423118, -0.644304845608295, -0.784590791978649,
-0.631551577756444), .Dim = c(6L, 1L)), `EUR/GBP_SocialMediaCount` = structure(c(-1.68861759789696,
-1.66829994393287, -1.5910928588693, -1.59515638966212, -1.6967446594826,
-1.63172816679749), .Dim = c(6L, 1L)), `EUR/GBP_NewsCount` = structure(c(0.76560533722738,
0.879161625683434, 1.33717198912285, 1.90306082659552, 0.487392430510049,
0.487392430510049), .Dim = c(6L, 1L))), na.action = structure(c(`6` = 6L,
`38` = 38L, `74` = 74L, `101` = 101L, `140` = 140L, `165` = 165L,
`189` = 189L, `197` = 197L, `236` = 236L, `256` = 256L, `323` = 323L,
`351` = 351L, `393` = 393L, `423` = 423L, `442` = 442L, `455` = 455L,
`490` = 490L, `510` = 510L, `551` = 551L, `576` = 576L, `605` = 605L,
`646` = 646L, `676` = 676L, `696` = 696L, `708` = 708L, `742` = 742L,
`762` = 762L, `793` = 793L, `829` = 829L, `858` = 858L, `904` = 904L,
`929` = 929L, `950` = 950L, `961` = 961L, `996` = 996L, `1016` = 1016L,
`1089` = 1089L, `1114` = 1114L, `1159` = 1159L, `1184` = 1184L,
`1207` = 1207L, `1216` = 1216L, `1238` = 1238L, `1243` = 1243L,
`1253` = 1253L, `1278` = 1278L, `1315` = 1315L, `1346` = 1346L,
`1372` = 1372L, `1416` = 1416L, `1441` = 1441L, `1473` = 1473L,
`1532` = 1532L, `1599` = 1599L, `1626` = 1626L, `1669` = 1669L,
`1694` = 1694L, `1718` = 1718L, `1726` = 1726L, `1766` = 1766L,
`1786` = 1786L, `1827` = 1827L, `1853` = 1853L, `1881` = 1881L,
`1922` = 1922L, `1952` = 1952L, `1971` = 1971L, `1984` = 1984L,
`2019` = 2019L, `2039` = 2039L, `2075` = 2075L, `2106` = 2106L,
`2135` = 2135L, `2181` = 2181L, `2206` = 2206L, `2227` = 2227L,
`2238` = 2238L, `2273` = 2273L, `2293` = 2293L, `2325` = 2325L,
`2366` = 2366L, `2391` = 2391L, `2436` = 2436L, `2461` = 2461L,
`2483` = 2483L, `2493` = 2493L), class = "omit"), row.names = c(1L,
2L, 3L, 4L, 5L, 7L), class = "data.frame")
I have built 9 regression models per forecast horizon (t+1, t+5 and t+22) and I am using the predict function to make my forecasts. I have coded this in an R loop, where I also try to assign each forecast to a matrix. My code is the following:
EUR/GBP_RBV t+1,t+22`~data.estimateI am trying to calculate realized volatility forecasts using a rolling window forecast. My aim is to use the first 500 observations to forecast the 501st observations, then shift the window forward one step using observations 2 to 501 to predict the 502nd observation. I want this to repeat until I have a complete pseudo out-of-sample forecast.
My df contains 2411 observations of 23 variables, here is small example:
Date
EUR/GBP_RV t+1
EUR/GBP_RV
EUR/GBP_RV_5
EUR/GBP_RV_22
2012-02-13
0.004019947
0.004467109
0.004995980
0.005150602
2012-02-14
0.004077322
0.004019947
0.004704742
0.005099209
2012-02-15
0.004666244
0.004077322
0.004564522
0.005020790
2012-02-16
0.004582351
0.004666244
0.004532930
0.005011078
2012-02-17
0.003951071
0.004582351
0.004362595
0.004999634
2012-02-21
0.005549329
0.004824547
0.004467109
0.004954358
The head of the df can be reproduced with
structure(list(Date = structure(c(15383, 15384, 15385, 15386,
15387, 15391), class = "Date"), `EUR/GBP_RV t+1,t+22` = c(0.00437808494654599,
0.00439764887779732, 0.00441997330738947, 0.00437799055732722,
0.00435021150904479, 0.00434881306458859), `EUR/GBP_RGV t+1,t+22` = c(0.00310674728131117,
0.00311502965608506, 0.00313756204195853, 0.00312923997431178,
0.00310846773074243, 0.00309755540903969), `EUR/GBP_RBV t+1,t+22` = c(0.00304961980133602,
0.00306866297401415, 0.00307794319983677, 0.00302801249035602,
0.00300946121851254, 0.00302272755554915), `EUR/GBP_RV t+1,t+5` = c(0.00425938711995146,
0.00442030721926592, 0.00471470868108043, 0.00487869292442023,
0.00476849421943949, 0.0046067439660438), `EUR/GBP_RGV t+1,t+5` = c(0.00287718093809447,
0.00311308998902836, 0.00344398536439729, 0.00376911066284235,
0.00377425759242542, 0.00353909902900148), `EUR/GBP_RBV t+1,t+5` = c(0.00313771439501486,
0.00310626895475871, 0.0031789431316576, 0.00305962424370556,
0.00288671182187571, 0.00291630955829613), `EUR/GBP_RV t+1` = c(0.00401994700051122,
0.00407732180013827, 0.00466624428620966, 0.00458235106134663,
0.00395107145155152, 0.00554932910921084), `EUR/GBP_RGV t+1` = c(0.00280067842079775,
0.00275522601341373, 0.00296142025653418, 0.00320716195737542,
0.00266141804235125, 0.00440970289025837), `EUR/GBP_RBV t+1` = c(0.00288377777753365,
0.00300554199386584, 0.00360608177982326, 0.00327292734850446,
0.0029202430753471, 0.00336891287836027), `EUR/GBP_RV` = c(0.00446710941914797,
0.00401994700051122, 0.00407732180013827, 0.00466624428620966,
0.00458235106134663, 0.00482454749708351), `EUR/GBP_RV_5` = c(0.00499598016427624,
0.00470474196716823, 0.00456452150727461, 0.00453292965488229,
0.00436259471347075, 0.00442030721926592), `EUR/GBP_RV_22` = c(0.00515060219897263,
0.00509920878086075, 0.00502079002092667, 0.00501107755050095,
0.00499963428727425, 0.00495435807685843), `EUR/GBP_RBV` = c(0.00324667045338159,
0.00288377777753365, 0.00300554199386584, 0.00360608177982326,
0.00327292734850446, 0.00272655057625291), `EUR/GBP_RBV_5` = c(0.0034985439252634,
0.00318731350301598, 0.00319529774619179, 0.0032799330165155,
0.00320299987062176, 0.00310626895475871), `EUR/GBP_RBV_22` = c(0.0036581887941976,
0.00362298829344015, 0.00355498498935768, 0.0035465419934449,
0.00355752455210586, 0.00351669973034298), `EUR/GBP_RGV` = c(0.00306825643155514,
0.00280067842079775, 0.00275522601341373, 0.00296142025653418,
0.00320716195737542, 0.00398022367546721), `EUR/GBP_RGV_5` = c(0.00353290218424469,
0.00345194162523714, 0.00325362896209417, 0.00312087362386985,
0.00295854861593525, 0.00311308998902836), `EUR/GBP_RGV_22` = c(0.00359974659692405,
0.00356342531619103, 0.00352224165959556, 0.00351722666683608,
0.00349184335907274, 0.00346394410318992), `EUR/GBP_TotalCount` = structure(c(-0.179518680545716,
-0.0757259172924681, 0.333514120677483, 0.759064450015801, -0.419724789788948,
-0.360414639358521), .Dim = c(6L, 1L)), `EUR/GBP_BloombergCount` = structure(c(-0.701694550941621,
-0.669811381311996, -0.574161872423118, -0.644304845608295, -0.784590791978649,
-0.631551577756444), .Dim = c(6L, 1L)), `EUR/GBP_SocialMediaCount` = structure(c(-1.68861759789696,
-1.66829994393287, -1.5910928588693, -1.59515638966212, -1.6967446594826,
-1.63172816679749), .Dim = c(6L, 1L)), `EUR/GBP_NewsCount` = structure(c(0.76560533722738,
0.879161625683434, 1.33717198912285, 1.90306082659552, 0.487392430510049,
0.487392430510049), .Dim = c(6L, 1L))), na.action = structure(c(`6` = 6L,
`38` = 38L, `74` = 74L, `101` = 101L, `140` = 140L, `165` = 165L,
`189` = 189L, `197` = 197L, `236` = 236L, `256` = 256L, `323` = 323L,
`351` = 351L, `393` = 393L, `423` = 423L, `442` = 442L, `455` = 455L,
`490` = 490L, `510` = 510L, `551` = 551L, `576` = 576L, `605` = 605L,
`646` = 646L, `676` = 676L, `696` = 696L, `708` = 708L, `742` = 742L,
`762` = 762L, `793` = 793L, `829` = 829L, `858` = 858L, `904` = 904L,
`929` = 929L, `950` = 950L, `961` = 961L, `996` = 996L, `1016` = 1016L,
`1089` = 1089L, `1114` = 1114L, `1159` = 1159L, `1184` = 1184L,
`1207` = 1207L, `1216` = 1216L, `1238` = 1238L, `1243` = 1243L,
`1253` = 1253L, `1278` = 1278L, `1315` = 1315L, `1346` = 1346L,
`1372` = 1372L, `1416` = 1416L, `1441` = 1441L, `1473` = 1473L,
`1532` = 1532L, `1599` = 1599L, `1626` = 1626L, `1669` = 1669L,
`1694` = 1694L, `1718` = 1718L, `1726` = 1726L, `1766` = 1766L,
`1786` = 1786L, `1827` = 1827L, `1853` = 1853L, `1881` = 1881L,
`1922` = 1922L, `1952` = 1952L, `1971` = 1971L, `1984` = 1984L,
`2019` = 2019L, `2039` = 2039L, `2075` = 2075L, `2106` = 2106L,
`2135` = 2135L, `2181` = 2181L, `2206` = 2206L, `2227` = 2227L,
`2238` = 2238L, `2273` = 2273L, `2293` = 2293L, `2325` = 2325L,
`2366` = 2366L, `2391` = 2391L, `2436` = 2436L, `2461` = 2461L,
`2483` = 2483L, `2493` = 2493L), class = "omit"), row.names = c(1L,
2L, 3L, 4L, 5L, 7L), class = "data.frame")
I have built 9 regression models per forecast horizon (t+1, t+5 and t+22) and I am using the predict function to make my forecasts. I have coded this in an R loop, where I also try to assign each forecast to a matrix. My code is the following:
EUR/GBP_RBV`+data.estimateI am trying to calculate realized volatility forecasts using a rolling window forecast. My aim is to use the first 500 observations to forecast the 501st observations, then shift the window forward one step using observations 2 to 501 to predict the 502nd observation. I want this to repeat until I have a complete pseudo out-of-sample forecast.
My df contains 2411 observations of 23 variables, here is small example:
Date
EUR/GBP_RV t+1
EUR/GBP_RV
EUR/GBP_RV_5
EUR/GBP_RV_22
2012-02-13
0.004019947
0.004467109
0.004995980
0.005150602
2012-02-14
0.004077322
0.004019947
0.004704742
0.005099209
2012-02-15
0.004666244
0.004077322
0.004564522
0.005020790
2012-02-16
0.004582351
0.004666244
0.004532930
0.005011078
2012-02-17
0.003951071
0.004582351
0.004362595
0.004999634
2012-02-21
0.005549329
0.004824547
0.004467109
0.004954358
The head of the df can be reproduced with
structure(list(Date = structure(c(15383, 15384, 15385, 15386,
15387, 15391), class = "Date"), `EUR/GBP_RV t+1,t+22` = c(0.00437808494654599,
0.00439764887779732, 0.00441997330738947, 0.00437799055732722,
0.00435021150904479, 0.00434881306458859), `EUR/GBP_RGV t+1,t+22` = c(0.00310674728131117,
0.00311502965608506, 0.00313756204195853, 0.00312923997431178,
0.00310846773074243, 0.00309755540903969), `EUR/GBP_RBV t+1,t+22` = c(0.00304961980133602,
0.00306866297401415, 0.00307794319983677, 0.00302801249035602,
0.00300946121851254, 0.00302272755554915), `EUR/GBP_RV t+1,t+5` = c(0.00425938711995146,
0.00442030721926592, 0.00471470868108043, 0.00487869292442023,
0.00476849421943949, 0.0046067439660438), `EUR/GBP_RGV t+1,t+5` = c(0.00287718093809447,
0.00311308998902836, 0.00344398536439729, 0.00376911066284235,
0.00377425759242542, 0.00353909902900148), `EUR/GBP_RBV t+1,t+5` = c(0.00313771439501486,
0.00310626895475871, 0.0031789431316576, 0.00305962424370556,
0.00288671182187571, 0.00291630955829613), `EUR/GBP_RV t+1` = c(0.00401994700051122,
0.00407732180013827, 0.00466624428620966, 0.00458235106134663,
0.00395107145155152, 0.00554932910921084), `EUR/GBP_RGV t+1` = c(0.00280067842079775,
0.00275522601341373, 0.00296142025653418, 0.00320716195737542,
0.00266141804235125, 0.00440970289025837), `EUR/GBP_RBV t+1` = c(0.00288377777753365,
0.00300554199386584, 0.00360608177982326, 0.00327292734850446,
0.0029202430753471, 0.00336891287836027), `EUR/GBP_RV` = c(0.00446710941914797,
0.00401994700051122, 0.00407732180013827, 0.00466624428620966,
0.00458235106134663, 0.00482454749708351), `EUR/GBP_RV_5` = c(0.00499598016427624,
0.00470474196716823, 0.00456452150727461, 0.00453292965488229,
0.00436259471347075, 0.00442030721926592), `EUR/GBP_RV_22` = c(0.00515060219897263,
0.00509920878086075, 0.00502079002092667, 0.00501107755050095,
0.00499963428727425, 0.00495435807685843), `EUR/GBP_RBV` = c(0.00324667045338159,
0.00288377777753365, 0.00300554199386584, 0.00360608177982326,
0.00327292734850446, 0.00272655057625291), `EUR/GBP_RBV_5` = c(0.0034985439252634,
0.00318731350301598, 0.00319529774619179, 0.0032799330165155,
0.00320299987062176, 0.00310626895475871), `EUR/GBP_RBV_22` = c(0.0036581887941976,
0.00362298829344015, 0.00355498498935768, 0.0035465419934449,
0.00355752455210586, 0.00351669973034298), `EUR/GBP_RGV` = c(0.00306825643155514,
0.00280067842079775, 0.00275522601341373, 0.00296142025653418,
0.00320716195737542, 0.00398022367546721), `EUR/GBP_RGV_5` = c(0.00353290218424469,
0.00345194162523714, 0.00325362896209417, 0.00312087362386985,
0.00295854861593525, 0.00311308998902836), `EUR/GBP_RGV_22` = c(0.00359974659692405,
0.00356342531619103, 0.00352224165959556, 0.00351722666683608,
0.00349184335907274, 0.00346394410318992), `EUR/GBP_TotalCount` = structure(c(-0.179518680545716,
-0.0757259172924681, 0.333514120677483, 0.759064450015801, -0.419724789788948,
-0.360414639358521), .Dim = c(6L, 1L)), `EUR/GBP_BloombergCount` = structure(c(-0.701694550941621,
-0.669811381311996, -0.574161872423118, -0.644304845608295, -0.784590791978649,
-0.631551577756444), .Dim = c(6L, 1L)), `EUR/GBP_SocialMediaCount` = structure(c(-1.68861759789696,
-1.66829994393287, -1.5910928588693, -1.59515638966212, -1.6967446594826,
-1.63172816679749), .Dim = c(6L, 1L)), `EUR/GBP_NewsCount` = structure(c(0.76560533722738,
0.879161625683434, 1.33717198912285, 1.90306082659552, 0.487392430510049,
0.487392430510049), .Dim = c(6L, 1L))), na.action = structure(c(`6` = 6L,
`38` = 38L, `74` = 74L, `101` = 101L, `140` = 140L, `165` = 165L,
`189` = 189L, `197` = 197L, `236` = 236L, `256` = 256L, `323` = 323L,
`351` = 351L, `393` = 393L, `423` = 423L, `442` = 442L, `455` = 455L,
`490` = 490L, `510` = 510L, `551` = 551L, `576` = 576L, `605` = 605L,
`646` = 646L, `676` = 676L, `696` = 696L, `708` = 708L, `742` = 742L,
`762` = 762L, `793` = 793L, `829` = 829L, `858` = 858L, `904` = 904L,
`929` = 929L, `950` = 950L, `961` = 961L, `996` = 996L, `1016` = 1016L,
`1089` = 1089L, `1114` = 1114L, `1159` = 1159L, `1184` = 1184L,
`1207` = 1207L, `1216` = 1216L, `1238` = 1238L, `1243` = 1243L,
`1253` = 1253L, `1278` = 1278L, `1315` = 1315L, `1346` = 1346L,
`1372` = 1372L, `1416` = 1416L, `1441` = 1441L, `1473` = 1473L,
`1532` = 1532L, `1599` = 1599L, `1626` = 1626L, `1669` = 1669L,
`1694` = 1694L, `1718` = 1718L, `1726` = 1726L, `1766` = 1766L,
`1786` = 1786L, `1827` = 1827L, `1853` = 1853L, `1881` = 1881L,
`1922` = 1922L, `1952` = 1952L, `1971` = 1971L, `1984` = 1984L,
`2019` = 2019L, `2039` = 2039L, `2075` = 2075L, `2106` = 2106L,
`2135` = 2135L, `2181` = 2181L, `2206` = 2206L, `2227` = 2227L,
`2238` = 2238L, `2273` = 2273L, `2293` = 2293L, `2325` = 2325L,
`2366` = 2366L, `2391` = 2391L, `2436` = 2436L, `2461` = 2461L,
`2483` = 2483L, `2493` = 2493L), class = "omit"), row.names = c(1L,
2L, 3L, 4L, 5L, 7L), class = "data.frame")
I have built 9 regression models per forecast horizon (t+1, t+5 and t+22) and I am using the predict function to make my forecasts. I have coded this in an R loop, where I also try to assign each forecast to a matrix. My code is the following:
EUR/GBP_RBV_5`+data.estimateI am trying to calculate realized volatility forecasts using a rolling window forecast. My aim is to use the first 500 observations to forecast the 501st observations, then shift the window forward one step using observations 2 to 501 to predict the 502nd observation. I want this to repeat until I have a complete pseudo out-of-sample forecast.
My df contains 2411 observations of 23 variables, here is small example:
Date
EUR/GBP_RV t+1
EUR/GBP_RV
EUR/GBP_RV_5
EUR/GBP_RV_22
2012-02-13
0.004019947
0.004467109
0.004995980
0.005150602
2012-02-14
0.004077322
0.004019947
0.004704742
0.005099209
2012-02-15
0.004666244
0.004077322
0.004564522
0.005020790
2012-02-16
0.004582351
0.004666244
0.004532930
0.005011078
2012-02-17
0.003951071
0.004582351
0.004362595
0.004999634
2012-02-21
0.005549329
0.004824547
0.004467109
0.004954358
The head of the df can be reproduced with
structure(list(Date = structure(c(15383, 15384, 15385, 15386,
15387, 15391), class = "Date"), `EUR/GBP_RV t+1,t+22` = c(0.00437808494654599,
0.00439764887779732, 0.00441997330738947, 0.00437799055732722,
0.00435021150904479, 0.00434881306458859), `EUR/GBP_RGV t+1,t+22` = c(0.00310674728131117,
0.00311502965608506, 0.00313756204195853, 0.00312923997431178,
0.00310846773074243, 0.00309755540903969), `EUR/GBP_RBV t+1,t+22` = c(0.00304961980133602,
0.00306866297401415, 0.00307794319983677, 0.00302801249035602,
0.00300946121851254, 0.00302272755554915), `EUR/GBP_RV t+1,t+5` = c(0.00425938711995146,
0.00442030721926592, 0.00471470868108043, 0.00487869292442023,
0.00476849421943949, 0.0046067439660438), `EUR/GBP_RGV t+1,t+5` = c(0.00287718093809447,
0.00311308998902836, 0.00344398536439729, 0.00376911066284235,
0.00377425759242542, 0.00353909902900148), `EUR/GBP_RBV t+1,t+5` = c(0.00313771439501486,
0.00310626895475871, 0.0031789431316576, 0.00305962424370556,
0.00288671182187571, 0.00291630955829613), `EUR/GBP_RV t+1` = c(0.00401994700051122,
0.00407732180013827, 0.00466624428620966, 0.00458235106134663,
0.00395107145155152, 0.00554932910921084), `EUR/GBP_RGV t+1` = c(0.00280067842079775,
0.00275522601341373, 0.00296142025653418, 0.00320716195737542,
0.00266141804235125, 0.00440970289025837), `EUR/GBP_RBV t+1` = c(0.00288377777753365,
0.00300554199386584, 0.00360608177982326, 0.00327292734850446,
0.0029202430753471, 0.00336891287836027), `EUR/GBP_RV` = c(0.00446710941914797,
0.00401994700051122, 0.00407732180013827, 0.00466624428620966,
0.00458235106134663, 0.00482454749708351), `EUR/GBP_RV_5` = c(0.00499598016427624,
0.00470474196716823, 0.00456452150727461, 0.00453292965488229,
0.00436259471347075, 0.00442030721926592), `EUR/GBP_RV_22` = c(0.00515060219897263,
0.00509920878086075, 0.00502079002092667, 0.00501107755050095,
0.00499963428727425, 0.00495435807685843), `EUR/GBP_RBV` = c(0.00324667045338159,
0.00288377777753365, 0.00300554199386584, 0.00360608177982326,
0.00327292734850446, 0.00272655057625291), `EUR/GBP_RBV_5` = c(0.0034985439252634,
0.00318731350301598, 0.00319529774619179, 0.0032799330165155,
0.00320299987062176, 0.00310626895475871), `EUR/GBP_RBV_22` = c(0.0036581887941976,
0.00362298829344015, 0.00355498498935768, 0.0035465419934449,
0.00355752455210586, 0.00351669973034298), `EUR/GBP_RGV` = c(0.00306825643155514,
0.00280067842079775, 0.00275522601341373, 0.00296142025653418,
0.00320716195737542, 0.00398022367546721), `EUR/GBP_RGV_5` = c(0.00353290218424469,
0.00345194162523714, 0.00325362896209417, 0.00312087362386985,
0.00295854861593525, 0.00311308998902836), `EUR/GBP_RGV_22` = c(0.00359974659692405,
0.00356342531619103, 0.00352224165959556, 0.00351722666683608,
0.00349184335907274, 0.00346394410318992), `EUR/GBP_TotalCount` = structure(c(-0.179518680545716,
-0.0757259172924681, 0.333514120677483, 0.759064450015801, -0.419724789788948,
-0.360414639358521), .Dim = c(6L, 1L)), `EUR/GBP_BloombergCount` = structure(c(-0.701694550941621,
-0.669811381311996, -0.574161872423118, -0.644304845608295, -0.784590791978649,
-0.631551577756444), .Dim = c(6L, 1L)), `EUR/GBP_SocialMediaCount` = structure(c(-1.68861759789696,
-1.66829994393287, -1.5910928588693, -1.59515638966212, -1.6967446594826,
-1.63172816679749), .Dim = c(6L, 1L)), `EUR/GBP_NewsCount` = structure(c(0.76560533722738,
0.879161625683434, 1.33717198912285, 1.90306082659552, 0.487392430510049,
0.487392430510049), .Dim = c(6L, 1L))), na.action = structure(c(`6` = 6L,
`38` = 38L, `74` = 74L, `101` = 101L, `140` = 140L, `165` = 165L,
`189` = 189L, `197` = 197L, `236` = 236L, `256` = 256L, `323` = 323L,
`351` = 351L, `393` = 393L, `423` = 423L, `442` = 442L, `455` = 455L,
`490` = 490L, `510` = 510L, `551` = 551L, `576` = 576L, `605` = 605L,
`646` = 646L, `676` = 676L, `696` = 696L, `708` = 708L, `742` = 742L,
`762` = 762L, `793` = 793L, `829` = 829L, `858` = 858L, `904` = 904L,
`929` = 929L, `950` = 950L, `961` = 961L, `996` = 996L, `1016` = 1016L,
`1089` = 1089L, `1114` = 1114L, `1159` = 1159L, `1184` = 1184L,
`1207` = 1207L, `1216` = 1216L, `1238` = 1238L, `1243` = 1243L,
`1253` = 1253L, `1278` = 1278L, `1315` = 1315L, `1346` = 1346L,
`1372` = 1372L, `1416` = 1416L, `1441` = 1441L, `1473` = 1473L,
`1532` = 1532L, `1599` = 1599L, `1626` = 1626L, `1669` = 1669L,
`1694` = 1694L, `1718` = 1718L, `1726` = 1726L, `1766` = 1766L,
`1786` = 1786L, `1827` = 1827L, `1853` = 1853L, `1881` = 1881L,
`1922` = 1922L, `1952` = 1952L, `1971` = 1971L, `1984` = 1984L,
`2019` = 2019L, `2039` = 2039L, `2075` = 2075L, `2106` = 2106L,
`2135` = 2135L, `2181` = 2181L, `2206` = 2206L, `2227` = 2227L,
`2238` = 2238L, `2273` = 2273L, `2293` = 2293L, `2325` = 2325L,
`2366` = 2366L, `2391` = 2391L, `2436` = 2436L, `2461` = 2461L,
`2483` = 2483L, `2493` = 2493L), class = "omit"), row.names = c(1L,
2L, 3L, 4L, 5L, 7L), class = "data.frame")
I have built 9 regression models per forecast horizon (t+1, t+5 and t+22) and I am using the predict function to make my forecasts. I have coded this in an R loop, where I also try to assign each forecast to a matrix. My code is the following:
EUR/GBP_RBV_22`)
EURGBP_HAR_RVBt22_NT_train <- lm(data.estimateI am trying to calculate realized volatility forecasts using a rolling window forecast. My aim is to use the first 500 observations to forecast the 501st observations, then shift the window forward one step using observations 2 to 501 to predict the 502nd observation. I want this to repeat until I have a complete pseudo out-of-sample forecast.
My df contains 2411 observations of 23 variables, here is small example:
Date
EUR/GBP_RV t+1
EUR/GBP_RV
EUR/GBP_RV_5
EUR/GBP_RV_22
2012-02-13
0.004019947
0.004467109
0.004995980
0.005150602
2012-02-14
0.004077322
0.004019947
0.004704742
0.005099209
2012-02-15
0.004666244
0.004077322
0.004564522
0.005020790
2012-02-16
0.004582351
0.004666244
0.004532930
0.005011078
2012-02-17
0.003951071
0.004582351
0.004362595
0.004999634
2012-02-21
0.005549329
0.004824547
0.004467109
0.004954358
The head of the df can be reproduced with
structure(list(Date = structure(c(15383, 15384, 15385, 15386,
15387, 15391), class = "Date"), `EUR/GBP_RV t+1,t+22` = c(0.00437808494654599,
0.00439764887779732, 0.00441997330738947, 0.00437799055732722,
0.00435021150904479, 0.00434881306458859), `EUR/GBP_RGV t+1,t+22` = c(0.00310674728131117,
0.00311502965608506, 0.00313756204195853, 0.00312923997431178,
0.00310846773074243, 0.00309755540903969), `EUR/GBP_RBV t+1,t+22` = c(0.00304961980133602,
0.00306866297401415, 0.00307794319983677, 0.00302801249035602,
0.00300946121851254, 0.00302272755554915), `EUR/GBP_RV t+1,t+5` = c(0.00425938711995146,
0.00442030721926592, 0.00471470868108043, 0.00487869292442023,
0.00476849421943949, 0.0046067439660438), `EUR/GBP_RGV t+1,t+5` = c(0.00287718093809447,
0.00311308998902836, 0.00344398536439729, 0.00376911066284235,
0.00377425759242542, 0.00353909902900148), `EUR/GBP_RBV t+1,t+5` = c(0.00313771439501486,
0.00310626895475871, 0.0031789431316576, 0.00305962424370556,
0.00288671182187571, 0.00291630955829613), `EUR/GBP_RV t+1` = c(0.00401994700051122,
0.00407732180013827, 0.00466624428620966, 0.00458235106134663,
0.00395107145155152, 0.00554932910921084), `EUR/GBP_RGV t+1` = c(0.00280067842079775,
0.00275522601341373, 0.00296142025653418, 0.00320716195737542,
0.00266141804235125, 0.00440970289025837), `EUR/GBP_RBV t+1` = c(0.00288377777753365,
0.00300554199386584, 0.00360608177982326, 0.00327292734850446,
0.0029202430753471, 0.00336891287836027), `EUR/GBP_RV` = c(0.00446710941914797,
0.00401994700051122, 0.00407732180013827, 0.00466624428620966,
0.00458235106134663, 0.00482454749708351), `EUR/GBP_RV_5` = c(0.00499598016427624,
0.00470474196716823, 0.00456452150727461, 0.00453292965488229,
0.00436259471347075, 0.00442030721926592), `EUR/GBP_RV_22` = c(0.00515060219897263,
0.00509920878086075, 0.00502079002092667, 0.00501107755050095,
0.00499963428727425, 0.00495435807685843), `EUR/GBP_RBV` = c(0.00324667045338159,
0.00288377777753365, 0.00300554199386584, 0.00360608177982326,
0.00327292734850446, 0.00272655057625291), `EUR/GBP_RBV_5` = c(0.0034985439252634,
0.00318731350301598, 0.00319529774619179, 0.0032799330165155,
0.00320299987062176, 0.00310626895475871), `EUR/GBP_RBV_22` = c(0.0036581887941976,
0.00362298829344015, 0.00355498498935768, 0.0035465419934449,
0.00355752455210586, 0.00351669973034298), `EUR/GBP_RGV` = c(0.00306825643155514,
0.00280067842079775, 0.00275522601341373, 0.00296142025653418,
0.00320716195737542, 0.00398022367546721), `EUR/GBP_RGV_5` = c(0.00353290218424469,
0.00345194162523714, 0.00325362896209417, 0.00312087362386985,
0.00295854861593525, 0.00311308998902836), `EUR/GBP_RGV_22` = c(0.00359974659692405,
0.00356342531619103, 0.00352224165959556, 0.00351722666683608,
0.00349184335907274, 0.00346394410318992), `EUR/GBP_TotalCount` = structure(c(-0.179518680545716,
-0.0757259172924681, 0.333514120677483, 0.759064450015801, -0.419724789788948,
-0.360414639358521), .Dim = c(6L, 1L)), `EUR/GBP_BloombergCount` = structure(c(-0.701694550941621,
-0.669811381311996, -0.574161872423118, -0.644304845608295, -0.784590791978649,
-0.631551577756444), .Dim = c(6L, 1L)), `EUR/GBP_SocialMediaCount` = structure(c(-1.68861759789696,
-1.66829994393287, -1.5910928588693, -1.59515638966212, -1.6967446594826,
-1.63172816679749), .Dim = c(6L, 1L)), `EUR/GBP_NewsCount` = structure(c(0.76560533722738,
0.879161625683434, 1.33717198912285, 1.90306082659552, 0.487392430510049,
0.487392430510049), .Dim = c(6L, 1L))), na.action = structure(c(`6` = 6L,
`38` = 38L, `74` = 74L, `101` = 101L, `140` = 140L, `165` = 165L,
`189` = 189L, `197` = 197L, `236` = 236L, `256` = 256L, `323` = 323L,
`351` = 351L, `393` = 393L, `423` = 423L, `442` = 442L, `455` = 455L,
`490` = 490L, `510` = 510L, `551` = 551L, `576` = 576L, `605` = 605L,
`646` = 646L, `676` = 676L, `696` = 696L, `708` = 708L, `742` = 742L,
`762` = 762L, `793` = 793L, `829` = 829L, `858` = 858L, `904` = 904L,
`929` = 929L, `950` = 950L, `961` = 961L, `996` = 996L, `1016` = 1016L,
`1089` = 1089L, `1114` = 1114L, `1159` = 1159L, `1184` = 1184L,
`1207` = 1207L, `1216` = 1216L, `1238` = 1238L, `1243` = 1243L,
`1253` = 1253L, `1278` = 1278L, `1315` = 1315L, `1346` = 1346L,
`1372` = 1372L, `1416` = 1416L, `1441` = 1441L, `1473` = 1473L,
`1532` = 1532L, `1599` = 1599L, `1626` = 1626L, `1669` = 1669L,
`1694` = 1694L, `1718` = 1718L, `1726` = 1726L, `1766` = 1766L,
`1786` = 1786L, `1827` = 1827L, `1853` = 1853L, `1881` = 1881L,
`1922` = 1922L, `1952` = 1952L, `1971` = 1971L, `1984` = 1984L,
`2019` = 2019L, `2039` = 2039L, `2075` = 2075L, `2106` = 2106L,
`2135` = 2135L, `2181` = 2181L, `2206` = 2206L, `2227` = 2227L,
`2238` = 2238L, `2273` = 2273L, `2293` = 2293L, `2325` = 2325L,
`2366` = 2366L, `2391` = 2391L, `2436` = 2436L, `2461` = 2461L,
`2483` = 2483L, `2493` = 2493L), class = "omit"), row.names = c(1L,
2L, 3L, 4L, 5L, 7L), class = "data.frame")
I have built 9 regression models per forecast horizon (t+1, t+5 and t+22) and I am using the predict function to make my forecasts. I have coded this in an R loop, where I also try to assign each forecast to a matrix. My code is the following:
EUR/GBP_RBV t+1,t+22`~data.estimateI am trying to calculate realized volatility forecasts using a rolling window forecast. My aim is to use the first 500 observations to forecast the 501st observations, then shift the window forward one step using observations 2 to 501 to predict the 502nd observation. I want this to repeat until I have a complete pseudo out-of-sample forecast.
My df contains 2411 observations of 23 variables, here is small example:
Date
EUR/GBP_RV t+1
EUR/GBP_RV
EUR/GBP_RV_5
EUR/GBP_RV_22
2012-02-13
0.004019947
0.004467109
0.004995980
0.005150602
2012-02-14
0.004077322
0.004019947
0.004704742
0.005099209
2012-02-15
0.004666244
0.004077322
0.004564522
0.005020790
2012-02-16
0.004582351
0.004666244
0.004532930
0.005011078
2012-02-17
0.003951071
0.004582351
0.004362595
0.004999634
2012-02-21
0.005549329
0.004824547
0.004467109
0.004954358
The head of the df can be reproduced with
structure(list(Date = structure(c(15383, 15384, 15385, 15386,
15387, 15391), class = "Date"), `EUR/GBP_RV t+1,t+22` = c(0.00437808494654599,
0.00439764887779732, 0.00441997330738947, 0.00437799055732722,
0.00435021150904479, 0.00434881306458859), `EUR/GBP_RGV t+1,t+22` = c(0.00310674728131117,
0.00311502965608506, 0.00313756204195853, 0.00312923997431178,
0.00310846773074243, 0.00309755540903969), `EUR/GBP_RBV t+1,t+22` = c(0.00304961980133602,
0.00306866297401415, 0.00307794319983677, 0.00302801249035602,
0.00300946121851254, 0.00302272755554915), `EUR/GBP_RV t+1,t+5` = c(0.00425938711995146,
0.00442030721926592, 0.00471470868108043, 0.00487869292442023,
0.00476849421943949, 0.0046067439660438), `EUR/GBP_RGV t+1,t+5` = c(0.00287718093809447,
0.00311308998902836, 0.00344398536439729, 0.00376911066284235,
0.00377425759242542, 0.00353909902900148), `EUR/GBP_RBV t+1,t+5` = c(0.00313771439501486,
0.00310626895475871, 0.0031789431316576, 0.00305962424370556,
0.00288671182187571, 0.00291630955829613), `EUR/GBP_RV t+1` = c(0.00401994700051122,
0.00407732180013827, 0.00466624428620966, 0.00458235106134663,
0.00395107145155152, 0.00554932910921084), `EUR/GBP_RGV t+1` = c(0.00280067842079775,
0.00275522601341373, 0.00296142025653418, 0.00320716195737542,
0.00266141804235125, 0.00440970289025837), `EUR/GBP_RBV t+1` = c(0.00288377777753365,
0.00300554199386584, 0.00360608177982326, 0.00327292734850446,
0.0029202430753471, 0.00336891287836027), `EUR/GBP_RV` = c(0.00446710941914797,
0.00401994700051122, 0.00407732180013827, 0.00466624428620966,
0.00458235106134663, 0.00482454749708351), `EUR/GBP_RV_5` = c(0.00499598016427624,
0.00470474196716823, 0.00456452150727461, 0.00453292965488229,
0.00436259471347075, 0.00442030721926592), `EUR/GBP_RV_22` = c(0.00515060219897263,
0.00509920878086075, 0.00502079002092667, 0.00501107755050095,
0.00499963428727425, 0.00495435807685843), `EUR/GBP_RBV` = c(0.00324667045338159,
0.00288377777753365, 0.00300554199386584, 0.00360608177982326,
0.00327292734850446, 0.00272655057625291), `EUR/GBP_RBV_5` = c(0.0034985439252634,
0.00318731350301598, 0.00319529774619179, 0.0032799330165155,
0.00320299987062176, 0.00310626895475871), `EUR/GBP_RBV_22` = c(0.0036581887941976,
0.00362298829344015, 0.00355498498935768, 0.0035465419934449,
0.00355752455210586, 0.00351669973034298), `EUR/GBP_RGV` = c(0.00306825643155514,
0.00280067842079775, 0.00275522601341373, 0.00296142025653418,
0.00320716195737542, 0.00398022367546721), `EUR/GBP_RGV_5` = c(0.00353290218424469,
0.00345194162523714, 0.00325362896209417, 0.00312087362386985,
0.00295854861593525, 0.00311308998902836), `EUR/GBP_RGV_22` = c(0.00359974659692405,
0.00356342531619103, 0.00352224165959556, 0.00351722666683608,
0.00349184335907274, 0.00346394410318992), `EUR/GBP_TotalCount` = structure(c(-0.179518680545716,
-0.0757259172924681, 0.333514120677483, 0.759064450015801, -0.419724789788948,
-0.360414639358521), .Dim = c(6L, 1L)), `EUR/GBP_BloombergCount` = structure(c(-0.701694550941621,
-0.669811381311996, -0.574161872423118, -0.644304845608295, -0.784590791978649,
-0.631551577756444), .Dim = c(6L, 1L)), `EUR/GBP_SocialMediaCount` = structure(c(-1.68861759789696,
-1.66829994393287, -1.5910928588693, -1.59515638966212, -1.6967446594826,
-1.63172816679749), .Dim = c(6L, 1L)), `EUR/GBP_NewsCount` = structure(c(0.76560533722738,
0.879161625683434, 1.33717198912285, 1.90306082659552, 0.487392430510049,
0.487392430510049), .Dim = c(6L, 1L))), na.action = structure(c(`6` = 6L,
`38` = 38L, `74` = 74L, `101` = 101L, `140` = 140L, `165` = 165L,
`189` = 189L, `197` = 197L, `236` = 236L, `256` = 256L, `323` = 323L,
`351` = 351L, `393` = 393L, `423` = 423L, `442` = 442L, `455` = 455L,
`490` = 490L, `510` = 510L, `551` = 551L, `576` = 576L, `605` = 605L,
`646` = 646L, `676` = 676L, `696` = 696L, `708` = 708L, `742` = 742L,
`762` = 762L, `793` = 793L, `829` = 829L, `858` = 858L, `904` = 904L,
`929` = 929L, `950` = 950L, `961` = 961L, `996` = 996L, `1016` = 1016L,
`1089` = 1089L, `1114` = 1114L, `1159` = 1159L, `1184` = 1184L,
`1207` = 1207L, `1216` = 1216L, `1238` = 1238L, `1243` = 1243L,
`1253` = 1253L, `1278` = 1278L, `1315` = 1315L, `1346` = 1346L,
`1372` = 1372L, `1416` = 1416L, `1441` = 1441L, `1473` = 1473L,
`1532` = 1532L, `1599` = 1599L, `1626` = 1626L, `1669` = 1669L,
`1694` = 1694L, `1718` = 1718L, `1726` = 1726L, `1766` = 1766L,
`1786` = 1786L, `1827` = 1827L, `1853` = 1853L, `1881` = 1881L,
`1922` = 1922L, `1952` = 1952L, `1971` = 1971L, `1984` = 1984L,
`2019` = 2019L, `2039` = 2039L, `2075` = 2075L, `2106` = 2106L,
`2135` = 2135L, `2181` = 2181L, `2206` = 2206L, `2227` = 2227L,
`2238` = 2238L, `2273` = 2273L, `2293` = 2293L, `2325` = 2325L,
`2366` = 2366L, `2391` = 2391L, `2436` = 2436L, `2461` = 2461L,
`2483` = 2483L, `2493` = 2493L), class = "omit"), row.names = c(1L,
2L, 3L, 4L, 5L, 7L), class = "data.frame")
I have built 9 regression models per forecast horizon (t+1, t+5 and t+22) and I am using the predict function to make my forecasts. I have coded this in an R loop, where I also try to assign each forecast to a matrix. My code is the following:
EUR/GBP_RBV`+data.estimateI am trying to calculate realized volatility forecasts using a rolling window forecast. My aim is to use the first 500 observations to forecast the 501st observations, then shift the window forward one step using observations 2 to 501 to predict the 502nd observation. I want this to repeat until I have a complete pseudo out-of-sample forecast.
My df contains 2411 observations of 23 variables, here is small example:
Date
EUR/GBP_RV t+1
EUR/GBP_RV
EUR/GBP_RV_5
EUR/GBP_RV_22
2012-02-13
0.004019947
0.004467109
0.004995980
0.005150602
2012-02-14
0.004077322
0.004019947
0.004704742
0.005099209
2012-02-15
0.004666244
0.004077322
0.004564522
0.005020790
2012-02-16
0.004582351
0.004666244
0.004532930
0.005011078
2012-02-17
0.003951071
0.004582351
0.004362595
0.004999634
2012-02-21
0.005549329
0.004824547
0.004467109
0.004954358
The head of the df can be reproduced with
structure(list(Date = structure(c(15383, 15384, 15385, 15386,
15387, 15391), class = "Date"), `EUR/GBP_RV t+1,t+22` = c(0.00437808494654599,
0.00439764887779732, 0.00441997330738947, 0.00437799055732722,
0.00435021150904479, 0.00434881306458859), `EUR/GBP_RGV t+1,t+22` = c(0.00310674728131117,
0.00311502965608506, 0.00313756204195853, 0.00312923997431178,
0.00310846773074243, 0.00309755540903969), `EUR/GBP_RBV t+1,t+22` = c(0.00304961980133602,
0.00306866297401415, 0.00307794319983677, 0.00302801249035602,
0.00300946121851254, 0.00302272755554915), `EUR/GBP_RV t+1,t+5` = c(0.00425938711995146,
0.00442030721926592, 0.00471470868108043, 0.00487869292442023,
0.00476849421943949, 0.0046067439660438), `EUR/GBP_RGV t+1,t+5` = c(0.00287718093809447,
0.00311308998902836, 0.00344398536439729, 0.00376911066284235,
0.00377425759242542, 0.00353909902900148), `EUR/GBP_RBV t+1,t+5` = c(0.00313771439501486,
0.00310626895475871, 0.0031789431316576, 0.00305962424370556,
0.00288671182187571, 0.00291630955829613), `EUR/GBP_RV t+1` = c(0.00401994700051122,
0.00407732180013827, 0.00466624428620966, 0.00458235106134663,
0.00395107145155152, 0.00554932910921084), `EUR/GBP_RGV t+1` = c(0.00280067842079775,
0.00275522601341373, 0.00296142025653418, 0.00320716195737542,
0.00266141804235125, 0.00440970289025837), `EUR/GBP_RBV t+1` = c(0.00288377777753365,
0.00300554199386584, 0.00360608177982326, 0.00327292734850446,
0.0029202430753471, 0.00336891287836027), `EUR/GBP_RV` = c(0.00446710941914797,
0.00401994700051122, 0.00407732180013827, 0.00466624428620966,
0.00458235106134663, 0.00482454749708351), `EUR/GBP_RV_5` = c(0.00499598016427624,
0.00470474196716823, 0.00456452150727461, 0.00453292965488229,
0.00436259471347075, 0.00442030721926592), `EUR/GBP_RV_22` = c(0.00515060219897263,
0.00509920878086075, 0.00502079002092667, 0.00501107755050095,
0.00499963428727425, 0.00495435807685843), `EUR/GBP_RBV` = c(0.00324667045338159,
0.00288377777753365, 0.00300554199386584, 0.00360608177982326,
0.00327292734850446, 0.00272655057625291), `EUR/GBP_RBV_5` = c(0.0034985439252634,
0.00318731350301598, 0.00319529774619179, 0.0032799330165155,
0.00320299987062176, 0.00310626895475871), `EUR/GBP_RBV_22` = c(0.0036581887941976,
0.00362298829344015, 0.00355498498935768, 0.0035465419934449,
0.00355752455210586, 0.00351669973034298), `EUR/GBP_RGV` = c(0.00306825643155514,
0.00280067842079775, 0.00275522601341373, 0.00296142025653418,
0.00320716195737542, 0.00398022367546721), `EUR/GBP_RGV_5` = c(0.00353290218424469,
0.00345194162523714, 0.00325362896209417, 0.00312087362386985,
0.00295854861593525, 0.00311308998902836), `EUR/GBP_RGV_22` = c(0.00359974659692405,
0.00356342531619103, 0.00352224165959556, 0.00351722666683608,
0.00349184335907274, 0.00346394410318992), `EUR/GBP_TotalCount` = structure(c(-0.179518680545716,
-0.0757259172924681, 0.333514120677483, 0.759064450015801, -0.419724789788948,
-0.360414639358521), .Dim = c(6L, 1L)), `EUR/GBP_BloombergCount` = structure(c(-0.701694550941621,
-0.669811381311996, -0.574161872423118, -0.644304845608295, -0.784590791978649,
-0.631551577756444), .Dim = c(6L, 1L)), `EUR/GBP_SocialMediaCount` = structure(c(-1.68861759789696,
-1.66829994393287, -1.5910928588693, -1.59515638966212, -1.6967446594826,
-1.63172816679749), .Dim = c(6L, 1L)), `EUR/GBP_NewsCount` = structure(c(0.76560533722738,
0.879161625683434, 1.33717198912285, 1.90306082659552, 0.487392430510049,
0.487392430510049), .Dim = c(6L, 1L))), na.action = structure(c(`6` = 6L,
`38` = 38L, `74` = 74L, `101` = 101L, `140` = 140L, `165` = 165L,
`189` = 189L, `197` = 197L, `236` = 236L, `256` = 256L, `323` = 323L,
`351` = 351L, `393` = 393L, `423` = 423L, `442` = 442L, `455` = 455L,
`490` = 490L, `510` = 510L, `551` = 551L, `576` = 576L, `605` = 605L,
`646` = 646L, `676` = 676L, `696` = 696L, `708` = 708L, `742` = 742L,
`762` = 762L, `793` = 793L, `829` = 829L, `858` = 858L, `904` = 904L,
`929` = 929L, `950` = 950L, `961` = 961L, `996` = 996L, `1016` = 1016L,
`1089` = 1089L, `1114` = 1114L, `1159` = 1159L, `1184` = 1184L,
`1207` = 1207L, `1216` = 1216L, `1238` = 1238L, `1243` = 1243L,
`1253` = 1253L, `1278` = 1278L, `1315` = 1315L, `1346` = 1346L,
`1372` = 1372L, `1416` = 1416L, `1441` = 1441L, `1473` = 1473L,
`1532` = 1532L, `1599` = 1599L, `1626` = 1626L, `1669` = 1669L,
`1694` = 1694L, `1718` = 1718L, `1726` = 1726L, `1766` = 1766L,
`1786` = 1786L, `1827` = 1827L, `1853` = 1853L, `1881` = 1881L,
`1922` = 1922L, `1952` = 1952L, `1971` = 1971L, `1984` = 1984L,
`2019` = 2019L, `2039` = 2039L, `2075` = 2075L, `2106` = 2106L,
`2135` = 2135L, `2181` = 2181L, `2206` = 2206L, `2227` = 2227L,
`2238` = 2238L, `2273` = 2273L, `2293` = 2293L, `2325` = 2325L,
`2366` = 2366L, `2391` = 2391L, `2436` = 2436L, `2461` = 2461L,
`2483` = 2483L, `2493` = 2493L), class = "omit"), row.names = c(1L,
2L, 3L, 4L, 5L, 7L), class = "data.frame")
I have built 9 regression models per forecast horizon (t+1, t+5 and t+22) and I am using the predict function to make my forecasts. I have coded this in an R loop, where I also try to assign each forecast to a matrix. My code is the following:
EUR/GBP_RBV_5`+data.estimateI am trying to calculate realized volatility forecasts using a rolling window forecast. My aim is to use the first 500 observations to forecast the 501st observations, then shift the window forward one step using observations 2 to 501 to predict the 502nd observation. I want this to repeat until I have a complete pseudo out-of-sample forecast.
My df contains 2411 observations of 23 variables, here is small example:
Date
EUR/GBP_RV t+1
EUR/GBP_RV
EUR/GBP_RV_5
EUR/GBP_RV_22
2012-02-13
0.004019947
0.004467109
0.004995980
0.005150602
2012-02-14
0.004077322
0.004019947
0.004704742
0.005099209
2012-02-15
0.004666244
0.004077322
0.004564522
0.005020790
2012-02-16
0.004582351
0.004666244
0.004532930
0.005011078
2012-02-17
0.003951071
0.004582351
0.004362595
0.004999634
2012-02-21
0.005549329
0.004824547
0.004467109
0.004954358
The head of the df can be reproduced with
structure(list(Date = structure(c(15383, 15384, 15385, 15386,
15387, 15391), class = "Date"), `EUR/GBP_RV t+1,t+22` = c(0.00437808494654599,
0.00439764887779732, 0.00441997330738947, 0.00437799055732722,
0.00435021150904479, 0.00434881306458859), `EUR/GBP_RGV t+1,t+22` = c(0.00310674728131117,
0.00311502965608506, 0.00313756204195853, 0.00312923997431178,
0.00310846773074243, 0.00309755540903969), `EUR/GBP_RBV t+1,t+22` = c(0.00304961980133602,
0.00306866297401415, 0.00307794319983677, 0.00302801249035602,
0.00300946121851254, 0.00302272755554915), `EUR/GBP_RV t+1,t+5` = c(0.00425938711995146,
0.00442030721926592, 0.00471470868108043, 0.00487869292442023,
0.00476849421943949, 0.0046067439660438), `EUR/GBP_RGV t+1,t+5` = c(0.00287718093809447,
0.00311308998902836, 0.00344398536439729, 0.00376911066284235,
0.00377425759242542, 0.00353909902900148), `EUR/GBP_RBV t+1,t+5` = c(0.00313771439501486,
0.00310626895475871, 0.0031789431316576, 0.00305962424370556,
0.00288671182187571, 0.00291630955829613), `EUR/GBP_RV t+1` = c(0.00401994700051122,
0.00407732180013827, 0.00466624428620966, 0.00458235106134663,
0.00395107145155152, 0.00554932910921084), `EUR/GBP_RGV t+1` = c(0.00280067842079775,
0.00275522601341373, 0.00296142025653418, 0.00320716195737542,
0.00266141804235125, 0.00440970289025837), `EUR/GBP_RBV t+1` = c(0.00288377777753365,
0.00300554199386584, 0.00360608177982326, 0.00327292734850446,
0.0029202430753471, 0.00336891287836027), `EUR/GBP_RV` = c(0.00446710941914797,
0.00401994700051122, 0.00407732180013827, 0.00466624428620966,
0.00458235106134663, 0.00482454749708351), `EUR/GBP_RV_5` = c(0.00499598016427624,
0.00470474196716823, 0.00456452150727461, 0.00453292965488229,
0.00436259471347075, 0.00442030721926592), `EUR/GBP_RV_22` = c(0.00515060219897263,
0.00509920878086075, 0.00502079002092667, 0.00501107755050095,
0.00499963428727425, 0.00495435807685843), `EUR/GBP_RBV` = c(0.00324667045338159,
0.00288377777753365, 0.00300554199386584, 0.00360608177982326,
0.00327292734850446, 0.00272655057625291), `EUR/GBP_RBV_5` = c(0.0034985439252634,
0.00318731350301598, 0.00319529774619179, 0.0032799330165155,
0.00320299987062176, 0.00310626895475871), `EUR/GBP_RBV_22` = c(0.0036581887941976,
0.00362298829344015, 0.00355498498935768, 0.0035465419934449,
0.00355752455210586, 0.00351669973034298), `EUR/GBP_RGV` = c(0.00306825643155514,
0.00280067842079775, 0.00275522601341373, 0.00296142025653418,
0.00320716195737542, 0.00398022367546721), `EUR/GBP_RGV_5` = c(0.00353290218424469,
0.00345194162523714, 0.00325362896209417, 0.00312087362386985,
0.00295854861593525, 0.00311308998902836), `EUR/GBP_RGV_22` = c(0.00359974659692405,
0.00356342531619103, 0.00352224165959556, 0.00351722666683608,
0.00349184335907274, 0.00346394410318992), `EUR/GBP_TotalCount` = structure(c(-0.179518680545716,
-0.0757259172924681, 0.333514120677483, 0.759064450015801, -0.419724789788948,
-0.360414639358521), .Dim = c(6L, 1L)), `EUR/GBP_BloombergCount` = structure(c(-0.701694550941621,
-0.669811381311996, -0.574161872423118, -0.644304845608295, -0.784590791978649,
-0.631551577756444), .Dim = c(6L, 1L)), `EUR/GBP_SocialMediaCount` = structure(c(-1.68861759789696,
-1.66829994393287, -1.5910928588693, -1.59515638966212, -1.6967446594826,
-1.63172816679749), .Dim = c(6L, 1L)), `EUR/GBP_NewsCount` = structure(c(0.76560533722738,
0.879161625683434, 1.33717198912285, 1.90306082659552, 0.487392430510049,
0.487392430510049), .Dim = c(6L, 1L))), na.action = structure(c(`6` = 6L,
`38` = 38L, `74` = 74L, `101` = 101L, `140` = 140L, `165` = 165L,
`189` = 189L, `197` = 197L, `236` = 236L, `256` = 256L, `323` = 323L,
`351` = 351L, `393` = 393L, `423` = 423L, `442` = 442L, `455` = 455L,
`490` = 490L, `510` = 510L, `551` = 551L, `576` = 576L, `605` = 605L,
`646` = 646L, `676` = 676L, `696` = 696L, `708` = 708L, `742` = 742L,
`762` = 762L, `793` = 793L, `829` = 829L, `858` = 858L, `904` = 904L,
`929` = 929L, `950` = 950L, `961` = 961L, `996` = 996L, `1016` = 1016L,
`1089` = 1089L, `1114` = 1114L, `1159` = 1159L, `1184` = 1184L,
`1207` = 1207L, `1216` = 1216L, `1238` = 1238L, `1243` = 1243L,
`1253` = 1253L, `1278` = 1278L, `1315` = 1315L, `1346` = 1346L,
`1372` = 1372L, `1416` = 1416L, `1441` = 1441L, `1473` = 1473L,
`1532` = 1532L, `1599` = 1599L, `1626` = 1626L, `1669` = 1669L,
`1694` = 1694L, `1718` = 1718L, `1726` = 1726L, `1766` = 1766L,
`1786` = 1786L, `1827` = 1827L, `1853` = 1853L, `1881` = 1881L,
`1922` = 1922L, `1952` = 1952L, `1971` = 1971L, `1984` = 1984L,
`2019` = 2019L, `2039` = 2039L, `2075` = 2075L, `2106` = 2106L,
`2135` = 2135L, `2181` = 2181L, `2206` = 2206L, `2227` = 2227L,
`2238` = 2238L, `2273` = 2273L, `2293` = 2293L, `2325` = 2325L,
`2366` = 2366L, `2391` = 2391L, `2436` = 2436L, `2461` = 2461L,
`2483` = 2483L, `2493` = 2493L), class = "omit"), row.names = c(1L,
2L, 3L, 4L, 5L, 7L), class = "data.frame")
I have built 9 regression models per forecast horizon (t+1, t+5 and t+22) and I am using the predict function to make my forecasts. I have coded this in an R loop, where I also try to assign each forecast to a matrix. My code is the following:
EUR/GBP_RBV_22`+data.estimateI am trying to calculate realized volatility forecasts using a rolling window forecast. My aim is to use the first 500 observations to forecast the 501st observations, then shift the window forward one step using observations 2 to 501 to predict the 502nd observation. I want this to repeat until I have a complete pseudo out-of-sample forecast.
My df contains 2411 observations of 23 variables, here is small example:
Date
EUR/GBP_RV t+1
EUR/GBP_RV
EUR/GBP_RV_5
EUR/GBP_RV_22
2012-02-13
0.004019947
0.004467109
0.004995980
0.005150602
2012-02-14
0.004077322
0.004019947
0.004704742
0.005099209
2012-02-15
0.004666244
0.004077322
0.004564522
0.005020790
2012-02-16
0.004582351
0.004666244
0.004532930
0.005011078
2012-02-17
0.003951071
0.004582351
0.004362595
0.004999634
2012-02-21
0.005549329
0.004824547
0.004467109
0.004954358
The head of the df can be reproduced with
structure(list(Date = structure(c(15383, 15384, 15385, 15386,
15387, 15391), class = "Date"), `EUR/GBP_RV t+1,t+22` = c(0.00437808494654599,
0.00439764887779732, 0.00441997330738947, 0.00437799055732722,
0.00435021150904479, 0.00434881306458859), `EUR/GBP_RGV t+1,t+22` = c(0.00310674728131117,
0.00311502965608506, 0.00313756204195853, 0.00312923997431178,
0.00310846773074243, 0.00309755540903969), `EUR/GBP_RBV t+1,t+22` = c(0.00304961980133602,
0.00306866297401415, 0.00307794319983677, 0.00302801249035602,
0.00300946121851254, 0.00302272755554915), `EUR/GBP_RV t+1,t+5` = c(0.00425938711995146,
0.00442030721926592, 0.00471470868108043, 0.00487869292442023,
0.00476849421943949, 0.0046067439660438), `EUR/GBP_RGV t+1,t+5` = c(0.00287718093809447,
0.00311308998902836, 0.00344398536439729, 0.00376911066284235,
0.00377425759242542, 0.00353909902900148), `EUR/GBP_RBV t+1,t+5` = c(0.00313771439501486,
0.00310626895475871, 0.0031789431316576, 0.00305962424370556,
0.00288671182187571, 0.00291630955829613), `EUR/GBP_RV t+1` = c(0.00401994700051122,
0.00407732180013827, 0.00466624428620966, 0.00458235106134663,
0.00395107145155152, 0.00554932910921084), `EUR/GBP_RGV t+1` = c(0.00280067842079775,
0.00275522601341373, 0.00296142025653418, 0.00320716195737542,
0.00266141804235125, 0.00440970289025837), `EUR/GBP_RBV t+1` = c(0.00288377777753365,
0.00300554199386584, 0.00360608177982326, 0.00327292734850446,
0.0029202430753471, 0.00336891287836027), `EUR/GBP_RV` = c(0.00446710941914797,
0.00401994700051122, 0.00407732180013827, 0.00466624428620966,
0.00458235106134663, 0.00482454749708351), `EUR/GBP_RV_5` = c(0.00499598016427624,
0.00470474196716823, 0.00456452150727461, 0.00453292965488229,
0.00436259471347075, 0.00442030721926592), `EUR/GBP_RV_22` = c(0.00515060219897263,
0.00509920878086075, 0.00502079002092667, 0.00501107755050095,
0.00499963428727425, 0.00495435807685843), `EUR/GBP_RBV` = c(0.00324667045338159,
0.00288377777753365, 0.00300554199386584, 0.00360608177982326,
0.00327292734850446, 0.00272655057625291), `EUR/GBP_RBV_5` = c(0.0034985439252634,
0.00318731350301598, 0.00319529774619179, 0.0032799330165155,
0.00320299987062176, 0.00310626895475871), `EUR/GBP_RBV_22` = c(0.0036581887941976,
0.00362298829344015, 0.00355498498935768, 0.0035465419934449,
0.00355752455210586, 0.00351669973034298), `EUR/GBP_RGV` = c(0.00306825643155514,
0.00280067842079775, 0.00275522601341373, 0.00296142025653418,
0.00320716195737542, 0.00398022367546721), `EUR/GBP_RGV_5` = c(0.00353290218424469,
0.00345194162523714, 0.00325362896209417, 0.00312087362386985,
0.00295854861593525, 0.00311308998902836), `EUR/GBP_RGV_22` = c(0.00359974659692405,
0.00356342531619103, 0.00352224165959556, 0.00351722666683608,
0.00349184335907274, 0.00346394410318992), `EUR/GBP_TotalCount` = structure(c(-0.179518680545716,
-0.0757259172924681, 0.333514120677483, 0.759064450015801, -0.419724789788948,
-0.360414639358521), .Dim = c(6L, 1L)), `EUR/GBP_BloombergCount` = structure(c(-0.701694550941621,
-0.669811381311996, -0.574161872423118, -0.644304845608295, -0.784590791978649,
-0.631551577756444), .Dim = c(6L, 1L)), `EUR/GBP_SocialMediaCount` = structure(c(-1.68861759789696,
-1.66829994393287, -1.5910928588693, -1.59515638966212, -1.6967446594826,
-1.63172816679749), .Dim = c(6L, 1L)), `EUR/GBP_NewsCount` = structure(c(0.76560533722738,
0.879161625683434, 1.33717198912285, 1.90306082659552, 0.487392430510049,
0.487392430510049), .Dim = c(6L, 1L))), na.action = structure(c(`6` = 6L,
`38` = 38L, `74` = 74L, `101` = 101L, `140` = 140L, `165` = 165L,
`189` = 189L, `197` = 197L, `236` = 236L, `256` = 256L, `323` = 323L,
`351` = 351L, `393` = 393L, `423` = 423L, `442` = 442L, `455` = 455L,
`490` = 490L, `510` = 510L, `551` = 551L, `576` = 576L, `605` = 605L,
`646` = 646L, `676` = 676L, `696` = 696L, `708` = 708L, `742` = 742L,
`762` = 762L, `793` = 793L, `829` = 829L, `858` = 858L, `904` = 904L,
`929` = 929L, `950` = 950L, `961` = 961L, `996` = 996L, `1016` = 1016L,
`1089` = 1089L, `1114` = 1114L, `1159` = 1159L, `1184` = 1184L,
`1207` = 1207L, `1216` = 1216L, `1238` = 1238L, `1243` = 1243L,
`1253` = 1253L, `1278` = 1278L, `1315` = 1315L, `1346` = 1346L,
`1372` = 1372L, `1416` = 1416L, `1441` = 1441L, `1473` = 1473L,
`1532` = 1532L, `1599` = 1599L, `1626` = 1626L, `1669` = 1669L,
`1694` = 1694L, `1718` = 1718L, `1726` = 1726L, `1766` = 1766L,
`1786` = 1786L, `1827` = 1827L, `1853` = 1853L, `1881` = 1881L,
`1922` = 1922L, `1952` = 1952L, `1971` = 1971L, `1984` = 1984L,
`2019` = 2019L, `2039` = 2039L, `2075` = 2075L, `2106` = 2106L,
`2135` = 2135L, `2181` = 2181L, `2206` = 2206L, `2227` = 2227L,
`2238` = 2238L, `2273` = 2273L, `2293` = 2293L, `2325` = 2325L,
`2366` = 2366L, `2391` = 2391L, `2436` = 2436L, `2461` = 2461L,
`2483` = 2483L, `2493` = 2493L), class = "omit"), row.names = c(1L,
2L, 3L, 4L, 5L, 7L), class = "data.frame")
I have built 9 regression models per forecast horizon (t+1, t+5 and t+22) and I am using the predict function to make my forecasts. I have coded this in an R loop, where I also try to assign each forecast to a matrix. My code is the following:
EUR/GBP_TotalCount`)
EURGBP_HAR_RVGt22_train <- lm(data.estimateI am trying to calculate realized volatility forecasts using a rolling window forecast. My aim is to use the first 500 observations to forecast the 501st observations, then shift the window forward one step using observations 2 to 501 to predict the 502nd observation. I want this to repeat until I have a complete pseudo out-of-sample forecast.
My df contains 2411 observations of 23 variables, here is small example:
Date
EUR/GBP_RV t+1
EUR/GBP_RV
EUR/GBP_RV_5
EUR/GBP_RV_22
2012-02-13
0.004019947
0.004467109
0.004995980
0.005150602
2012-02-14
0.004077322
0.004019947
0.004704742
0.005099209
2012-02-15
0.004666244
0.004077322
0.004564522
0.005020790
2012-02-16
0.004582351
0.004666244
0.004532930
0.005011078
2012-02-17
0.003951071
0.004582351
0.004362595
0.004999634
2012-02-21
0.005549329
0.004824547
0.004467109
0.004954358
The head of the df can be reproduced with
structure(list(Date = structure(c(15383, 15384, 15385, 15386,
15387, 15391), class = "Date"), `EUR/GBP_RV t+1,t+22` = c(0.00437808494654599,
0.00439764887779732, 0.00441997330738947, 0.00437799055732722,
0.00435021150904479, 0.00434881306458859), `EUR/GBP_RGV t+1,t+22` = c(0.00310674728131117,
0.00311502965608506, 0.00313756204195853, 0.00312923997431178,
0.00310846773074243, 0.00309755540903969), `EUR/GBP_RBV t+1,t+22` = c(0.00304961980133602,
0.00306866297401415, 0.00307794319983677, 0.00302801249035602,
0.00300946121851254, 0.00302272755554915), `EUR/GBP_RV t+1,t+5` = c(0.00425938711995146,
0.00442030721926592, 0.00471470868108043, 0.00487869292442023,
0.00476849421943949, 0.0046067439660438), `EUR/GBP_RGV t+1,t+5` = c(0.00287718093809447,
0.00311308998902836, 0.00344398536439729, 0.00376911066284235,
0.00377425759242542, 0.00353909902900148), `EUR/GBP_RBV t+1,t+5` = c(0.00313771439501486,
0.00310626895475871, 0.0031789431316576, 0.00305962424370556,
0.00288671182187571, 0.00291630955829613), `EUR/GBP_RV t+1` = c(0.00401994700051122,
0.00407732180013827, 0.00466624428620966, 0.00458235106134663,
0.00395107145155152, 0.00554932910921084), `EUR/GBP_RGV t+1` = c(0.00280067842079775,
0.00275522601341373, 0.00296142025653418, 0.00320716195737542,
0.00266141804235125, 0.00440970289025837), `EUR/GBP_RBV t+1` = c(0.00288377777753365,
0.00300554199386584, 0.00360608177982326, 0.00327292734850446,
0.0029202430753471, 0.00336891287836027), `EUR/GBP_RV` = c(0.00446710941914797,
0.00401994700051122, 0.00407732180013827, 0.00466624428620966,
0.00458235106134663, 0.00482454749708351), `EUR/GBP_RV_5` = c(0.00499598016427624,
0.00470474196716823, 0.00456452150727461, 0.00453292965488229,
0.00436259471347075, 0.00442030721926592), `EUR/GBP_RV_22` = c(0.00515060219897263,
0.00509920878086075, 0.00502079002092667, 0.00501107755050095,
0.00499963428727425, 0.00495435807685843), `EUR/GBP_RBV` = c(0.00324667045338159,
0.00288377777753365, 0.00300554199386584, 0.00360608177982326,
0.00327292734850446, 0.00272655057625291), `EUR/GBP_RBV_5` = c(0.0034985439252634,
0.00318731350301598, 0.00319529774619179, 0.0032799330165155,
0.00320299987062176, 0.00310626895475871), `EUR/GBP_RBV_22` = c(0.0036581887941976,
0.00362298829344015, 0.00355498498935768, 0.0035465419934449,
0.00355752455210586, 0.00351669973034298), `EUR/GBP_RGV` = c(0.00306825643155514,
0.00280067842079775, 0.00275522601341373, 0.00296142025653418,
0.00320716195737542, 0.00398022367546721), `EUR/GBP_RGV_5` = c(0.00353290218424469,
0.00345194162523714, 0.00325362896209417, 0.00312087362386985,
0.00295854861593525, 0.00311308998902836), `EUR/GBP_RGV_22` = c(0.00359974659692405,
0.00356342531619103, 0.00352224165959556, 0.00351722666683608,
0.00349184335907274, 0.00346394410318992), `EUR/GBP_TotalCount` = structure(c(-0.179518680545716,
-0.0757259172924681, 0.333514120677483, 0.759064450015801, -0.419724789788948,
-0.360414639358521), .Dim = c(6L, 1L)), `EUR/GBP_BloombergCount` = structure(c(-0.701694550941621,
-0.669811381311996, -0.574161872423118, -0.644304845608295, -0.784590791978649,
-0.631551577756444), .Dim = c(6L, 1L)), `EUR/GBP_SocialMediaCount` = structure(c(-1.68861759789696,
-1.66829994393287, -1.5910928588693, -1.59515638966212, -1.6967446594826,
-1.63172816679749), .Dim = c(6L, 1L)), `EUR/GBP_NewsCount` = structure(c(0.76560533722738,
0.879161625683434, 1.33717198912285, 1.90306082659552, 0.487392430510049,
0.487392430510049), .Dim = c(6L, 1L))), na.action = structure(c(`6` = 6L,
`38` = 38L, `74` = 74L, `101` = 101L, `140` = 140L, `165` = 165L,
`189` = 189L, `197` = 197L, `236` = 236L, `256` = 256L, `323` = 323L,
`351` = 351L, `393` = 393L, `423` = 423L, `442` = 442L, `455` = 455L,
`490` = 490L, `510` = 510L, `551` = 551L, `576` = 576L, `605` = 605L,
`646` = 646L, `676` = 676L, `696` = 696L, `708` = 708L, `742` = 742L,
`762` = 762L, `793` = 793L, `829` = 829L, `858` = 858L, `904` = 904L,
`929` = 929L, `950` = 950L, `961` = 961L, `996` = 996L, `1016` = 1016L,
`1089` = 1089L, `1114` = 1114L, `1159` = 1159L, `1184` = 1184L,
`1207` = 1207L, `1216` = 1216L, `1238` = 1238L, `1243` = 1243L,
`1253` = 1253L, `1278` = 1278L, `1315` = 1315L, `1346` = 1346L,
`1372` = 1372L, `1416` = 1416L, `1441` = 1441L, `1473` = 1473L,
`1532` = 1532L, `1599` = 1599L, `1626` = 1626L, `1669` = 1669L,
`1694` = 1694L, `1718` = 1718L, `1726` = 1726L, `1766` = 1766L,
`1786` = 1786L, `1827` = 1827L, `1853` = 1853L, `1881` = 1881L,
`1922` = 1922L, `1952` = 1952L, `1971` = 1971L, `1984` = 1984L,
`2019` = 2019L, `2039` = 2039L, `2075` = 2075L, `2106` = 2106L,
`2135` = 2135L, `2181` = 2181L, `2206` = 2206L, `2227` = 2227L,
`2238` = 2238L, `2273` = 2273L, `2293` = 2293L, `2325` = 2325L,
`2366` = 2366L, `2391` = 2391L, `2436` = 2436L, `2461` = 2461L,
`2483` = 2483L, `2493` = 2493L), class = "omit"), row.names = c(1L,
2L, 3L, 4L, 5L, 7L), class = "data.frame")
I have built 9 regression models per forecast horizon (t+1, t+5 and t+22) and I am using the predict function to make my forecasts. I have coded this in an R loop, where I also try to assign each forecast to a matrix. My code is the following:
EUR/GBP_RGV t+1,t+22`~data.estimateI am trying to calculate realized volatility forecasts using a rolling window forecast. My aim is to use the first 500 observations to forecast the 501st observations, then shift the window forward one step using observations 2 to 501 to predict the 502nd observation. I want this to repeat until I have a complete pseudo out-of-sample forecast.
My df contains 2411 observations of 23 variables, here is small example:
Date
EUR/GBP_RV t+1
EUR/GBP_RV
EUR/GBP_RV_5
EUR/GBP_RV_22
2012-02-13
0.004019947
0.004467109
0.004995980
0.005150602
2012-02-14
0.004077322
0.004019947
0.004704742
0.005099209
2012-02-15
0.004666244
0.004077322
0.004564522
0.005020790
2012-02-16
0.004582351
0.004666244
0.004532930
0.005011078
2012-02-17
0.003951071
0.004582351
0.004362595
0.004999634
2012-02-21
0.005549329
0.004824547
0.004467109
0.004954358
The head of the df can be reproduced with
structure(list(Date = structure(c(15383, 15384, 15385, 15386,
15387, 15391), class = "Date"), `EUR/GBP_RV t+1,t+22` = c(0.00437808494654599,
0.00439764887779732, 0.00441997330738947, 0.00437799055732722,
0.00435021150904479, 0.00434881306458859), `EUR/GBP_RGV t+1,t+22` = c(0.00310674728131117,
0.00311502965608506, 0.00313756204195853, 0.00312923997431178,
0.00310846773074243, 0.00309755540903969), `EUR/GBP_RBV t+1,t+22` = c(0.00304961980133602,
0.00306866297401415, 0.00307794319983677, 0.00302801249035602,
0.00300946121851254, 0.00302272755554915), `EUR/GBP_RV t+1,t+5` = c(0.00425938711995146,
0.00442030721926592, 0.00471470868108043, 0.00487869292442023,
0.00476849421943949, 0.0046067439660438), `EUR/GBP_RGV t+1,t+5` = c(0.00287718093809447,
0.00311308998902836, 0.00344398536439729, 0.00376911066284235,
0.00377425759242542, 0.00353909902900148), `EUR/GBP_RBV t+1,t+5` = c(0.00313771439501486,
0.00310626895475871, 0.0031789431316576, 0.00305962424370556,
0.00288671182187571, 0.00291630955829613), `EUR/GBP_RV t+1` = c(0.00401994700051122,
0.00407732180013827, 0.00466624428620966, 0.00458235106134663,
0.00395107145155152, 0.00554932910921084), `EUR/GBP_RGV t+1` = c(0.00280067842079775,
0.00275522601341373, 0.00296142025653418, 0.00320716195737542,
0.00266141804235125, 0.00440970289025837), `EUR/GBP_RBV t+1` = c(0.00288377777753365,
0.00300554199386584, 0.00360608177982326, 0.00327292734850446,
0.0029202430753471, 0.00336891287836027), `EUR/GBP_RV` = c(0.00446710941914797,
0.00401994700051122, 0.00407732180013827, 0.00466624428620966,
0.00458235106134663, 0.00482454749708351), `EUR/GBP_RV_5` = c(0.00499598016427624,
0.00470474196716823, 0.00456452150727461, 0.00453292965488229,
0.00436259471347075, 0.00442030721926592), `EUR/GBP_RV_22` = c(0.00515060219897263,
0.00509920878086075, 0.00502079002092667, 0.00501107755050095,
0.00499963428727425, 0.00495435807685843), `EUR/GBP_RBV` = c(0.00324667045338159,
0.00288377777753365, 0.00300554199386584, 0.00360608177982326,
0.00327292734850446, 0.00272655057625291), `EUR/GBP_RBV_5` = c(0.0034985439252634,
0.00318731350301598, 0.00319529774619179, 0.0032799330165155,
0.00320299987062176, 0.00310626895475871), `EUR/GBP_RBV_22` = c(0.0036581887941976,
0.00362298829344015, 0.00355498498935768, 0.0035465419934449,
0.00355752455210586, 0.00351669973034298), `EUR/GBP_RGV` = c(0.00306825643155514,
0.00280067842079775, 0.00275522601341373, 0.00296142025653418,
0.00320716195737542, 0.00398022367546721), `EUR/GBP_RGV_5` = c(0.00353290218424469,
0.00345194162523714, 0.00325362896209417, 0.00312087362386985,
0.00295854861593525, 0.00311308998902836), `EUR/GBP_RGV_22` = c(0.00359974659692405,
0.00356342531619103, 0.00352224165959556, 0.00351722666683608,
0.00349184335907274, 0.00346394410318992), `EUR/GBP_TotalCount` = structure(c(-0.179518680545716,
-0.0757259172924681, 0.333514120677483, 0.759064450015801, -0.419724789788948,
-0.360414639358521), .Dim = c(6L, 1L)), `EUR/GBP_BloombergCount` = structure(c(-0.701694550941621,
-0.669811381311996, -0.574161872423118, -0.644304845608295, -0.784590791978649,
-0.631551577756444), .Dim = c(6L, 1L)), `EUR/GBP_SocialMediaCount` = structure(c(-1.68861759789696,
-1.66829994393287, -1.5910928588693, -1.59515638966212, -1.6967446594826,
-1.63172816679749), .Dim = c(6L, 1L)), `EUR/GBP_NewsCount` = structure(c(0.76560533722738,
0.879161625683434, 1.33717198912285, 1.90306082659552, 0.487392430510049,
0.487392430510049), .Dim = c(6L, 1L))), na.action = structure(c(`6` = 6L,
`38` = 38L, `74` = 74L, `101` = 101L, `140` = 140L, `165` = 165L,
`189` = 189L, `197` = 197L, `236` = 236L, `256` = 256L, `323` = 323L,
`351` = 351L, `393` = 393L, `423` = 423L, `442` = 442L, `455` = 455L,
`490` = 490L, `510` = 510L, `551` = 551L, `576` = 576L, `605` = 605L,
`646` = 646L, `676` = 676L, `696` = 696L, `708` = 708L, `742` = 742L,
`762` = 762L, `793` = 793L, `829` = 829L, `858` = 858L, `904` = 904L,
`929` = 929L, `950` = 950L, `961` = 961L, `996` = 996L, `1016` = 1016L,
`1089` = 1089L, `1114` = 1114L, `1159` = 1159L, `1184` = 1184L,
`1207` = 1207L, `1216` = 1216L, `1238` = 1238L, `1243` = 1243L,
`1253` = 1253L, `1278` = 1278L, `1315` = 1315L, `1346` = 1346L,
`1372` = 1372L, `1416` = 1416L, `1441` = 1441L, `1473` = 1473L,
`1532` = 1532L, `1599` = 1599L, `1626` = 1626L, `1669` = 1669L,
`1694` = 1694L, `1718` = 1718L, `1726` = 1726L, `1766` = 1766L,
`1786` = 1786L, `1827` = 1827L, `1853` = 1853L, `1881` = 1881L,
`1922` = 1922L, `1952` = 1952L, `1971` = 1971L, `1984` = 1984L,
`2019` = 2019L, `2039` = 2039L, `2075` = 2075L, `2106` = 2106L,
`2135` = 2135L, `2181` = 2181L, `2206` = 2206L, `2227` = 2227L,
`2238` = 2238L, `2273` = 2273L, `2293` = 2293L, `2325` = 2325L,
`2366` = 2366L, `2391` = 2391L, `2436` = 2436L, `2461` = 2461L,
`2483` = 2483L, `2493` = 2493L), class = "omit"), row.names = c(1L,
2L, 3L, 4L, 5L, 7L), class = "data.frame")
I have built 9 regression models per forecast horizon (t+1, t+5 and t+22) and I am using the predict function to make my forecasts. I have coded this in an R loop, where I also try to assign each forecast to a matrix. My code is the following:
EUR/GBP_RGV`+data.estimateI am trying to calculate realized volatility forecasts using a rolling window forecast. My aim is to use the first 500 observations to forecast the 501st observations, then shift the window forward one step using observations 2 to 501 to predict the 502nd observation. I want this to repeat until I have a complete pseudo out-of-sample forecast.
My df contains 2411 observations of 23 variables, here is small example:
Date
EUR/GBP_RV t+1
EUR/GBP_RV
EUR/GBP_RV_5
EUR/GBP_RV_22
2012-02-13
0.004019947
0.004467109
0.004995980
0.005150602
2012-02-14
0.004077322
0.004019947
0.004704742
0.005099209
2012-02-15
0.004666244
0.004077322
0.004564522
0.005020790
2012-02-16
0.004582351
0.004666244
0.004532930
0.005011078
2012-02-17
0.003951071
0.004582351
0.004362595
0.004999634
2012-02-21
0.005549329
0.004824547
0.004467109
0.004954358
The head of the df can be reproduced with
structure(list(Date = structure(c(15383, 15384, 15385, 15386,
15387, 15391), class = "Date"), `EUR/GBP_RV t+1,t+22` = c(0.00437808494654599,
0.00439764887779732, 0.00441997330738947, 0.00437799055732722,
0.00435021150904479, 0.00434881306458859), `EUR/GBP_RGV t+1,t+22` = c(0.00310674728131117,
0.00311502965608506, 0.00313756204195853, 0.00312923997431178,
0.00310846773074243, 0.00309755540903969), `EUR/GBP_RBV t+1,t+22` = c(0.00304961980133602,
0.00306866297401415, 0.00307794319983677, 0.00302801249035602,
0.00300946121851254, 0.00302272755554915), `EUR/GBP_RV t+1,t+5` = c(0.00425938711995146,
0.00442030721926592, 0.00471470868108043, 0.00487869292442023,
0.00476849421943949, 0.0046067439660438), `EUR/GBP_RGV t+1,t+5` = c(0.00287718093809447,
0.00311308998902836, 0.00344398536439729, 0.00376911066284235,
0.00377425759242542, 0.00353909902900148), `EUR/GBP_RBV t+1,t+5` = c(0.00313771439501486,
0.00310626895475871, 0.0031789431316576, 0.00305962424370556,
0.00288671182187571, 0.00291630955829613), `EUR/GBP_RV t+1` = c(0.00401994700051122,
0.00407732180013827, 0.00466624428620966, 0.00458235106134663,
0.00395107145155152, 0.00554932910921084), `EUR/GBP_RGV t+1` = c(0.00280067842079775,
0.00275522601341373, 0.00296142025653418, 0.00320716195737542,
0.00266141804235125, 0.00440970289025837), `EUR/GBP_RBV t+1` = c(0.00288377777753365,
0.00300554199386584, 0.00360608177982326, 0.00327292734850446,
0.0029202430753471, 0.00336891287836027), `EUR/GBP_RV` = c(0.00446710941914797,
0.00401994700051122, 0.00407732180013827, 0.00466624428620966,
0.00458235106134663, 0.00482454749708351), `EUR/GBP_RV_5` = c(0.00499598016427624,
0.00470474196716823, 0.00456452150727461, 0.00453292965488229,
0.00436259471347075, 0.00442030721926592), `EUR/GBP_RV_22` = c(0.00515060219897263,
0.00509920878086075, 0.00502079002092667, 0.00501107755050095,
0.00499963428727425, 0.00495435807685843), `EUR/GBP_RBV` = c(0.00324667045338159,
0.00288377777753365, 0.00300554199386584, 0.00360608177982326,
0.00327292734850446, 0.00272655057625291), `EUR/GBP_RBV_5` = c(0.0034985439252634,
0.00318731350301598, 0.00319529774619179, 0.0032799330165155,
0.00320299987062176, 0.00310626895475871), `EUR/GBP_RBV_22` = c(0.0036581887941976,
0.00362298829344015, 0.00355498498935768, 0.0035465419934449,
0.00355752455210586, 0.00351669973034298), `EUR/GBP_RGV` = c(0.00306825643155514,
0.00280067842079775, 0.00275522601341373, 0.00296142025653418,
0.00320716195737542, 0.00398022367546721), `EUR/GBP_RGV_5` = c(0.00353290218424469,
0.00345194162523714, 0.00325362896209417, 0.00312087362386985,
0.00295854861593525, 0.00311308998902836), `EUR/GBP_RGV_22` = c(0.00359974659692405,
0.00356342531619103, 0.00352224165959556, 0.00351722666683608,
0.00349184335907274, 0.00346394410318992), `EUR/GBP_TotalCount` = structure(c(-0.179518680545716,
-0.0757259172924681, 0.333514120677483, 0.759064450015801, -0.419724789788948,
-0.360414639358521), .Dim = c(6L, 1L)), `EUR/GBP_BloombergCount` = structure(c(-0.701694550941621,
-0.669811381311996, -0.574161872423118, -0.644304845608295, -0.784590791978649,
-0.631551577756444), .Dim = c(6L, 1L)), `EUR/GBP_SocialMediaCount` = structure(c(-1.68861759789696,
-1.66829994393287, -1.5910928588693, -1.59515638966212, -1.6967446594826,
-1.63172816679749), .Dim = c(6L, 1L)), `EUR/GBP_NewsCount` = structure(c(0.76560533722738,
0.879161625683434, 1.33717198912285, 1.90306082659552, 0.487392430510049,
0.487392430510049), .Dim = c(6L, 1L))), na.action = structure(c(`6` = 6L,
`38` = 38L, `74` = 74L, `101` = 101L, `140` = 140L, `165` = 165L,
`189` = 189L, `197` = 197L, `236` = 236L, `256` = 256L, `323` = 323L,
`351` = 351L, `393` = 393L, `423` = 423L, `442` = 442L, `455` = 455L,
`490` = 490L, `510` = 510L, `551` = 551L, `576` = 576L, `605` = 605L,
`646` = 646L, `676` = 676L, `696` = 696L, `708` = 708L, `742` = 742L,
`762` = 762L, `793` = 793L, `829` = 829L, `858` = 858L, `904` = 904L,
`929` = 929L, `950` = 950L, `961` = 961L, `996` = 996L, `1016` = 1016L,
`1089` = 1089L, `1114` = 1114L, `1159` = 1159L, `1184` = 1184L,
`1207` = 1207L, `1216` = 1216L, `1238` = 1238L, `1243` = 1243L,
`1253` = 1253L, `1278` = 1278L, `1315` = 1315L, `1346` = 1346L,
`1372` = 1372L, `1416` = 1416L, `1441` = 1441L, `1473` = 1473L,
`1532` = 1532L, `1599` = 1599L, `1626` = 1626L, `1669` = 1669L,
`1694` = 1694L, `1718` = 1718L, `1726` = 1726L, `1766` = 1766L,
`1786` = 1786L, `1827` = 1827L, `1853` = 1853L, `1881` = 1881L,
`1922` = 1922L, `1952` = 1952L, `1971` = 1971L, `1984` = 1984L,
`2019` = 2019L, `2039` = 2039L, `2075` = 2075L, `2106` = 2106L,
`2135` = 2135L, `2181` = 2181L, `2206` = 2206L, `2227` = 2227L,
`2238` = 2238L, `2273` = 2273L, `2293` = 2293L, `2325` = 2325L,
`2366` = 2366L, `2391` = 2391L, `2436` = 2436L, `2461` = 2461L,
`2483` = 2483L, `2493` = 2493L), class = "omit"), row.names = c(1L,
2L, 3L, 4L, 5L, 7L), class = "data.frame")
I have built 9 regression models per forecast horizon (t+1, t+5 and t+22) and I am using the predict function to make my forecasts. I have coded this in an R loop, where I also try to assign each forecast to a matrix. My code is the following:
EUR/GBP_RGV_5`+data.estimateI am trying to calculate realized volatility forecasts using a rolling window forecast. My aim is to use the first 500 observations to forecast the 501st observations, then shift the window forward one step using observations 2 to 501 to predict the 502nd observation. I want this to repeat until I have a complete pseudo out-of-sample forecast.
My df contains 2411 observations of 23 variables, here is small example:
Date
EUR/GBP_RV t+1
EUR/GBP_RV
EUR/GBP_RV_5
EUR/GBP_RV_22
2012-02-13
0.004019947
0.004467109
0.004995980
0.005150602
2012-02-14
0.004077322
0.004019947
0.004704742
0.005099209
2012-02-15
0.004666244
0.004077322
0.004564522
0.005020790
2012-02-16
0.004582351
0.004666244
0.004532930
0.005011078
2012-02-17
0.003951071
0.004582351
0.004362595
0.004999634
2012-02-21
0.005549329
0.004824547
0.004467109
0.004954358
The head of the df can be reproduced with
structure(list(Date = structure(c(15383, 15384, 15385, 15386,
15387, 15391), class = "Date"), `EUR/GBP_RV t+1,t+22` = c(0.00437808494654599,
0.00439764887779732, 0.00441997330738947, 0.00437799055732722,
0.00435021150904479, 0.00434881306458859), `EUR/GBP_RGV t+1,t+22` = c(0.00310674728131117,
0.00311502965608506, 0.00313756204195853, 0.00312923997431178,
0.00310846773074243, 0.00309755540903969), `EUR/GBP_RBV t+1,t+22` = c(0.00304961980133602,
0.00306866297401415, 0.00307794319983677, 0.00302801249035602,
0.00300946121851254, 0.00302272755554915), `EUR/GBP_RV t+1,t+5` = c(0.00425938711995146,
0.00442030721926592, 0.00471470868108043, 0.00487869292442023,
0.00476849421943949, 0.0046067439660438), `EUR/GBP_RGV t+1,t+5` = c(0.00287718093809447,
0.00311308998902836, 0.00344398536439729, 0.00376911066284235,
0.00377425759242542, 0.00353909902900148), `EUR/GBP_RBV t+1,t+5` = c(0.00313771439501486,
0.00310626895475871, 0.0031789431316576, 0.00305962424370556,
0.00288671182187571, 0.00291630955829613), `EUR/GBP_RV t+1` = c(0.00401994700051122,
0.00407732180013827, 0.00466624428620966, 0.00458235106134663,
0.00395107145155152, 0.00554932910921084), `EUR/GBP_RGV t+1` = c(0.00280067842079775,
0.00275522601341373, 0.00296142025653418, 0.00320716195737542,
0.00266141804235125, 0.00440970289025837), `EUR/GBP_RBV t+1` = c(0.00288377777753365,
0.00300554199386584, 0.00360608177982326, 0.00327292734850446,
0.0029202430753471, 0.00336891287836027), `EUR/GBP_RV` = c(0.00446710941914797,
0.00401994700051122, 0.00407732180013827, 0.00466624428620966,
0.00458235106134663, 0.00482454749708351), `EUR/GBP_RV_5` = c(0.00499598016427624,
0.00470474196716823, 0.00456452150727461, 0.00453292965488229,
0.00436259471347075, 0.00442030721926592), `EUR/GBP_RV_22` = c(0.00515060219897263,
0.00509920878086075, 0.00502079002092667, 0.00501107755050095,
0.00499963428727425, 0.00495435807685843), `EUR/GBP_RBV` = c(0.00324667045338159,
0.00288377777753365, 0.00300554199386584, 0.00360608177982326,
0.00327292734850446, 0.00272655057625291), `EUR/GBP_RBV_5` = c(0.0034985439252634,
0.00318731350301598, 0.00319529774619179, 0.0032799330165155,
0.00320299987062176, 0.00310626895475871), `EUR/GBP_RBV_22` = c(0.0036581887941976,
0.00362298829344015, 0.00355498498935768, 0.0035465419934449,
0.00355752455210586, 0.00351669973034298), `EUR/GBP_RGV` = c(0.00306825643155514,
0.00280067842079775, 0.00275522601341373, 0.00296142025653418,
0.00320716195737542, 0.00398022367546721), `EUR/GBP_RGV_5` = c(0.00353290218424469,
0.00345194162523714, 0.00325362896209417, 0.00312087362386985,
0.00295854861593525, 0.00311308998902836), `EUR/GBP_RGV_22` = c(0.00359974659692405,
0.00356342531619103, 0.00352224165959556, 0.00351722666683608,
0.00349184335907274, 0.00346394410318992), `EUR/GBP_TotalCount` = structure(c(-0.179518680545716,
-0.0757259172924681, 0.333514120677483, 0.759064450015801, -0.419724789788948,
-0.360414639358521), .Dim = c(6L, 1L)), `EUR/GBP_BloombergCount` = structure(c(-0.701694550941621,
-0.669811381311996, -0.574161872423118, -0.644304845608295, -0.784590791978649,
-0.631551577756444), .Dim = c(6L, 1L)), `EUR/GBP_SocialMediaCount` = structure(c(-1.68861759789696,
-1.66829994393287, -1.5910928588693, -1.59515638966212, -1.6967446594826,
-1.63172816679749), .Dim = c(6L, 1L)), `EUR/GBP_NewsCount` = structure(c(0.76560533722738,
0.879161625683434, 1.33717198912285, 1.90306082659552, 0.487392430510049,
0.487392430510049), .Dim = c(6L, 1L))), na.action = structure(c(`6` = 6L,
`38` = 38L, `74` = 74L, `101` = 101L, `140` = 140L, `165` = 165L,
`189` = 189L, `197` = 197L, `236` = 236L, `256` = 256L, `323` = 323L,
`351` = 351L, `393` = 393L, `423` = 423L, `442` = 442L, `455` = 455L,
`490` = 490L, `510` = 510L, `551` = 551L, `576` = 576L, `605` = 605L,
`646` = 646L, `676` = 676L, `696` = 696L, `708` = 708L, `742` = 742L,
`762` = 762L, `793` = 793L, `829` = 829L, `858` = 858L, `904` = 904L,
`929` = 929L, `950` = 950L, `961` = 961L, `996` = 996L, `1016` = 1016L,
`1089` = 1089L, `1114` = 1114L, `1159` = 1159L, `1184` = 1184L,
`1207` = 1207L, `1216` = 1216L, `1238` = 1238L, `1243` = 1243L,
`1253` = 1253L, `1278` = 1278L, `1315` = 1315L, `1346` = 1346L,
`1372` = 1372L, `1416` = 1416L, `1441` = 1441L, `1473` = 1473L,
`1532` = 1532L, `1599` = 1599L, `1626` = 1626L, `1669` = 1669L,
`1694` = 1694L, `1718` = 1718L, `1726` = 1726L, `1766` = 1766L,
`1786` = 1786L, `1827` = 1827L, `1853` = 1853L, `1881` = 1881L,
`1922` = 1922L, `1952` = 1952L, `1971` = 1971L, `1984` = 1984L,
`2019` = 2019L, `2039` = 2039L, `2075` = 2075L, `2106` = 2106L,
`2135` = 2135L, `2181` = 2181L, `2206` = 2206L, `2227` = 2227L,
`2238` = 2238L, `2273` = 2273L, `2293` = 2293L, `2325` = 2325L,
`2366` = 2366L, `2391` = 2391L, `2436` = 2436L, `2461` = 2461L,
`2483` = 2483L, `2493` = 2493L), class = "omit"), row.names = c(1L,
2L, 3L, 4L, 5L, 7L), class = "data.frame")
I have built 9 regression models per forecast horizon (t+1, t+5 and t+22) and I am using the predict function to make my forecasts. I have coded this in an R loop, where I also try to assign each forecast to a matrix. My code is the following:
EUR/GBP_RGV_22`)
EURGBP_HAR_RVGt22_NT_train <- lm(data.estimateI am trying to calculate realized volatility forecasts using a rolling window forecast. My aim is to use the first 500 observations to forecast the 501st observations, then shift the window forward one step using observations 2 to 501 to predict the 502nd observation. I want this to repeat until I have a complete pseudo out-of-sample forecast.
My df contains 2411 observations of 23 variables, here is small example:
Date
EUR/GBP_RV t+1
EUR/GBP_RV
EUR/GBP_RV_5
EUR/GBP_RV_22
2012-02-13
0.004019947
0.004467109
0.004995980
0.005150602
2012-02-14
0.004077322
0.004019947
0.004704742
0.005099209
2012-02-15
0.004666244
0.004077322
0.004564522
0.005020790
2012-02-16
0.004582351
0.004666244
0.004532930
0.005011078
2012-02-17
0.003951071
0.004582351
0.004362595
0.004999634
2012-02-21
0.005549329
0.004824547
0.004467109
0.004954358
The head of the df can be reproduced with
structure(list(Date = structure(c(15383, 15384, 15385, 15386,
15387, 15391), class = "Date"), `EUR/GBP_RV t+1,t+22` = c(0.00437808494654599,
0.00439764887779732, 0.00441997330738947, 0.00437799055732722,
0.00435021150904479, 0.00434881306458859), `EUR/GBP_RGV t+1,t+22` = c(0.00310674728131117,
0.00311502965608506, 0.00313756204195853, 0.00312923997431178,
0.00310846773074243, 0.00309755540903969), `EUR/GBP_RBV t+1,t+22` = c(0.00304961980133602,
0.00306866297401415, 0.00307794319983677, 0.00302801249035602,
0.00300946121851254, 0.00302272755554915), `EUR/GBP_RV t+1,t+5` = c(0.00425938711995146,
0.00442030721926592, 0.00471470868108043, 0.00487869292442023,
0.00476849421943949, 0.0046067439660438), `EUR/GBP_RGV t+1,t+5` = c(0.00287718093809447,
0.00311308998902836, 0.00344398536439729, 0.00376911066284235,
0.00377425759242542, 0.00353909902900148), `EUR/GBP_RBV t+1,t+5` = c(0.00313771439501486,
0.00310626895475871, 0.0031789431316576, 0.00305962424370556,
0.00288671182187571, 0.00291630955829613), `EUR/GBP_RV t+1` = c(0.00401994700051122,
0.00407732180013827, 0.00466624428620966, 0.00458235106134663,
0.00395107145155152, 0.00554932910921084), `EUR/GBP_RGV t+1` = c(0.00280067842079775,
0.00275522601341373, 0.00296142025653418, 0.00320716195737542,
0.00266141804235125, 0.00440970289025837), `EUR/GBP_RBV t+1` = c(0.00288377777753365,
0.00300554199386584, 0.00360608177982326, 0.00327292734850446,
0.0029202430753471, 0.00336891287836027), `EUR/GBP_RV` = c(0.00446710941914797,
0.00401994700051122, 0.00407732180013827, 0.00466624428620966,
0.00458235106134663, 0.00482454749708351), `EUR/GBP_RV_5` = c(0.00499598016427624,
0.00470474196716823, 0.00456452150727461, 0.00453292965488229,
0.00436259471347075, 0.00442030721926592), `EUR/GBP_RV_22` = c(0.00515060219897263,
0.00509920878086075, 0.00502079002092667, 0.00501107755050095,
0.00499963428727425, 0.00495435807685843), `EUR/GBP_RBV` = c(0.00324667045338159,
0.00288377777753365, 0.00300554199386584, 0.00360608177982326,
0.00327292734850446, 0.00272655057625291), `EUR/GBP_RBV_5` = c(0.0034985439252634,
0.00318731350301598, 0.00319529774619179, 0.0032799330165155,
0.00320299987062176, 0.00310626895475871), `EUR/GBP_RBV_22` = c(0.0036581887941976,
0.00362298829344015, 0.00355498498935768, 0.0035465419934449,
0.00355752455210586, 0.00351669973034298), `EUR/GBP_RGV` = c(0.00306825643155514,
0.00280067842079775, 0.00275522601341373, 0.00296142025653418,
0.00320716195737542, 0.00398022367546721), `EUR/GBP_RGV_5` = c(0.00353290218424469,
0.00345194162523714, 0.00325362896209417, 0.00312087362386985,
0.00295854861593525, 0.00311308998902836), `EUR/GBP_RGV_22` = c(0.00359974659692405,
0.00356342531619103, 0.00352224165959556, 0.00351722666683608,
0.00349184335907274, 0.00346394410318992), `EUR/GBP_TotalCount` = structure(c(-0.179518680545716,
-0.0757259172924681, 0.333514120677483, 0.759064450015801, -0.419724789788948,
-0.360414639358521), .Dim = c(6L, 1L)), `EUR/GBP_BloombergCount` = structure(c(-0.701694550941621,
-0.669811381311996, -0.574161872423118, -0.644304845608295, -0.784590791978649,
-0.631551577756444), .Dim = c(6L, 1L)), `EUR/GBP_SocialMediaCount` = structure(c(-1.68861759789696,
-1.66829994393287, -1.5910928588693, -1.59515638966212, -1.6967446594826,
-1.63172816679749), .Dim = c(6L, 1L)), `EUR/GBP_NewsCount` = structure(c(0.76560533722738,
0.879161625683434, 1.33717198912285, 1.90306082659552, 0.487392430510049,
0.487392430510049), .Dim = c(6L, 1L))), na.action = structure(c(`6` = 6L,
`38` = 38L, `74` = 74L, `101` = 101L, `140` = 140L, `165` = 165L,
`189` = 189L, `197` = 197L, `236` = 236L, `256` = 256L, `323` = 323L,
`351` = 351L, `393` = 393L, `423` = 423L, `442` = 442L, `455` = 455L,
`490` = 490L, `510` = 510L, `551` = 551L, `576` = 576L, `605` = 605L,
`646` = 646L, `676` = 676L, `696` = 696L, `708` = 708L, `742` = 742L,
`762` = 762L, `793` = 793L, `829` = 829L, `858` = 858L, `904` = 904L,
`929` = 929L, `950` = 950L, `961` = 961L, `996` = 996L, `1016` = 1016L,
`1089` = 1089L, `1114` = 1114L, `1159` = 1159L, `1184` = 1184L,
`1207` = 1207L, `1216` = 1216L, `1238` = 1238L, `1243` = 1243L,
`1253` = 1253L, `1278` = 1278L, `1315` = 1315L, `1346` = 1346L,
`1372` = 1372L, `1416` = 1416L, `1441` = 1441L, `1473` = 1473L,
`1532` = 1532L, `1599` = 1599L, `1626` = 1626L, `1669` = 1669L,
`1694` = 1694L, `1718` = 1718L, `1726` = 1726L, `1766` = 1766L,
`1786` = 1786L, `1827` = 1827L, `1853` = 1853L, `1881` = 1881L,
`1922` = 1922L, `1952` = 1952L, `1971` = 1971L, `1984` = 1984L,
`2019` = 2019L, `2039` = 2039L, `2075` = 2075L, `2106` = 2106L,
`2135` = 2135L, `2181` = 2181L, `2206` = 2206L, `2227` = 2227L,
`2238` = 2238L, `2273` = 2273L, `2293` = 2293L, `2325` = 2325L,
`2366` = 2366L, `2391` = 2391L, `2436` = 2436L, `2461` = 2461L,
`2483` = 2483L, `2493` = 2493L), class = "omit"), row.names = c(1L,
2L, 3L, 4L, 5L, 7L), class = "data.frame")
I have built 9 regression models per forecast horizon (t+1, t+5 and t+22) and I am using the predict function to make my forecasts. I have coded this in an R loop, where I also try to assign each forecast to a matrix. My code is the following:
EUR/GBP_RGV t+1,t+22`~data.estimateI am trying to calculate realized volatility forecasts using a rolling window forecast. My aim is to use the first 500 observations to forecast the 501st observations, then shift the window forward one step using observations 2 to 501 to predict the 502nd observation. I want this to repeat until I have a complete pseudo out-of-sample forecast.
My df contains 2411 observations of 23 variables, here is small example:
Date
EUR/GBP_RV t+1
EUR/GBP_RV
EUR/GBP_RV_5
EUR/GBP_RV_22
2012-02-13
0.004019947
0.004467109
0.004995980
0.005150602
2012-02-14
0.004077322
0.004019947
0.004704742
0.005099209
2012-02-15
0.004666244
0.004077322
0.004564522
0.005020790
2012-02-16
0.004582351
0.004666244
0.004532930
0.005011078
2012-02-17
0.003951071
0.004582351
0.004362595
0.004999634
2012-02-21
0.005549329
0.004824547
0.004467109
0.004954358
The head of the df can be reproduced with
structure(list(Date = structure(c(15383, 15384, 15385, 15386,
15387, 15391), class = "Date"), `EUR/GBP_RV t+1,t+22` = c(0.00437808494654599,
0.00439764887779732, 0.00441997330738947, 0.00437799055732722,
0.00435021150904479, 0.00434881306458859), `EUR/GBP_RGV t+1,t+22` = c(0.00310674728131117,
0.00311502965608506, 0.00313756204195853, 0.00312923997431178,
0.00310846773074243, 0.00309755540903969), `EUR/GBP_RBV t+1,t+22` = c(0.00304961980133602,
0.00306866297401415, 0.00307794319983677, 0.00302801249035602,
0.00300946121851254, 0.00302272755554915), `EUR/GBP_RV t+1,t+5` = c(0.00425938711995146,
0.00442030721926592, 0.00471470868108043, 0.00487869292442023,
0.00476849421943949, 0.0046067439660438), `EUR/GBP_RGV t+1,t+5` = c(0.00287718093809447,
0.00311308998902836, 0.00344398536439729, 0.00376911066284235,
0.00377425759242542, 0.00353909902900148), `EUR/GBP_RBV t+1,t+5` = c(0.00313771439501486,
0.00310626895475871, 0.0031789431316576, 0.00305962424370556,
0.00288671182187571, 0.00291630955829613), `EUR/GBP_RV t+1` = c(0.00401994700051122,
0.00407732180013827, 0.00466624428620966, 0.00458235106134663,
0.00395107145155152, 0.00554932910921084), `EUR/GBP_RGV t+1` = c(0.00280067842079775,
0.00275522601341373, 0.00296142025653418, 0.00320716195737542,
0.00266141804235125, 0.00440970289025837), `EUR/GBP_RBV t+1` = c(0.00288377777753365,
0.00300554199386584, 0.00360608177982326, 0.00327292734850446,
0.0029202430753471, 0.00336891287836027), `EUR/GBP_RV` = c(0.00446710941914797,
0.00401994700051122, 0.00407732180013827, 0.00466624428620966,
0.00458235106134663, 0.00482454749708351), `EUR/GBP_RV_5` = c(0.00499598016427624,
0.00470474196716823, 0.00456452150727461, 0.00453292965488229,
0.00436259471347075, 0.00442030721926592), `EUR/GBP_RV_22` = c(0.00515060219897263,
0.00509920878086075, 0.00502079002092667, 0.00501107755050095,
0.00499963428727425, 0.00495435807685843), `EUR/GBP_RBV` = c(0.00324667045338159,
0.00288377777753365, 0.00300554199386584, 0.00360608177982326,
0.00327292734850446, 0.00272655057625291), `EUR/GBP_RBV_5` = c(0.0034985439252634,
0.00318731350301598, 0.00319529774619179, 0.0032799330165155,
0.00320299987062176, 0.00310626895475871), `EUR/GBP_RBV_22` = c(0.0036581887941976,
0.00362298829344015, 0.00355498498935768, 0.0035465419934449,
0.00355752455210586, 0.00351669973034298), `EUR/GBP_RGV` = c(0.00306825643155514,
0.00280067842079775, 0.00275522601341373, 0.00296142025653418,
0.00320716195737542, 0.00398022367546721), `EUR/GBP_RGV_5` = c(0.00353290218424469,
0.00345194162523714, 0.00325362896209417, 0.00312087362386985,
0.00295854861593525, 0.00311308998902836), `EUR/GBP_RGV_22` = c(0.00359974659692405,
0.00356342531619103, 0.00352224165959556, 0.00351722666683608,
0.00349184335907274, 0.00346394410318992), `EUR/GBP_TotalCount` = structure(c(-0.179518680545716,
-0.0757259172924681, 0.333514120677483, 0.759064450015801, -0.419724789788948,
-0.360414639358521), .Dim = c(6L, 1L)), `EUR/GBP_BloombergCount` = structure(c(-0.701694550941621,
-0.669811381311996, -0.574161872423118, -0.644304845608295, -0.784590791978649,
-0.631551577756444), .Dim = c(6L, 1L)), `EUR/GBP_SocialMediaCount` = structure(c(-1.68861759789696,
-1.66829994393287, -1.5910928588693, -1.59515638966212, -1.6967446594826,
-1.63172816679749), .Dim = c(6L, 1L)), `EUR/GBP_NewsCount` = structure(c(0.76560533722738,
0.879161625683434, 1.33717198912285, 1.90306082659552, 0.487392430510049,
0.487392430510049), .Dim = c(6L, 1L))), na.action = structure(c(`6` = 6L,
`38` = 38L, `74` = 74L, `101` = 101L, `140` = 140L, `165` = 165L,
`189` = 189L, `197` = 197L, `236` = 236L, `256` = 256L, `323` = 323L,
`351` = 351L, `393` = 393L, `423` = 423L, `442` = 442L, `455` = 455L,
`490` = 490L, `510` = 510L, `551` = 551L, `576` = 576L, `605` = 605L,
`646` = 646L, `676` = 676L, `696` = 696L, `708` = 708L, `742` = 742L,
`762` = 762L, `793` = 793L, `829` = 829L, `858` = 858L, `904` = 904L,
`929` = 929L, `950` = 950L, `961` = 961L, `996` = 996L, `1016` = 1016L,
`1089` = 1089L, `1114` = 1114L, `1159` = 1159L, `1184` = 1184L,
`1207` = 1207L, `1216` = 1216L, `1238` = 1238L, `1243` = 1243L,
`1253` = 1253L, `1278` = 1278L, `1315` = 1315L, `1346` = 1346L,
`1372` = 1372L, `1416` = 1416L, `1441` = 1441L, `1473` = 1473L,
`1532` = 1532L, `1599` = 1599L, `1626` = 1626L, `1669` = 1669L,
`1694` = 1694L, `1718` = 1718L, `1726` = 1726L, `1766` = 1766L,
`1786` = 1786L, `1827` = 1827L, `1853` = 1853L, `1881` = 1881L,
`1922` = 1922L, `1952` = 1952L, `1971` = 1971L, `1984` = 1984L,
`2019` = 2019L, `2039` = 2039L, `2075` = 2075L, `2106` = 2106L,
`2135` = 2135L, `2181` = 2181L, `2206` = 2206L, `2227` = 2227L,
`2238` = 2238L, `2273` = 2273L, `2293` = 2293L, `2325` = 2325L,
`2366` = 2366L, `2391` = 2391L, `2436` = 2436L, `2461` = 2461L,
`2483` = 2483L, `2493` = 2493L), class = "omit"), row.names = c(1L,
2L, 3L, 4L, 5L, 7L), class = "data.frame")
I have built 9 regression models per forecast horizon (t+1, t+5 and t+22) and I am using the predict function to make my forecasts. I have coded this in an R loop, where I also try to assign each forecast to a matrix. My code is the following:
EUR/GBP_RGV`+data.estimateI am trying to calculate realized volatility forecasts using a rolling window forecast. My aim is to use the first 500 observations to forecast the 501st observations, then shift the window forward one step using observations 2 to 501 to predict the 502nd observation. I want this to repeat until I have a complete pseudo out-of-sample forecast.
My df contains 2411 observations of 23 variables, here is small example:
Date
EUR/GBP_RV t+1
EUR/GBP_RV
EUR/GBP_RV_5
EUR/GBP_RV_22
2012-02-13
0.004019947
0.004467109
0.004995980
0.005150602
2012-02-14
0.004077322
0.004019947
0.004704742
0.005099209
2012-02-15
0.004666244
0.004077322
0.004564522
0.005020790
2012-02-16
0.004582351
0.004666244
0.004532930
0.005011078
2012-02-17
0.003951071
0.004582351
0.004362595
0.004999634
2012-02-21
0.005549329
0.004824547
0.004467109
0.004954358
The head of the df can be reproduced with
structure(list(Date = structure(c(15383, 15384, 15385, 15386,
15387, 15391), class = "Date"), `EUR/GBP_RV t+1,t+22` = c(0.00437808494654599,
0.00439764887779732, 0.00441997330738947, 0.00437799055732722,
0.00435021150904479, 0.00434881306458859), `EUR/GBP_RGV t+1,t+22` = c(0.00310674728131117,
0.00311502965608506, 0.00313756204195853, 0.00312923997431178,
0.00310846773074243, 0.00309755540903969), `EUR/GBP_RBV t+1,t+22` = c(0.00304961980133602,
0.00306866297401415, 0.00307794319983677, 0.00302801249035602,
0.00300946121851254, 0.00302272755554915), `EUR/GBP_RV t+1,t+5` = c(0.00425938711995146,
0.00442030721926592, 0.00471470868108043, 0.00487869292442023,
0.00476849421943949, 0.0046067439660438), `EUR/GBP_RGV t+1,t+5` = c(0.00287718093809447,
0.00311308998902836, 0.00344398536439729, 0.00376911066284235,
0.00377425759242542, 0.00353909902900148), `EUR/GBP_RBV t+1,t+5` = c(0.00313771439501486,
0.00310626895475871, 0.0031789431316576, 0.00305962424370556,
0.00288671182187571, 0.00291630955829613), `EUR/GBP_RV t+1` = c(0.00401994700051122,
0.00407732180013827, 0.00466624428620966, 0.00458235106134663,
0.00395107145155152, 0.00554932910921084), `EUR/GBP_RGV t+1` = c(0.00280067842079775,
0.00275522601341373, 0.00296142025653418, 0.00320716195737542,
0.00266141804235125, 0.00440970289025837), `EUR/GBP_RBV t+1` = c(0.00288377777753365,
0.00300554199386584, 0.00360608177982326, 0.00327292734850446,
0.0029202430753471, 0.00336891287836027), `EUR/GBP_RV` = c(0.00446710941914797,
0.00401994700051122, 0.00407732180013827, 0.00466624428620966,
0.00458235106134663, 0.00482454749708351), `EUR/GBP_RV_5` = c(0.00499598016427624,
0.00470474196716823, 0.00456452150727461, 0.00453292965488229,
0.00436259471347075, 0.00442030721926592), `EUR/GBP_RV_22` = c(0.00515060219897263,
0.00509920878086075, 0.00502079002092667, 0.00501107755050095,
0.00499963428727425, 0.00495435807685843), `EUR/GBP_RBV` = c(0.00324667045338159,
0.00288377777753365, 0.00300554199386584, 0.00360608177982326,
0.00327292734850446, 0.00272655057625291), `EUR/GBP_RBV_5` = c(0.0034985439252634,
0.00318731350301598, 0.00319529774619179, 0.0032799330165155,
0.00320299987062176, 0.00310626895475871), `EUR/GBP_RBV_22` = c(0.0036581887941976,
0.00362298829344015, 0.00355498498935768, 0.0035465419934449,
0.00355752455210586, 0.00351669973034298), `EUR/GBP_RGV` = c(0.00306825643155514,
0.00280067842079775, 0.00275522601341373, 0.00296142025653418,
0.00320716195737542, 0.00398022367546721), `EUR/GBP_RGV_5` = c(0.00353290218424469,
0.00345194162523714, 0.00325362896209417, 0.00312087362386985,
0.00295854861593525, 0.00311308998902836), `EUR/GBP_RGV_22` = c(0.00359974659692405,
0.00356342531619103, 0.00352224165959556, 0.00351722666683608,
0.00349184335907274, 0.00346394410318992), `EUR/GBP_TotalCount` = structure(c(-0.179518680545716,
-0.0757259172924681, 0.333514120677483, 0.759064450015801, -0.419724789788948,
-0.360414639358521), .Dim = c(6L, 1L)), `EUR/GBP_BloombergCount` = structure(c(-0.701694550941621,
-0.669811381311996, -0.574161872423118, -0.644304845608295, -0.784590791978649,
-0.631551577756444), .Dim = c(6L, 1L)), `EUR/GBP_SocialMediaCount` = structure(c(-1.68861759789696,
-1.66829994393287, -1.5910928588693, -1.59515638966212, -1.6967446594826,
-1.63172816679749), .Dim = c(6L, 1L)), `EUR/GBP_NewsCount` = structure(c(0.76560533722738,
0.879161625683434, 1.33717198912285, 1.90306082659552, 0.487392430510049,
0.487392430510049), .Dim = c(6L, 1L))), na.action = structure(c(`6` = 6L,
`38` = 38L, `74` = 74L, `101` = 101L, `140` = 140L, `165` = 165L,
`189` = 189L, `197` = 197L, `236` = 236L, `256` = 256L, `323` = 323L,
`351` = 351L, `393` = 393L, `423` = 423L, `442` = 442L, `455` = 455L,
`490` = 490L, `510` = 510L, `551` = 551L, `576` = 576L, `605` = 605L,
`646` = 646L, `676` = 676L, `696` = 696L, `708` = 708L, `742` = 742L,
`762` = 762L, `793` = 793L, `829` = 829L, `858` = 858L, `904` = 904L,
`929` = 929L, `950` = 950L, `961` = 961L, `996` = 996L, `1016` = 1016L,
`1089` = 1089L, `1114` = 1114L, `1159` = 1159L, `1184` = 1184L,
`1207` = 1207L, `1216` = 1216L, `1238` = 1238L, `1243` = 1243L,
`1253` = 1253L, `1278` = 1278L, `1315` = 1315L, `1346` = 1346L,
`1372` = 1372L, `1416` = 1416L, `1441` = 1441L, `1473` = 1473L,
`1532` = 1532L, `1599` = 1599L, `1626` = 1626L, `1669` = 1669L,
`1694` = 1694L, `1718` = 1718L, `1726` = 1726L, `1766` = 1766L,
`1786` = 1786L, `1827` = 1827L, `1853` = 1853L, `1881` = 1881L,
`1922` = 1922L, `1952` = 1952L, `1971` = 1971L, `1984` = 1984L,
`2019` = 2019L, `2039` = 2039L, `2075` = 2075L, `2106` = 2106L,
`2135` = 2135L, `2181` = 2181L, `2206` = 2206L, `2227` = 2227L,
`2238` = 2238L, `2273` = 2273L, `2293` = 2293L, `2325` = 2325L,
`2366` = 2366L, `2391` = 2391L, `2436` = 2436L, `2461` = 2461L,
`2483` = 2483L, `2493` = 2493L), class = "omit"), row.names = c(1L,
2L, 3L, 4L, 5L, 7L), class = "data.frame")
I have built 9 regression models per forecast horizon (t+1, t+5 and t+22) and I am using the predict function to make my forecasts. I have coded this in an R loop, where I also try to assign each forecast to a matrix. My code is the following:
EUR/GBP_RGV_5`+data.estimateI am trying to calculate realized volatility forecasts using a rolling window forecast. My aim is to use the first 500 observations to forecast the 501st observations, then shift the window forward one step using observations 2 to 501 to predict the 502nd observation. I want this to repeat until I have a complete pseudo out-of-sample forecast.
My df contains 2411 observations of 23 variables, here is small example:
Date
EUR/GBP_RV t+1
EUR/GBP_RV
EUR/GBP_RV_5
EUR/GBP_RV_22
2012-02-13
0.004019947
0.004467109
0.004995980
0.005150602
2012-02-14
0.004077322
0.004019947
0.004704742
0.005099209
2012-02-15
0.004666244
0.004077322
0.004564522
0.005020790
2012-02-16
0.004582351
0.004666244
0.004532930
0.005011078
2012-02-17
0.003951071
0.004582351
0.004362595
0.004999634
2012-02-21
0.005549329
0.004824547
0.004467109
0.004954358
The head of the df can be reproduced with
structure(list(Date = structure(c(15383, 15384, 15385, 15386,
15387, 15391), class = "Date"), `EUR/GBP_RV t+1,t+22` = c(0.00437808494654599,
0.00439764887779732, 0.00441997330738947, 0.00437799055732722,
0.00435021150904479, 0.00434881306458859), `EUR/GBP_RGV t+1,t+22` = c(0.00310674728131117,
0.00311502965608506, 0.00313756204195853, 0.00312923997431178,
0.00310846773074243, 0.00309755540903969), `EUR/GBP_RBV t+1,t+22` = c(0.00304961980133602,
0.00306866297401415, 0.00307794319983677, 0.00302801249035602,
0.00300946121851254, 0.00302272755554915), `EUR/GBP_RV t+1,t+5` = c(0.00425938711995146,
0.00442030721926592, 0.00471470868108043, 0.00487869292442023,
0.00476849421943949, 0.0046067439660438), `EUR/GBP_RGV t+1,t+5` = c(0.00287718093809447,
0.00311308998902836, 0.00344398536439729, 0.00376911066284235,
0.00377425759242542, 0.00353909902900148), `EUR/GBP_RBV t+1,t+5` = c(0.00313771439501486,
0.00310626895475871, 0.0031789431316576, 0.00305962424370556,
0.00288671182187571, 0.00291630955829613), `EUR/GBP_RV t+1` = c(0.00401994700051122,
0.00407732180013827, 0.00466624428620966, 0.00458235106134663,
0.00395107145155152, 0.00554932910921084), `EUR/GBP_RGV t+1` = c(0.00280067842079775,
0.00275522601341373, 0.00296142025653418, 0.00320716195737542,
0.00266141804235125, 0.00440970289025837), `EUR/GBP_RBV t+1` = c(0.00288377777753365,
0.00300554199386584, 0.00360608177982326, 0.00327292734850446,
0.0029202430753471, 0.00336891287836027), `EUR/GBP_RV` = c(0.00446710941914797,
0.00401994700051122, 0.00407732180013827, 0.00466624428620966,
0.00458235106134663, 0.00482454749708351), `EUR/GBP_RV_5` = c(0.00499598016427624,
0.00470474196716823, 0.00456452150727461, 0.00453292965488229,
0.00436259471347075, 0.00442030721926592), `EUR/GBP_RV_22` = c(0.00515060219897263,
0.00509920878086075, 0.00502079002092667, 0.00501107755050095,
0.00499963428727425, 0.00495435807685843), `EUR/GBP_RBV` = c(0.00324667045338159,
0.00288377777753365, 0.00300554199386584, 0.00360608177982326,
0.00327292734850446, 0.00272655057625291), `EUR/GBP_RBV_5` = c(0.0034985439252634,
0.00318731350301598, 0.00319529774619179, 0.0032799330165155,
0.00320299987062176, 0.00310626895475871), `EUR/GBP_RBV_22` = c(0.0036581887941976,
0.00362298829344015, 0.00355498498935768, 0.0035465419934449,
0.00355752455210586, 0.00351669973034298), `EUR/GBP_RGV` = c(0.00306825643155514,
0.00280067842079775, 0.00275522601341373, 0.00296142025653418,
0.00320716195737542, 0.00398022367546721), `EUR/GBP_RGV_5` = c(0.00353290218424469,
0.00345194162523714, 0.00325362896209417, 0.00312087362386985,
0.00295854861593525, 0.00311308998902836), `EUR/GBP_RGV_22` = c(0.00359974659692405,
0.00356342531619103, 0.00352224165959556, 0.00351722666683608,
0.00349184335907274, 0.00346394410318992), `EUR/GBP_TotalCount` = structure(c(-0.179518680545716,
-0.0757259172924681, 0.333514120677483, 0.759064450015801, -0.419724789788948,
-0.360414639358521), .Dim = c(6L, 1L)), `EUR/GBP_BloombergCount` = structure(c(-0.701694550941621,
-0.669811381311996, -0.574161872423118, -0.644304845608295, -0.784590791978649,
-0.631551577756444), .Dim = c(6L, 1L)), `EUR/GBP_SocialMediaCount` = structure(c(-1.68861759789696,
-1.66829994393287, -1.5910928588693, -1.59515638966212, -1.6967446594826,
-1.63172816679749), .Dim = c(6L, 1L)), `EUR/GBP_NewsCount` = structure(c(0.76560533722738,
0.879161625683434, 1.33717198912285, 1.90306082659552, 0.487392430510049,
0.487392430510049), .Dim = c(6L, 1L))), na.action = structure(c(`6` = 6L,
`38` = 38L, `74` = 74L, `101` = 101L, `140` = 140L, `165` = 165L,
`189` = 189L, `197` = 197L, `236` = 236L, `256` = 256L, `323` = 323L,
`351` = 351L, `393` = 393L, `423` = 423L, `442` = 442L, `455` = 455L,
`490` = 490L, `510` = 510L, `551` = 551L, `576` = 576L, `605` = 605L,
`646` = 646L, `676` = 676L, `696` = 696L, `708` = 708L, `742` = 742L,
`762` = 762L, `793` = 793L, `829` = 829L, `858` = 858L, `904` = 904L,
`929` = 929L, `950` = 950L, `961` = 961L, `996` = 996L, `1016` = 1016L,
`1089` = 1089L, `1114` = 1114L, `1159` = 1159L, `1184` = 1184L,
`1207` = 1207L, `1216` = 1216L, `1238` = 1238L, `1243` = 1243L,
`1253` = 1253L, `1278` = 1278L, `1315` = 1315L, `1346` = 1346L,
`1372` = 1372L, `1416` = 1416L, `1441` = 1441L, `1473` = 1473L,
`1532` = 1532L, `1599` = 1599L, `1626` = 1626L, `1669` = 1669L,
`1694` = 1694L, `1718` = 1718L, `1726` = 1726L, `1766` = 1766L,
`1786` = 1786L, `1827` = 1827L, `1853` = 1853L, `1881` = 1881L,
`1922` = 1922L, `1952` = 1952L, `1971` = 1971L, `1984` = 1984L,
`2019` = 2019L, `2039` = 2039L, `2075` = 2075L, `2106` = 2106L,
`2135` = 2135L, `2181` = 2181L, `2206` = 2206L, `2227` = 2227L,
`2238` = 2238L, `2273` = 2273L, `2293` = 2293L, `2325` = 2325L,
`2366` = 2366L, `2391` = 2391L, `2436` = 2436L, `2461` = 2461L,
`2483` = 2483L, `2493` = 2493L), class = "omit"), row.names = c(1L,
2L, 3L, 4L, 5L, 7L), class = "data.frame")
I have built 9 regression models per forecast horizon (t+1, t+5 and t+22) and I am using the predict function to make my forecasts. I have coded this in an R loop, where I also try to assign each forecast to a matrix. My code is the following:
EUR/GBP_RGV_22`+data.estimateI am trying to calculate realized volatility forecasts using a rolling window forecast. My aim is to use the first 500 observations to forecast the 501st observations, then shift the window forward one step using observations 2 to 501 to predict the 502nd observation. I want this to repeat until I have a complete pseudo out-of-sample forecast.
My df contains 2411 observations of 23 variables, here is small example:
Date
EUR/GBP_RV t+1
EUR/GBP_RV
EUR/GBP_RV_5
EUR/GBP_RV_22
2012-02-13
0.004019947
0.004467109
0.004995980
0.005150602
2012-02-14
0.004077322
0.004019947
0.004704742
0.005099209
2012-02-15
0.004666244
0.004077322
0.004564522
0.005020790
2012-02-16
0.004582351
0.004666244
0.004532930
0.005011078
2012-02-17
0.003951071
0.004582351
0.004362595
0.004999634
2012-02-21
0.005549329
0.004824547
0.004467109
0.004954358
The head of the df can be reproduced with
structure(list(Date = structure(c(15383, 15384, 15385, 15386,
15387, 15391), class = "Date"), `EUR/GBP_RV t+1,t+22` = c(0.00437808494654599,
0.00439764887779732, 0.00441997330738947, 0.00437799055732722,
0.00435021150904479, 0.00434881306458859), `EUR/GBP_RGV t+1,t+22` = c(0.00310674728131117,
0.00311502965608506, 0.00313756204195853, 0.00312923997431178,
0.00310846773074243, 0.00309755540903969), `EUR/GBP_RBV t+1,t+22` = c(0.00304961980133602,
0.00306866297401415, 0.00307794319983677, 0.00302801249035602,
0.00300946121851254, 0.00302272755554915), `EUR/GBP_RV t+1,t+5` = c(0.00425938711995146,
0.00442030721926592, 0.00471470868108043, 0.00487869292442023,
0.00476849421943949, 0.0046067439660438), `EUR/GBP_RGV t+1,t+5` = c(0.00287718093809447,
0.00311308998902836, 0.00344398536439729, 0.00376911066284235,
0.00377425759242542, 0.00353909902900148), `EUR/GBP_RBV t+1,t+5` = c(0.00313771439501486,
0.00310626895475871, 0.0031789431316576, 0.00305962424370556,
0.00288671182187571, 0.00291630955829613), `EUR/GBP_RV t+1` = c(0.00401994700051122,
0.00407732180013827, 0.00466624428620966, 0.00458235106134663,
0.00395107145155152, 0.00554932910921084), `EUR/GBP_RGV t+1` = c(0.00280067842079775,
0.00275522601341373, 0.00296142025653418, 0.00320716195737542,
0.00266141804235125, 0.00440970289025837), `EUR/GBP_RBV t+1` = c(0.00288377777753365,
0.00300554199386584, 0.00360608177982326, 0.00327292734850446,
0.0029202430753471, 0.00336891287836027), `EUR/GBP_RV` = c(0.00446710941914797,
0.00401994700051122, 0.00407732180013827, 0.00466624428620966,
0.00458235106134663, 0.00482454749708351), `EUR/GBP_RV_5` = c(0.00499598016427624,
0.00470474196716823, 0.00456452150727461, 0.00453292965488229,
0.00436259471347075, 0.00442030721926592), `EUR/GBP_RV_22` = c(0.00515060219897263,
0.00509920878086075, 0.00502079002092667, 0.00501107755050095,
0.00499963428727425, 0.00495435807685843), `EUR/GBP_RBV` = c(0.00324667045338159,
0.00288377777753365, 0.00300554199386584, 0.00360608177982326,
0.00327292734850446, 0.00272655057625291), `EUR/GBP_RBV_5` = c(0.0034985439252634,
0.00318731350301598, 0.00319529774619179, 0.0032799330165155,
0.00320299987062176, 0.00310626895475871), `EUR/GBP_RBV_22` = c(0.0036581887941976,
0.00362298829344015, 0.00355498498935768, 0.0035465419934449,
0.00355752455210586, 0.00351669973034298), `EUR/GBP_RGV` = c(0.00306825643155514,
0.00280067842079775, 0.00275522601341373, 0.00296142025653418,
0.00320716195737542, 0.00398022367546721), `EUR/GBP_RGV_5` = c(0.00353290218424469,
0.00345194162523714, 0.00325362896209417, 0.00312087362386985,
0.00295854861593525, 0.00311308998902836), `EUR/GBP_RGV_22` = c(0.00359974659692405,
0.00356342531619103, 0.00352224165959556, 0.00351722666683608,
0.00349184335907274, 0.00346394410318992), `EUR/GBP_TotalCount` = structure(c(-0.179518680545716,
-0.0757259172924681, 0.333514120677483, 0.759064450015801, -0.419724789788948,
-0.360414639358521), .Dim = c(6L, 1L)), `EUR/GBP_BloombergCount` = structure(c(-0.701694550941621,
-0.669811381311996, -0.574161872423118, -0.644304845608295, -0.784590791978649,
-0.631551577756444), .Dim = c(6L, 1L)), `EUR/GBP_SocialMediaCount` = structure(c(-1.68861759789696,
-1.66829994393287, -1.5910928588693, -1.59515638966212, -1.6967446594826,
-1.63172816679749), .Dim = c(6L, 1L)), `EUR/GBP_NewsCount` = structure(c(0.76560533722738,
0.879161625683434, 1.33717198912285, 1.90306082659552, 0.487392430510049,
0.487392430510049), .Dim = c(6L, 1L))), na.action = structure(c(`6` = 6L,
`38` = 38L, `74` = 74L, `101` = 101L, `140` = 140L, `165` = 165L,
`189` = 189L, `197` = 197L, `236` = 236L, `256` = 256L, `323` = 323L,
`351` = 351L, `393` = 393L, `423` = 423L, `442` = 442L, `455` = 455L,
`490` = 490L, `510` = 510L, `551` = 551L, `576` = 576L, `605` = 605L,
`646` = 646L, `676` = 676L, `696` = 696L, `708` = 708L, `742` = 742L,
`762` = 762L, `793` = 793L, `829` = 829L, `858` = 858L, `904` = 904L,
`929` = 929L, `950` = 950L, `961` = 961L, `996` = 996L, `1016` = 1016L,
`1089` = 1089L, `1114` = 1114L, `1159` = 1159L, `1184` = 1184L,
`1207` = 1207L, `1216` = 1216L, `1238` = 1238L, `1243` = 1243L,
`1253` = 1253L, `1278` = 1278L, `1315` = 1315L, `1346` = 1346L,
`1372` = 1372L, `1416` = 1416L, `1441` = 1441L, `1473` = 1473L,
`1532` = 1532L, `1599` = 1599L, `1626` = 1626L, `1669` = 1669L,
`1694` = 1694L, `1718` = 1718L, `1726` = 1726L, `1766` = 1766L,
`1786` = 1786L, `1827` = 1827L, `1853` = 1853L, `1881` = 1881L,
`1922` = 1922L, `1952` = 1952L, `1971` = 1971L, `1984` = 1984L,
`2019` = 2019L, `2039` = 2039L, `2075` = 2075L, `2106` = 2106L,
`2135` = 2135L, `2181` = 2181L, `2206` = 2206L, `2227` = 2227L,
`2238` = 2238L, `2273` = 2273L, `2293` = 2293L, `2325` = 2325L,
`2366` = 2366L, `2391` = 2391L, `2436` = 2436L, `2461` = 2461L,
`2483` = 2483L, `2493` = 2493L), class = "omit"), row.names = c(1L,
2L, 3L, 4L, 5L, 7L), class = "data.frame")
I have built 9 regression models per forecast horizon (t+1, t+5 and t+22) and I am using the predict function to make my forecasts. I have coded this in an R loop, where I also try to assign each forecast to a matrix. My code is the following:
EUR/GBP_TotalCount`)
EURGBP_HAR_RVt22_Bloomberg_train <- lm(data.estimateI am trying to calculate realized volatility forecasts using a rolling window forecast. My aim is to use the first 500 observations to forecast the 501st observations, then shift the window forward one step using observations 2 to 501 to predict the 502nd observation. I want this to repeat until I have a complete pseudo out-of-sample forecast.
My df contains 2411 observations of 23 variables, here is small example:
Date
EUR/GBP_RV t+1
EUR/GBP_RV
EUR/GBP_RV_5
EUR/GBP_RV_22
2012-02-13
0.004019947
0.004467109
0.004995980
0.005150602
2012-02-14
0.004077322
0.004019947
0.004704742
0.005099209
2012-02-15
0.004666244
0.004077322
0.004564522
0.005020790
2012-02-16
0.004582351
0.004666244
0.004532930
0.005011078
2012-02-17
0.003951071
0.004582351
0.004362595
0.004999634
2012-02-21
0.005549329
0.004824547
0.004467109
0.004954358
The head of the df can be reproduced with
structure(list(Date = structure(c(15383, 15384, 15385, 15386,
15387, 15391), class = "Date"), `EUR/GBP_RV t+1,t+22` = c(0.00437808494654599,
0.00439764887779732, 0.00441997330738947, 0.00437799055732722,
0.00435021150904479, 0.00434881306458859), `EUR/GBP_RGV t+1,t+22` = c(0.00310674728131117,
0.00311502965608506, 0.00313756204195853, 0.00312923997431178,
0.00310846773074243, 0.00309755540903969), `EUR/GBP_RBV t+1,t+22` = c(0.00304961980133602,
0.00306866297401415, 0.00307794319983677, 0.00302801249035602,
0.00300946121851254, 0.00302272755554915), `EUR/GBP_RV t+1,t+5` = c(0.00425938711995146,
0.00442030721926592, 0.00471470868108043, 0.00487869292442023,
0.00476849421943949, 0.0046067439660438), `EUR/GBP_RGV t+1,t+5` = c(0.00287718093809447,
0.00311308998902836, 0.00344398536439729, 0.00376911066284235,
0.00377425759242542, 0.00353909902900148), `EUR/GBP_RBV t+1,t+5` = c(0.00313771439501486,
0.00310626895475871, 0.0031789431316576, 0.00305962424370556,
0.00288671182187571, 0.00291630955829613), `EUR/GBP_RV t+1` = c(0.00401994700051122,
0.00407732180013827, 0.00466624428620966, 0.00458235106134663,
0.00395107145155152, 0.00554932910921084), `EUR/GBP_RGV t+1` = c(0.00280067842079775,
0.00275522601341373, 0.00296142025653418, 0.00320716195737542,
0.00266141804235125, 0.00440970289025837), `EUR/GBP_RBV t+1` = c(0.00288377777753365,
0.00300554199386584, 0.00360608177982326, 0.00327292734850446,
0.0029202430753471, 0.00336891287836027), `EUR/GBP_RV` = c(0.00446710941914797,
0.00401994700051122, 0.00407732180013827, 0.00466624428620966,
0.00458235106134663, 0.00482454749708351), `EUR/GBP_RV_5` = c(0.00499598016427624,
0.00470474196716823, 0.00456452150727461, 0.00453292965488229,
0.00436259471347075, 0.00442030721926592), `EUR/GBP_RV_22` = c(0.00515060219897263,
0.00509920878086075, 0.00502079002092667, 0.00501107755050095,
0.00499963428727425, 0.00495435807685843), `EUR/GBP_RBV` = c(0.00324667045338159,
0.00288377777753365, 0.00300554199386584, 0.00360608177982326,
0.00327292734850446, 0.00272655057625291), `EUR/GBP_RBV_5` = c(0.0034985439252634,
0.00318731350301598, 0.00319529774619179, 0.0032799330165155,
0.00320299987062176, 0.00310626895475871), `EUR/GBP_RBV_22` = c(0.0036581887941976,
0.00362298829344015, 0.00355498498935768, 0.0035465419934449,
0.00355752455210586, 0.00351669973034298), `EUR/GBP_RGV` = c(0.00306825643155514,
0.00280067842079775, 0.00275522601341373, 0.00296142025653418,
0.00320716195737542, 0.00398022367546721), `EUR/GBP_RGV_5` = c(0.00353290218424469,
0.00345194162523714, 0.00325362896209417, 0.00312087362386985,
0.00295854861593525, 0.00311308998902836), `EUR/GBP_RGV_22` = c(0.00359974659692405,
0.00356342531619103, 0.00352224165959556, 0.00351722666683608,
0.00349184335907274, 0.00346394410318992), `EUR/GBP_TotalCount` = structure(c(-0.179518680545716,
-0.0757259172924681, 0.333514120677483, 0.759064450015801, -0.419724789788948,
-0.360414639358521), .Dim = c(6L, 1L)), `EUR/GBP_BloombergCount` = structure(c(-0.701694550941621,
-0.669811381311996, -0.574161872423118, -0.644304845608295, -0.784590791978649,
-0.631551577756444), .Dim = c(6L, 1L)), `EUR/GBP_SocialMediaCount` = structure(c(-1.68861759789696,
-1.66829994393287, -1.5910928588693, -1.59515638966212, -1.6967446594826,
-1.63172816679749), .Dim = c(6L, 1L)), `EUR/GBP_NewsCount` = structure(c(0.76560533722738,
0.879161625683434, 1.33717198912285, 1.90306082659552, 0.487392430510049,
0.487392430510049), .Dim = c(6L, 1L))), na.action = structure(c(`6` = 6L,
`38` = 38L, `74` = 74L, `101` = 101L, `140` = 140L, `165` = 165L,
`189` = 189L, `197` = 197L, `236` = 236L, `256` = 256L, `323` = 323L,
`351` = 351L, `393` = 393L, `423` = 423L, `442` = 442L, `455` = 455L,
`490` = 490L, `510` = 510L, `551` = 551L, `576` = 576L, `605` = 605L,
`646` = 646L, `676` = 676L, `696` = 696L, `708` = 708L, `742` = 742L,
`762` = 762L, `793` = 793L, `829` = 829L, `858` = 858L, `904` = 904L,
`929` = 929L, `950` = 950L, `961` = 961L, `996` = 996L, `1016` = 1016L,
`1089` = 1089L, `1114` = 1114L, `1159` = 1159L, `1184` = 1184L,
`1207` = 1207L, `1216` = 1216L, `1238` = 1238L, `1243` = 1243L,
`1253` = 1253L, `1278` = 1278L, `1315` = 1315L, `1346` = 1346L,
`1372` = 1372L, `1416` = 1416L, `1441` = 1441L, `1473` = 1473L,
`1532` = 1532L, `1599` = 1599L, `1626` = 1626L, `1669` = 1669L,
`1694` = 1694L, `1718` = 1718L, `1726` = 1726L, `1766` = 1766L,
`1786` = 1786L, `1827` = 1827L, `1853` = 1853L, `1881` = 1881L,
`1922` = 1922L, `1952` = 1952L, `1971` = 1971L, `1984` = 1984L,
`2019` = 2019L, `2039` = 2039L, `2075` = 2075L, `2106` = 2106L,
`2135` = 2135L, `2181` = 2181L, `2206` = 2206L, `2227` = 2227L,
`2238` = 2238L, `2273` = 2273L, `2293` = 2293L, `2325` = 2325L,
`2366` = 2366L, `2391` = 2391L, `2436` = 2436L, `2461` = 2461L,
`2483` = 2483L, `2493` = 2493L), class = "omit"), row.names = c(1L,
2L, 3L, 4L, 5L, 7L), class = "data.frame")
I have built 9 regression models per forecast horizon (t+1, t+5 and t+22) and I am using the predict function to make my forecasts. I have coded this in an R loop, where I also try to assign each forecast to a matrix. My code is the following:
EUR/GBP_RV t+1,t+22`~data.estimateI am trying to calculate realized volatility forecasts using a rolling window forecast. My aim is to use the first 500 observations to forecast the 501st observations, then shift the window forward one step using observations 2 to 501 to predict the 502nd observation. I want this to repeat until I have a complete pseudo out-of-sample forecast.
My df contains 2411 observations of 23 variables, here is small example:
Date
EUR/GBP_RV t+1
EUR/GBP_RV
EUR/GBP_RV_5
EUR/GBP_RV_22
2012-02-13
0.004019947
0.004467109
0.004995980
0.005150602
2012-02-14
0.004077322
0.004019947
0.004704742
0.005099209
2012-02-15
0.004666244
0.004077322
0.004564522
0.005020790
2012-02-16
0.004582351
0.004666244
0.004532930
0.005011078
2012-02-17
0.003951071
0.004582351
0.004362595
0.004999634
2012-02-21
0.005549329
0.004824547
0.004467109
0.004954358
The head of the df can be reproduced with
structure(list(Date = structure(c(15383, 15384, 15385, 15386,
15387, 15391), class = "Date"), `EUR/GBP_RV t+1,t+22` = c(0.00437808494654599,
0.00439764887779732, 0.00441997330738947, 0.00437799055732722,
0.00435021150904479, 0.00434881306458859), `EUR/GBP_RGV t+1,t+22` = c(0.00310674728131117,
0.00311502965608506, 0.00313756204195853, 0.00312923997431178,
0.00310846773074243, 0.00309755540903969), `EUR/GBP_RBV t+1,t+22` = c(0.00304961980133602,
0.00306866297401415, 0.00307794319983677, 0.00302801249035602,
0.00300946121851254, 0.00302272755554915), `EUR/GBP_RV t+1,t+5` = c(0.00425938711995146,
0.00442030721926592, 0.00471470868108043, 0.00487869292442023,
0.00476849421943949, 0.0046067439660438), `EUR/GBP_RGV t+1,t+5` = c(0.00287718093809447,
0.00311308998902836, 0.00344398536439729, 0.00376911066284235,
0.00377425759242542, 0.00353909902900148), `EUR/GBP_RBV t+1,t+5` = c(0.00313771439501486,
0.00310626895475871, 0.0031789431316576, 0.00305962424370556,
0.00288671182187571, 0.00291630955829613), `EUR/GBP_RV t+1` = c(0.00401994700051122,
0.00407732180013827, 0.00466624428620966, 0.00458235106134663,
0.00395107145155152, 0.00554932910921084), `EUR/GBP_RGV t+1` = c(0.00280067842079775,
0.00275522601341373, 0.00296142025653418, 0.00320716195737542,
0.00266141804235125, 0.00440970289025837), `EUR/GBP_RBV t+1` = c(0.00288377777753365,
0.00300554199386584, 0.00360608177982326, 0.00327292734850446,
0.0029202430753471, 0.00336891287836027), `EUR/GBP_RV` = c(0.00446710941914797,
0.00401994700051122, 0.00407732180013827, 0.00466624428620966,
0.00458235106134663, 0.00482454749708351), `EUR/GBP_RV_5` = c(0.00499598016427624,
0.00470474196716823, 0.00456452150727461, 0.00453292965488229,
0.00436259471347075, 0.00442030721926592), `EUR/GBP_RV_22` = c(0.00515060219897263,
0.00509920878086075, 0.00502079002092667, 0.00501107755050095,
0.00499963428727425, 0.00495435807685843), `EUR/GBP_RBV` = c(0.00324667045338159,
0.00288377777753365, 0.00300554199386584, 0.00360608177982326,
0.00327292734850446, 0.00272655057625291), `EUR/GBP_RBV_5` = c(0.0034985439252634,
0.00318731350301598, 0.00319529774619179, 0.0032799330165155,
0.00320299987062176, 0.00310626895475871), `EUR/GBP_RBV_22` = c(0.0036581887941976,
0.00362298829344015, 0.00355498498935768, 0.0035465419934449,
0.00355752455210586, 0.00351669973034298), `EUR/GBP_RGV` = c(0.00306825643155514,
0.00280067842079775, 0.00275522601341373, 0.00296142025653418,
0.00320716195737542, 0.00398022367546721), `EUR/GBP_RGV_5` = c(0.00353290218424469,
0.00345194162523714, 0.00325362896209417, 0.00312087362386985,
0.00295854861593525, 0.00311308998902836), `EUR/GBP_RGV_22` = c(0.00359974659692405,
0.00356342531619103, 0.00352224165959556, 0.00351722666683608,
0.00349184335907274, 0.00346394410318992), `EUR/GBP_TotalCount` = structure(c(-0.179518680545716,
-0.0757259172924681, 0.333514120677483, 0.759064450015801, -0.419724789788948,
-0.360414639358521), .Dim = c(6L, 1L)), `EUR/GBP_BloombergCount` = structure(c(-0.701694550941621,
-0.669811381311996, -0.574161872423118, -0.644304845608295, -0.784590791978649,
-0.631551577756444), .Dim = c(6L, 1L)), `EUR/GBP_SocialMediaCount` = structure(c(-1.68861759789696,
-1.66829994393287, -1.5910928588693, -1.59515638966212, -1.6967446594826,
-1.63172816679749), .Dim = c(6L, 1L)), `EUR/GBP_NewsCount` = structure(c(0.76560533722738,
0.879161625683434, 1.33717198912285, 1.90306082659552, 0.487392430510049,
0.487392430510049), .Dim = c(6L, 1L))), na.action = structure(c(`6` = 6L,
`38` = 38L, `74` = 74L, `101` = 101L, `140` = 140L, `165` = 165L,
`189` = 189L, `197` = 197L, `236` = 236L, `256` = 256L, `323` = 323L,
`351` = 351L, `393` = 393L, `423` = 423L, `442` = 442L, `455` = 455L,
`490` = 490L, `510` = 510L, `551` = 551L, `576` = 576L, `605` = 605L,
`646` = 646L, `676` = 676L, `696` = 696L, `708` = 708L, `742` = 742L,
`762` = 762L, `793` = 793L, `829` = 829L, `858` = 858L, `904` = 904L,
`929` = 929L, `950` = 950L, `961` = 961L, `996` = 996L, `1016` = 1016L,
`1089` = 1089L, `1114` = 1114L, `1159` = 1159L, `1184` = 1184L,
`1207` = 1207L, `1216` = 1216L, `1238` = 1238L, `1243` = 1243L,
`1253` = 1253L, `1278` = 1278L, `1315` = 1315L, `1346` = 1346L,
`1372` = 1372L, `1416` = 1416L, `1441` = 1441L, `1473` = 1473L,
`1532` = 1532L, `1599` = 1599L, `1626` = 1626L, `1669` = 1669L,
`1694` = 1694L, `1718` = 1718L, `1726` = 1726L, `1766` = 1766L,
`1786` = 1786L, `1827` = 1827L, `1853` = 1853L, `1881` = 1881L,
`1922` = 1922L, `1952` = 1952L, `1971` = 1971L, `1984` = 1984L,
`2019` = 2019L, `2039` = 2039L, `2075` = 2075L, `2106` = 2106L,
`2135` = 2135L, `2181` = 2181L, `2206` = 2206L, `2227` = 2227L,
`2238` = 2238L, `2273` = 2273L, `2293` = 2293L, `2325` = 2325L,
`2366` = 2366L, `2391` = 2391L, `2436` = 2436L, `2461` = 2461L,
`2483` = 2483L, `2493` = 2493L), class = "omit"), row.names = c(1L,
2L, 3L, 4L, 5L, 7L), class = "data.frame")
I have built 9 regression models per forecast horizon (t+1, t+5 and t+22) and I am using the predict function to make my forecasts. I have coded this in an R loop, where I also try to assign each forecast to a matrix. My code is the following:
EUR/GBP_RV`+data.estimateI am trying to calculate realized volatility forecasts using a rolling window forecast. My aim is to use the first 500 observations to forecast the 501st observations, then shift the window forward one step using observations 2 to 501 to predict the 502nd observation. I want this to repeat until I have a complete pseudo out-of-sample forecast.
My df contains 2411 observations of 23 variables, here is small example:
Date
EUR/GBP_RV t+1
EUR/GBP_RV
EUR/GBP_RV_5
EUR/GBP_RV_22
2012-02-13
0.004019947
0.004467109
0.004995980
0.005150602
2012-02-14
0.004077322
0.004019947
0.004704742
0.005099209
2012-02-15
0.004666244
0.004077322
0.004564522
0.005020790
2012-02-16
0.004582351
0.004666244
0.004532930
0.005011078
2012-02-17
0.003951071
0.004582351
0.004362595
0.004999634
2012-02-21
0.005549329
0.004824547
0.004467109
0.004954358
The head of the df can be reproduced with
structure(list(Date = structure(c(15383, 15384, 15385, 15386,
15387, 15391), class = "Date"), `EUR/GBP_RV t+1,t+22` = c(0.00437808494654599,
0.00439764887779732, 0.00441997330738947, 0.00437799055732722,
0.00435021150904479, 0.00434881306458859), `EUR/GBP_RGV t+1,t+22` = c(0.00310674728131117,
0.00311502965608506, 0.00313756204195853, 0.00312923997431178,
0.00310846773074243, 0.00309755540903969), `EUR/GBP_RBV t+1,t+22` = c(0.00304961980133602,
0.00306866297401415, 0.00307794319983677, 0.00302801249035602,
0.00300946121851254, 0.00302272755554915), `EUR/GBP_RV t+1,t+5` = c(0.00425938711995146,
0.00442030721926592, 0.00471470868108043, 0.00487869292442023,
0.00476849421943949, 0.0046067439660438), `EUR/GBP_RGV t+1,t+5` = c(0.00287718093809447,
0.00311308998902836, 0.00344398536439729, 0.00376911066284235,
0.00377425759242542, 0.00353909902900148), `EUR/GBP_RBV t+1,t+5` = c(0.00313771439501486,
0.00310626895475871, 0.0031789431316576, 0.00305962424370556,
0.00288671182187571, 0.00291630955829613), `EUR/GBP_RV t+1` = c(0.00401994700051122,
0.00407732180013827, 0.00466624428620966, 0.00458235106134663,
0.00395107145155152, 0.00554932910921084), `EUR/GBP_RGV t+1` = c(0.00280067842079775,
0.00275522601341373, 0.00296142025653418, 0.00320716195737542,
0.00266141804235125, 0.00440970289025837), `EUR/GBP_RBV t+1` = c(0.00288377777753365,
0.00300554199386584, 0.00360608177982326, 0.00327292734850446,
0.0029202430753471, 0.00336891287836027), `EUR/GBP_RV` = c(0.00446710941914797,
0.00401994700051122, 0.00407732180013827, 0.00466624428620966,
0.00458235106134663, 0.00482454749708351), `EUR/GBP_RV_5` = c(0.00499598016427624,
0.00470474196716823, 0.00456452150727461, 0.00453292965488229,
0.00436259471347075, 0.00442030721926592), `EUR/GBP_RV_22` = c(0.00515060219897263,
0.00509920878086075, 0.00502079002092667, 0.00501107755050095,
0.00499963428727425, 0.00495435807685843), `EUR/GBP_RBV` = c(0.00324667045338159,
0.00288377777753365, 0.00300554199386584, 0.00360608177982326,
0.00327292734850446, 0.00272655057625291), `EUR/GBP_RBV_5` = c(0.0034985439252634,
0.00318731350301598, 0.00319529774619179, 0.0032799330165155,
0.00320299987062176, 0.00310626895475871), `EUR/GBP_RBV_22` = c(0.0036581887941976,
0.00362298829344015, 0.00355498498935768, 0.0035465419934449,
0.00355752455210586, 0.00351669973034298), `EUR/GBP_RGV` = c(0.00306825643155514,
0.00280067842079775, 0.00275522601341373, 0.00296142025653418,
0.00320716195737542, 0.00398022367546721), `EUR/GBP_RGV_5` = c(0.00353290218424469,
0.00345194162523714, 0.00325362896209417, 0.00312087362386985,
0.00295854861593525, 0.00311308998902836), `EUR/GBP_RGV_22` = c(0.00359974659692405,
0.00356342531619103, 0.00352224165959556, 0.00351722666683608,
0.00349184335907274, 0.00346394410318992), `EUR/GBP_TotalCount` = structure(c(-0.179518680545716,
-0.0757259172924681, 0.333514120677483, 0.759064450015801, -0.419724789788948,
-0.360414639358521), .Dim = c(6L, 1L)), `EUR/GBP_BloombergCount` = structure(c(-0.701694550941621,
-0.669811381311996, -0.574161872423118, -0.644304845608295, -0.784590791978649,
-0.631551577756444), .Dim = c(6L, 1L)), `EUR/GBP_SocialMediaCount` = structure(c(-1.68861759789696,
-1.66829994393287, -1.5910928588693, -1.59515638966212, -1.6967446594826,
-1.63172816679749), .Dim = c(6L, 1L)), `EUR/GBP_NewsCount` = structure(c(0.76560533722738,
0.879161625683434, 1.33717198912285, 1.90306082659552, 0.487392430510049,
0.487392430510049), .Dim = c(6L, 1L))), na.action = structure(c(`6` = 6L,
`38` = 38L, `74` = 74L, `101` = 101L, `140` = 140L, `165` = 165L,
`189` = 189L, `197` = 197L, `236` = 236L, `256` = 256L, `323` = 323L,
`351` = 351L, `393` = 393L, `423` = 423L, `442` = 442L, `455` = 455L,
`490` = 490L, `510` = 510L, `551` = 551L, `576` = 576L, `605` = 605L,
`646` = 646L, `676` = 676L, `696` = 696L, `708` = 708L, `742` = 742L,
`762` = 762L, `793` = 793L, `829` = 829L, `858` = 858L, `904` = 904L,
`929` = 929L, `950` = 950L, `961` = 961L, `996` = 996L, `1016` = 1016L,
`1089` = 1089L, `1114` = 1114L, `1159` = 1159L, `1184` = 1184L,
`1207` = 1207L, `1216` = 1216L, `1238` = 1238L, `1243` = 1243L,
`1253` = 1253L, `1278` = 1278L, `1315` = 1315L, `1346` = 1346L,
`1372` = 1372L, `1416` = 1416L, `1441` = 1441L, `1473` = 1473L,
`1532` = 1532L, `1599` = 1599L, `1626` = 1626L, `1669` = 1669L,
`1694` = 1694L, `1718` = 1718L, `1726` = 1726L, `1766` = 1766L,
`1786` = 1786L, `1827` = 1827L, `1853` = 1853L, `1881` = 1881L,
`1922` = 1922L, `1952` = 1952L, `1971` = 1971L, `1984` = 1984L,
`2019` = 2019L, `2039` = 2039L, `2075` = 2075L, `2106` = 2106L,
`2135` = 2135L, `2181` = 2181L, `2206` = 2206L, `2227` = 2227L,
`2238` = 2238L, `2273` = 2273L, `2293` = 2293L, `2325` = 2325L,
`2366` = 2366L, `2391` = 2391L, `2436` = 2436L, `2461` = 2461L,
`2483` = 2483L, `2493` = 2493L), class = "omit"), row.names = c(1L,
2L, 3L, 4L, 5L, 7L), class = "data.frame")
I have built 9 regression models per forecast horizon (t+1, t+5 and t+22) and I am using the predict function to make my forecasts. I have coded this in an R loop, where I also try to assign each forecast to a matrix. My code is the following:
EUR/GBP_RV_5`+data.estimateI am trying to calculate realized volatility forecasts using a rolling window forecast. My aim is to use the first 500 observations to forecast the 501st observations, then shift the window forward one step using observations 2 to 501 to predict the 502nd observation. I want this to repeat until I have a complete pseudo out-of-sample forecast.
My df contains 2411 observations of 23 variables, here is small example:
Date
EUR/GBP_RV t+1
EUR/GBP_RV
EUR/GBP_RV_5
EUR/GBP_RV_22
2012-02-13
0.004019947
0.004467109
0.004995980
0.005150602
2012-02-14
0.004077322
0.004019947
0.004704742
0.005099209
2012-02-15
0.004666244
0.004077322
0.004564522
0.005020790
2012-02-16
0.004582351
0.004666244
0.004532930
0.005011078
2012-02-17
0.003951071
0.004582351
0.004362595
0.004999634
2012-02-21
0.005549329
0.004824547
0.004467109
0.004954358
The head of the df can be reproduced with
structure(list(Date = structure(c(15383, 15384, 15385, 15386,
15387, 15391), class = "Date"), `EUR/GBP_RV t+1,t+22` = c(0.00437808494654599,
0.00439764887779732, 0.00441997330738947, 0.00437799055732722,
0.00435021150904479, 0.00434881306458859), `EUR/GBP_RGV t+1,t+22` = c(0.00310674728131117,
0.00311502965608506, 0.00313756204195853, 0.00312923997431178,
0.00310846773074243, 0.00309755540903969), `EUR/GBP_RBV t+1,t+22` = c(0.00304961980133602,
0.00306866297401415, 0.00307794319983677, 0.00302801249035602,
0.00300946121851254, 0.00302272755554915), `EUR/GBP_RV t+1,t+5` = c(0.00425938711995146,
0.00442030721926592, 0.00471470868108043, 0.00487869292442023,
0.00476849421943949, 0.0046067439660438), `EUR/GBP_RGV t+1,t+5` = c(0.00287718093809447,
0.00311308998902836, 0.00344398536439729, 0.00376911066284235,
0.00377425759242542, 0.00353909902900148), `EUR/GBP_RBV t+1,t+5` = c(0.00313771439501486,
0.00310626895475871, 0.0031789431316576, 0.00305962424370556,
0.00288671182187571, 0.00291630955829613), `EUR/GBP_RV t+1` = c(0.00401994700051122,
0.00407732180013827, 0.00466624428620966, 0.00458235106134663,
0.00395107145155152, 0.00554932910921084), `EUR/GBP_RGV t+1` = c(0.00280067842079775,
0.00275522601341373, 0.00296142025653418, 0.00320716195737542,
0.00266141804235125, 0.00440970289025837), `EUR/GBP_RBV t+1` = c(0.00288377777753365,
0.00300554199386584, 0.00360608177982326, 0.00327292734850446,
0.0029202430753471, 0.00336891287836027), `EUR/GBP_RV` = c(0.00446710941914797,
0.00401994700051122, 0.00407732180013827, 0.00466624428620966,
0.00458235106134663, 0.00482454749708351), `EUR/GBP_RV_5` = c(0.00499598016427624,
0.00470474196716823, 0.00456452150727461, 0.00453292965488229,
0.00436259471347075, 0.00442030721926592), `EUR/GBP_RV_22` = c(0.00515060219897263,
0.00509920878086075, 0.00502079002092667, 0.00501107755050095,
0.00499963428727425, 0.00495435807685843), `EUR/GBP_RBV` = c(0.00324667045338159,
0.00288377777753365, 0.00300554199386584, 0.00360608177982326,
0.00327292734850446, 0.00272655057625291), `EUR/GBP_RBV_5` = c(0.0034985439252634,
0.00318731350301598, 0.00319529774619179, 0.0032799330165155,
0.00320299987062176, 0.00310626895475871), `EUR/GBP_RBV_22` = c(0.0036581887941976,
0.00362298829344015, 0.00355498498935768, 0.0035465419934449,
0.00355752455210586, 0.00351669973034298), `EUR/GBP_RGV` = c(0.00306825643155514,
0.00280067842079775, 0.00275522601341373, 0.00296142025653418,
0.00320716195737542, 0.00398022367546721), `EUR/GBP_RGV_5` = c(0.00353290218424469,
0.00345194162523714, 0.00325362896209417, 0.00312087362386985,
0.00295854861593525, 0.00311308998902836), `EUR/GBP_RGV_22` = c(0.00359974659692405,
0.00356342531619103, 0.00352224165959556, 0.00351722666683608,
0.00349184335907274, 0.00346394410318992), `EUR/GBP_TotalCount` = structure(c(-0.179518680545716,
-0.0757259172924681, 0.333514120677483, 0.759064450015801, -0.419724789788948,
-0.360414639358521), .Dim = c(6L, 1L)), `EUR/GBP_BloombergCount` = structure(c(-0.701694550941621,
-0.669811381311996, -0.574161872423118, -0.644304845608295, -0.784590791978649,
-0.631551577756444), .Dim = c(6L, 1L)), `EUR/GBP_SocialMediaCount` = structure(c(-1.68861759789696,
-1.66829994393287, -1.5910928588693, -1.59515638966212, -1.6967446594826,
-1.63172816679749), .Dim = c(6L, 1L)), `EUR/GBP_NewsCount` = structure(c(0.76560533722738,
0.879161625683434, 1.33717198912285, 1.90306082659552, 0.487392430510049,
0.487392430510049), .Dim = c(6L, 1L))), na.action = structure(c(`6` = 6L,
`38` = 38L, `74` = 74L, `101` = 101L, `140` = 140L, `165` = 165L,
`189` = 189L, `197` = 197L, `236` = 236L, `256` = 256L, `323` = 323L,
`351` = 351L, `393` = 393L, `423` = 423L, `442` = 442L, `455` = 455L,
`490` = 490L, `510` = 510L, `551` = 551L, `576` = 576L, `605` = 605L,
`646` = 646L, `676` = 676L, `696` = 696L, `708` = 708L, `742` = 742L,
`762` = 762L, `793` = 793L, `829` = 829L, `858` = 858L, `904` = 904L,
`929` = 929L, `950` = 950L, `961` = 961L, `996` = 996L, `1016` = 1016L,
`1089` = 1089L, `1114` = 1114L, `1159` = 1159L, `1184` = 1184L,
`1207` = 1207L, `1216` = 1216L, `1238` = 1238L, `1243` = 1243L,
`1253` = 1253L, `1278` = 1278L, `1315` = 1315L, `1346` = 1346L,
`1372` = 1372L, `1416` = 1416L, `1441` = 1441L, `1473` = 1473L,
`1532` = 1532L, `1599` = 1599L, `1626` = 1626L, `1669` = 1669L,
`1694` = 1694L, `1718` = 1718L, `1726` = 1726L, `1766` = 1766L,
`1786` = 1786L, `1827` = 1827L, `1853` = 1853L, `1881` = 1881L,
`1922` = 1922L, `1952` = 1952L, `1971` = 1971L, `1984` = 1984L,
`2019` = 2019L, `2039` = 2039L, `2075` = 2075L, `2106` = 2106L,
`2135` = 2135L, `2181` = 2181L, `2206` = 2206L, `2227` = 2227L,
`2238` = 2238L, `2273` = 2273L, `2293` = 2293L, `2325` = 2325L,
`2366` = 2366L, `2391` = 2391L, `2436` = 2436L, `2461` = 2461L,
`2483` = 2483L, `2493` = 2493L), class = "omit"), row.names = c(1L,
2L, 3L, 4L, 5L, 7L), class = "data.frame")
I have built 9 regression models per forecast horizon (t+1, t+5 and t+22) and I am using the predict function to make my forecasts. I have coded this in an R loop, where I also try to assign each forecast to a matrix. My code is the following:
EUR/GBP_RV_22`+data.estimateI am trying to calculate realized volatility forecasts using a rolling window forecast. My aim is to use the first 500 observations to forecast the 501st observations, then shift the window forward one step using observations 2 to 501 to predict the 502nd observation. I want this to repeat until I have a complete pseudo out-of-sample forecast.
My df contains 2411 observations of 23 variables, here is small example:
Date
EUR/GBP_RV t+1
EUR/GBP_RV
EUR/GBP_RV_5
EUR/GBP_RV_22
2012-02-13
0.004019947
0.004467109
0.004995980
0.005150602
2012-02-14
0.004077322
0.004019947
0.004704742
0.005099209
2012-02-15
0.004666244
0.004077322
0.004564522
0.005020790
2012-02-16
0.004582351
0.004666244
0.004532930
0.005011078
2012-02-17
0.003951071
0.004582351
0.004362595
0.004999634
2012-02-21
0.005549329
0.004824547
0.004467109
0.004954358
The head of the df can be reproduced with
structure(list(Date = structure(c(15383, 15384, 15385, 15386,
15387, 15391), class = "Date"), `EUR/GBP_RV t+1,t+22` = c(0.00437808494654599,
0.00439764887779732, 0.00441997330738947, 0.00437799055732722,
0.00435021150904479, 0.00434881306458859), `EUR/GBP_RGV t+1,t+22` = c(0.00310674728131117,
0.00311502965608506, 0.00313756204195853, 0.00312923997431178,
0.00310846773074243, 0.00309755540903969), `EUR/GBP_RBV t+1,t+22` = c(0.00304961980133602,
0.00306866297401415, 0.00307794319983677, 0.00302801249035602,
0.00300946121851254, 0.00302272755554915), `EUR/GBP_RV t+1,t+5` = c(0.00425938711995146,
0.00442030721926592, 0.00471470868108043, 0.00487869292442023,
0.00476849421943949, 0.0046067439660438), `EUR/GBP_RGV t+1,t+5` = c(0.00287718093809447,
0.00311308998902836, 0.00344398536439729, 0.00376911066284235,
0.00377425759242542, 0.00353909902900148), `EUR/GBP_RBV t+1,t+5` = c(0.00313771439501486,
0.00310626895475871, 0.0031789431316576, 0.00305962424370556,
0.00288671182187571, 0.00291630955829613), `EUR/GBP_RV t+1` = c(0.00401994700051122,
0.00407732180013827, 0.00466624428620966, 0.00458235106134663,
0.00395107145155152, 0.00554932910921084), `EUR/GBP_RGV t+1` = c(0.00280067842079775,
0.00275522601341373, 0.00296142025653418, 0.00320716195737542,
0.00266141804235125, 0.00440970289025837), `EUR/GBP_RBV t+1` = c(0.00288377777753365,
0.00300554199386584, 0.00360608177982326, 0.00327292734850446,
0.0029202430753471, 0.00336891287836027), `EUR/GBP_RV` = c(0.00446710941914797,
0.00401994700051122, 0.00407732180013827, 0.00466624428620966,
0.00458235106134663, 0.00482454749708351), `EUR/GBP_RV_5` = c(0.00499598016427624,
0.00470474196716823, 0.00456452150727461, 0.00453292965488229,
0.00436259471347075, 0.00442030721926592), `EUR/GBP_RV_22` = c(0.00515060219897263,
0.00509920878086075, 0.00502079002092667, 0.00501107755050095,
0.00499963428727425, 0.00495435807685843), `EUR/GBP_RBV` = c(0.00324667045338159,
0.00288377777753365, 0.00300554199386584, 0.00360608177982326,
0.00327292734850446, 0.00272655057625291), `EUR/GBP_RBV_5` = c(0.0034985439252634,
0.00318731350301598, 0.00319529774619179, 0.0032799330165155,
0.00320299987062176, 0.00310626895475871), `EUR/GBP_RBV_22` = c(0.0036581887941976,
0.00362298829344015, 0.00355498498935768, 0.0035465419934449,
0.00355752455210586, 0.00351669973034298), `EUR/GBP_RGV` = c(0.00306825643155514,
0.00280067842079775, 0.00275522601341373, 0.00296142025653418,
0.00320716195737542, 0.00398022367546721), `EUR/GBP_RGV_5` = c(0.00353290218424469,
0.00345194162523714, 0.00325362896209417, 0.00312087362386985,
0.00295854861593525, 0.00311308998902836), `EUR/GBP_RGV_22` = c(0.00359974659692405,
0.00356342531619103, 0.00352224165959556, 0.00351722666683608,
0.00349184335907274, 0.00346394410318992), `EUR/GBP_TotalCount` = structure(c(-0.179518680545716,
-0.0757259172924681, 0.333514120677483, 0.759064450015801, -0.419724789788948,
-0.360414639358521), .Dim = c(6L, 1L)), `EUR/GBP_BloombergCount` = structure(c(-0.701694550941621,
-0.669811381311996, -0.574161872423118, -0.644304845608295, -0.784590791978649,
-0.631551577756444), .Dim = c(6L, 1L)), `EUR/GBP_SocialMediaCount` = structure(c(-1.68861759789696,
-1.66829994393287, -1.5910928588693, -1.59515638966212, -1.6967446594826,
-1.63172816679749), .Dim = c(6L, 1L)), `EUR/GBP_NewsCount` = structure(c(0.76560533722738,
0.879161625683434, 1.33717198912285, 1.90306082659552, 0.487392430510049,
0.487392430510049), .Dim = c(6L, 1L))), na.action = structure(c(`6` = 6L,
`38` = 38L, `74` = 74L, `101` = 101L, `140` = 140L, `165` = 165L,
`189` = 189L, `197` = 197L, `236` = 236L, `256` = 256L, `323` = 323L,
`351` = 351L, `393` = 393L, `423` = 423L, `442` = 442L, `455` = 455L,
`490` = 490L, `510` = 510L, `551` = 551L, `576` = 576L, `605` = 605L,
`646` = 646L, `676` = 676L, `696` = 696L, `708` = 708L, `742` = 742L,
`762` = 762L, `793` = 793L, `829` = 829L, `858` = 858L, `904` = 904L,
`929` = 929L, `950` = 950L, `961` = 961L, `996` = 996L, `1016` = 1016L,
`1089` = 1089L, `1114` = 1114L, `1159` = 1159L, `1184` = 1184L,
`1207` = 1207L, `1216` = 1216L, `1238` = 1238L, `1243` = 1243L,
`1253` = 1253L, `1278` = 1278L, `1315` = 1315L, `1346` = 1346L,
`1372` = 1372L, `1416` = 1416L, `1441` = 1441L, `1473` = 1473L,
`1532` = 1532L, `1599` = 1599L, `1626` = 1626L, `1669` = 1669L,
`1694` = 1694L, `1718` = 1718L, `1726` = 1726L, `1766` = 1766L,
`1786` = 1786L, `1827` = 1827L, `1853` = 1853L, `1881` = 1881L,
`1922` = 1922L, `1952` = 1952L, `1971` = 1971L, `1984` = 1984L,
`2019` = 2019L, `2039` = 2039L, `2075` = 2075L, `2106` = 2106L,
`2135` = 2135L, `2181` = 2181L, `2206` = 2206L, `2227` = 2227L,
`2238` = 2238L, `2273` = 2273L, `2293` = 2293L, `2325` = 2325L,
`2366` = 2366L, `2391` = 2391L, `2436` = 2436L, `2461` = 2461L,
`2483` = 2483L, `2493` = 2493L), class = "omit"), row.names = c(1L,
2L, 3L, 4L, 5L, 7L), class = "data.frame")
I have built 9 regression models per forecast horizon (t+1, t+5 and t+22) and I am using the predict function to make my forecasts. I have coded this in an R loop, where I also try to assign each forecast to a matrix. My code is the following:
EUR/GBP_BloombergCount`)
EURGBP_HAR_RVt22_SocialMedia_train <- lm(data.estimateI am trying to calculate realized volatility forecasts using a rolling window forecast. My aim is to use the first 500 observations to forecast the 501st observations, then shift the window forward one step using observations 2 to 501 to predict the 502nd observation. I want this to repeat until I have a complete pseudo out-of-sample forecast.
My df contains 2411 observations of 23 variables, here is small example:
Date
EUR/GBP_RV t+1
EUR/GBP_RV
EUR/GBP_RV_5
EUR/GBP_RV_22
2012-02-13
0.004019947
0.004467109
0.004995980
0.005150602
2012-02-14
0.004077322
0.004019947
0.004704742
0.005099209
2012-02-15
0.004666244
0.004077322
0.004564522
0.005020790
2012-02-16
0.004582351
0.004666244
0.004532930
0.005011078
2012-02-17
0.003951071
0.004582351
0.004362595
0.004999634
2012-02-21
0.005549329
0.004824547
0.004467109
0.004954358
The head of the df can be reproduced with
structure(list(Date = structure(c(15383, 15384, 15385, 15386,
15387, 15391), class = "Date"), `EUR/GBP_RV t+1,t+22` = c(0.00437808494654599,
0.00439764887779732, 0.00441997330738947, 0.00437799055732722,
0.00435021150904479, 0.00434881306458859), `EUR/GBP_RGV t+1,t+22` = c(0.00310674728131117,
0.00311502965608506, 0.00313756204195853, 0.00312923997431178,
0.00310846773074243, 0.00309755540903969), `EUR/GBP_RBV t+1,t+22` = c(0.00304961980133602,
0.00306866297401415, 0.00307794319983677, 0.00302801249035602,
0.00300946121851254, 0.00302272755554915), `EUR/GBP_RV t+1,t+5` = c(0.00425938711995146,
0.00442030721926592, 0.00471470868108043, 0.00487869292442023,
0.00476849421943949, 0.0046067439660438), `EUR/GBP_RGV t+1,t+5` = c(0.00287718093809447,
0.00311308998902836, 0.00344398536439729, 0.00376911066284235,
0.00377425759242542, 0.00353909902900148), `EUR/GBP_RBV t+1,t+5` = c(0.00313771439501486,
0.00310626895475871, 0.0031789431316576, 0.00305962424370556,
0.00288671182187571, 0.00291630955829613), `EUR/GBP_RV t+1` = c(0.00401994700051122,
0.00407732180013827, 0.00466624428620966, 0.00458235106134663,
0.00395107145155152, 0.00554932910921084), `EUR/GBP_RGV t+1` = c(0.00280067842079775,
0.00275522601341373, 0.00296142025653418, 0.00320716195737542,
0.00266141804235125, 0.00440970289025837), `EUR/GBP_RBV t+1` = c(0.00288377777753365,
0.00300554199386584, 0.00360608177982326, 0.00327292734850446,
0.0029202430753471, 0.00336891287836027), `EUR/GBP_RV` = c(0.00446710941914797,
0.00401994700051122, 0.00407732180013827, 0.00466624428620966,
0.00458235106134663, 0.00482454749708351), `EUR/GBP_RV_5` = c(0.00499598016427624,
0.00470474196716823, 0.00456452150727461, 0.00453292965488229,
0.00436259471347075, 0.00442030721926592), `EUR/GBP_RV_22` = c(0.00515060219897263,
0.00509920878086075, 0.00502079002092667, 0.00501107755050095,
0.00499963428727425, 0.00495435807685843), `EUR/GBP_RBV` = c(0.00324667045338159,
0.00288377777753365, 0.00300554199386584, 0.00360608177982326,
0.00327292734850446, 0.00272655057625291), `EUR/GBP_RBV_5` = c(0.0034985439252634,
0.00318731350301598, 0.00319529774619179, 0.0032799330165155,
0.00320299987062176, 0.00310626895475871), `EUR/GBP_RBV_22` = c(0.0036581887941976,
0.00362298829344015, 0.00355498498935768, 0.0035465419934449,
0.00355752455210586, 0.00351669973034298), `EUR/GBP_RGV` = c(0.00306825643155514,
0.00280067842079775, 0.00275522601341373, 0.00296142025653418,
0.00320716195737542, 0.00398022367546721), `EUR/GBP_RGV_5` = c(0.00353290218424469,
0.00345194162523714, 0.00325362896209417, 0.00312087362386985,
0.00295854861593525, 0.00311308998902836), `EUR/GBP_RGV_22` = c(0.00359974659692405,
0.00356342531619103, 0.00352224165959556, 0.00351722666683608,
0.00349184335907274, 0.00346394410318992), `EUR/GBP_TotalCount` = structure(c(-0.179518680545716,
-0.0757259172924681, 0.333514120677483, 0.759064450015801, -0.419724789788948,
-0.360414639358521), .Dim = c(6L, 1L)), `EUR/GBP_BloombergCount` = structure(c(-0.701694550941621,
-0.669811381311996, -0.574161872423118, -0.644304845608295, -0.784590791978649,
-0.631551577756444), .Dim = c(6L, 1L)), `EUR/GBP_SocialMediaCount` = structure(c(-1.68861759789696,
-1.66829994393287, -1.5910928588693, -1.59515638966212, -1.6967446594826,
-1.63172816679749), .Dim = c(6L, 1L)), `EUR/GBP_NewsCount` = structure(c(0.76560533722738,
0.879161625683434, 1.33717198912285, 1.90306082659552, 0.487392430510049,
0.487392430510049), .Dim = c(6L, 1L))), na.action = structure(c(`6` = 6L,
`38` = 38L, `74` = 74L, `101` = 101L, `140` = 140L, `165` = 165L,
`189` = 189L, `197` = 197L, `236` = 236L, `256` = 256L, `323` = 323L,
`351` = 351L, `393` = 393L, `423` = 423L, `442` = 442L, `455` = 455L,
`490` = 490L, `510` = 510L, `551` = 551L, `576` = 576L, `605` = 605L,
`646` = 646L, `676` = 676L, `696` = 696L, `708` = 708L, `742` = 742L,
`762` = 762L, `793` = 793L, `829` = 829L, `858` = 858L, `904` = 904L,
`929` = 929L, `950` = 950L, `961` = 961L, `996` = 996L, `1016` = 1016L,
`1089` = 1089L, `1114` = 1114L, `1159` = 1159L, `1184` = 1184L,
`1207` = 1207L, `1216` = 1216L, `1238` = 1238L, `1243` = 1243L,
`1253` = 1253L, `1278` = 1278L, `1315` = 1315L, `1346` = 1346L,
`1372` = 1372L, `1416` = 1416L, `1441` = 1441L, `1473` = 1473L,
`1532` = 1532L, `1599` = 1599L, `1626` = 1626L, `1669` = 1669L,
`1694` = 1694L, `1718` = 1718L, `1726` = 1726L, `1766` = 1766L,
`1786` = 1786L, `1827` = 1827L, `1853` = 1853L, `1881` = 1881L,
`1922` = 1922L, `1952` = 1952L, `1971` = 1971L, `1984` = 1984L,
`2019` = 2019L, `2039` = 2039L, `2075` = 2075L, `2106` = 2106L,
`2135` = 2135L, `2181` = 2181L, `2206` = 2206L, `2227` = 2227L,
`2238` = 2238L, `2273` = 2273L, `2293` = 2293L, `2325` = 2325L,
`2366` = 2366L, `2391` = 2391L, `2436` = 2436L, `2461` = 2461L,
`2483` = 2483L, `2493` = 2493L), class = "omit"), row.names = c(1L,
2L, 3L, 4L, 5L, 7L), class = "data.frame")
I have built 9 regression models per forecast horizon (t+1, t+5 and t+22) and I am using the predict function to make my forecasts. I have coded this in an R loop, where I also try to assign each forecast to a matrix. My code is the following:
EUR/GBP_RV t+1,t+22`~data.estimateI am trying to calculate realized volatility forecasts using a rolling window forecast. My aim is to use the first 500 observations to forecast the 501st observations, then shift the window forward one step using observations 2 to 501 to predict the 502nd observation. I want this to repeat until I have a complete pseudo out-of-sample forecast.
My df contains 2411 observations of 23 variables, here is small example:
Date
EUR/GBP_RV t+1
EUR/GBP_RV
EUR/GBP_RV_5
EUR/GBP_RV_22
2012-02-13
0.004019947
0.004467109
0.004995980
0.005150602
2012-02-14
0.004077322
0.004019947
0.004704742
0.005099209
2012-02-15
0.004666244
0.004077322
0.004564522
0.005020790
2012-02-16
0.004582351
0.004666244
0.004532930
0.005011078
2012-02-17
0.003951071
0.004582351
0.004362595
0.004999634
2012-02-21
0.005549329
0.004824547
0.004467109
0.004954358
The head of the df can be reproduced with
structure(list(Date = structure(c(15383, 15384, 15385, 15386,
15387, 15391), class = "Date"), `EUR/GBP_RV t+1,t+22` = c(0.00437808494654599,
0.00439764887779732, 0.00441997330738947, 0.00437799055732722,
0.00435021150904479, 0.00434881306458859), `EUR/GBP_RGV t+1,t+22` = c(0.00310674728131117,
0.00311502965608506, 0.00313756204195853, 0.00312923997431178,
0.00310846773074243, 0.00309755540903969), `EUR/GBP_RBV t+1,t+22` = c(0.00304961980133602,
0.00306866297401415, 0.00307794319983677, 0.00302801249035602,
0.00300946121851254, 0.00302272755554915), `EUR/GBP_RV t+1,t+5` = c(0.00425938711995146,
0.00442030721926592, 0.00471470868108043, 0.00487869292442023,
0.00476849421943949, 0.0046067439660438), `EUR/GBP_RGV t+1,t+5` = c(0.00287718093809447,
0.00311308998902836, 0.00344398536439729, 0.00376911066284235,
0.00377425759242542, 0.00353909902900148), `EUR/GBP_RBV t+1,t+5` = c(0.00313771439501486,
0.00310626895475871, 0.0031789431316576, 0.00305962424370556,
0.00288671182187571, 0.00291630955829613), `EUR/GBP_RV t+1` = c(0.00401994700051122,
0.00407732180013827, 0.00466624428620966, 0.00458235106134663,
0.00395107145155152, 0.00554932910921084), `EUR/GBP_RGV t+1` = c(0.00280067842079775,
0.00275522601341373, 0.00296142025653418, 0.00320716195737542,
0.00266141804235125, 0.00440970289025837), `EUR/GBP_RBV t+1` = c(0.00288377777753365,
0.00300554199386584, 0.00360608177982326, 0.00327292734850446,
0.0029202430753471, 0.00336891287836027), `EUR/GBP_RV` = c(0.00446710941914797,
0.00401994700051122, 0.00407732180013827, 0.00466624428620966,
0.00458235106134663, 0.00482454749708351), `EUR/GBP_RV_5` = c(0.00499598016427624,
0.00470474196716823, 0.00456452150727461, 0.00453292965488229,
0.00436259471347075, 0.00442030721926592), `EUR/GBP_RV_22` = c(0.00515060219897263,
0.00509920878086075, 0.00502079002092667, 0.00501107755050095,
0.00499963428727425, 0.00495435807685843), `EUR/GBP_RBV` = c(0.00324667045338159,
0.00288377777753365, 0.00300554199386584, 0.00360608177982326,
0.00327292734850446, 0.00272655057625291), `EUR/GBP_RBV_5` = c(0.0034985439252634,
0.00318731350301598, 0.00319529774619179, 0.0032799330165155,
0.00320299987062176, 0.00310626895475871), `EUR/GBP_RBV_22` = c(0.0036581887941976,
0.00362298829344015, 0.00355498498935768, 0.0035465419934449,
0.00355752455210586, 0.00351669973034298), `EUR/GBP_RGV` = c(0.00306825643155514,
0.00280067842079775, 0.00275522601341373, 0.00296142025653418,
0.00320716195737542, 0.00398022367546721), `EUR/GBP_RGV_5` = c(0.00353290218424469,
0.00345194162523714, 0.00325362896209417, 0.00312087362386985,
0.00295854861593525, 0.00311308998902836), `EUR/GBP_RGV_22` = c(0.00359974659692405,
0.00356342531619103, 0.00352224165959556, 0.00351722666683608,
0.00349184335907274, 0.00346394410318992), `EUR/GBP_TotalCount` = structure(c(-0.179518680545716,
-0.0757259172924681, 0.333514120677483, 0.759064450015801, -0.419724789788948,
-0.360414639358521), .Dim = c(6L, 1L)), `EUR/GBP_BloombergCount` = structure(c(-0.701694550941621,
-0.669811381311996, -0.574161872423118, -0.644304845608295, -0.784590791978649,
-0.631551577756444), .Dim = c(6L, 1L)), `EUR/GBP_SocialMediaCount` = structure(c(-1.68861759789696,
-1.66829994393287, -1.5910928588693, -1.59515638966212, -1.6967446594826,
-1.63172816679749), .Dim = c(6L, 1L)), `EUR/GBP_NewsCount` = structure(c(0.76560533722738,
0.879161625683434, 1.33717198912285, 1.90306082659552, 0.487392430510049,
0.487392430510049), .Dim = c(6L, 1L))), na.action = structure(c(`6` = 6L,
`38` = 38L, `74` = 74L, `101` = 101L, `140` = 140L, `165` = 165L,
`189` = 189L, `197` = 197L, `236` = 236L, `256` = 256L, `323` = 323L,
`351` = 351L, `393` = 393L, `423` = 423L, `442` = 442L, `455` = 455L,
`490` = 490L, `510` = 510L, `551` = 551L, `576` = 576L, `605` = 605L,
`646` = 646L, `676` = 676L, `696` = 696L, `708` = 708L, `742` = 742L,
`762` = 762L, `793` = 793L, `829` = 829L, `858` = 858L, `904` = 904L,
`929` = 929L, `950` = 950L, `961` = 961L, `996` = 996L, `1016` = 1016L,
`1089` = 1089L, `1114` = 1114L, `1159` = 1159L, `1184` = 1184L,
`1207` = 1207L, `1216` = 1216L, `1238` = 1238L, `1243` = 1243L,
`1253` = 1253L, `1278` = 1278L, `1315` = 1315L, `1346` = 1346L,
`1372` = 1372L, `1416` = 1416L, `1441` = 1441L, `1473` = 1473L,
`1532` = 1532L, `1599` = 1599L, `1626` = 1626L, `1669` = 1669L,
`1694` = 1694L, `1718` = 1718L, `1726` = 1726L, `1766` = 1766L,
`1786` = 1786L, `1827` = 1827L, `1853` = 1853L, `1881` = 1881L,
`1922` = 1922L, `1952` = 1952L, `1971` = 1971L, `1984` = 1984L,
`2019` = 2019L, `2039` = 2039L, `2075` = 2075L, `2106` = 2106L,
`2135` = 2135L, `2181` = 2181L, `2206` = 2206L, `2227` = 2227L,
`2238` = 2238L, `2273` = 2273L, `2293` = 2293L, `2325` = 2325L,
`2366` = 2366L, `2391` = 2391L, `2436` = 2436L, `2461` = 2461L,
`2483` = 2483L, `2493` = 2493L), class = "omit"), row.names = c(1L,
2L, 3L, 4L, 5L, 7L), class = "data.frame")
I have built 9 regression models per forecast horizon (t+1, t+5 and t+22) and I am using the predict function to make my forecasts. I have coded this in an R loop, where I also try to assign each forecast to a matrix. My code is the following:
EUR/GBP_RV`+data.estimateI am trying to calculate realized volatility forecasts using a rolling window forecast. My aim is to use the first 500 observations to forecast the 501st observations, then shift the window forward one step using observations 2 to 501 to predict the 502nd observation. I want this to repeat until I have a complete pseudo out-of-sample forecast.
My df contains 2411 observations of 23 variables, here is small example:
Date
EUR/GBP_RV t+1
EUR/GBP_RV
EUR/GBP_RV_5
EUR/GBP_RV_22
2012-02-13
0.004019947
0.004467109
0.004995980
0.005150602
2012-02-14
0.004077322
0.004019947
0.004704742
0.005099209
2012-02-15
0.004666244
0.004077322
0.004564522
0.005020790
2012-02-16
0.004582351
0.004666244
0.004532930
0.005011078
2012-02-17
0.003951071
0.004582351
0.004362595
0.004999634
2012-02-21
0.005549329
0.004824547
0.004467109
0.004954358
The head of the df can be reproduced with
structure(list(Date = structure(c(15383, 15384, 15385, 15386,
15387, 15391), class = "Date"), `EUR/GBP_RV t+1,t+22` = c(0.00437808494654599,
0.00439764887779732, 0.00441997330738947, 0.00437799055732722,
0.00435021150904479, 0.00434881306458859), `EUR/GBP_RGV t+1,t+22` = c(0.00310674728131117,
0.00311502965608506, 0.00313756204195853, 0.00312923997431178,
0.00310846773074243, 0.00309755540903969), `EUR/GBP_RBV t+1,t+22` = c(0.00304961980133602,
0.00306866297401415, 0.00307794319983677, 0.00302801249035602,
0.00300946121851254, 0.00302272755554915), `EUR/GBP_RV t+1,t+5` = c(0.00425938711995146,
0.00442030721926592, 0.00471470868108043, 0.00487869292442023,
0.00476849421943949, 0.0046067439660438), `EUR/GBP_RGV t+1,t+5` = c(0.00287718093809447,
0.00311308998902836, 0.00344398536439729, 0.00376911066284235,
0.00377425759242542, 0.00353909902900148), `EUR/GBP_RBV t+1,t+5` = c(0.00313771439501486,
0.00310626895475871, 0.0031789431316576, 0.00305962424370556,
0.00288671182187571, 0.00291630955829613), `EUR/GBP_RV t+1` = c(0.00401994700051122,
0.00407732180013827, 0.00466624428620966, 0.00458235106134663,
0.00395107145155152, 0.00554932910921084), `EUR/GBP_RGV t+1` = c(0.00280067842079775,
0.00275522601341373, 0.00296142025653418, 0.00320716195737542,
0.00266141804235125, 0.00440970289025837), `EUR/GBP_RBV t+1` = c(0.00288377777753365,
0.00300554199386584, 0.00360608177982326, 0.00327292734850446,
0.0029202430753471, 0.00336891287836027), `EUR/GBP_RV` = c(0.00446710941914797,
0.00401994700051122, 0.00407732180013827, 0.00466624428620966,
0.00458235106134663, 0.00482454749708351), `EUR/GBP_RV_5` = c(0.00499598016427624,
0.00470474196716823, 0.00456452150727461, 0.00453292965488229,
0.00436259471347075, 0.00442030721926592), `EUR/GBP_RV_22` = c(0.00515060219897263,
0.00509920878086075, 0.00502079002092667, 0.00501107755050095,
0.00499963428727425, 0.00495435807685843), `EUR/GBP_RBV` = c(0.00324667045338159,
0.00288377777753365, 0.00300554199386584, 0.00360608177982326,
0.00327292734850446, 0.00272655057625291), `EUR/GBP_RBV_5` = c(0.0034985439252634,
0.00318731350301598, 0.00319529774619179, 0.0032799330165155,
0.00320299987062176, 0.00310626895475871), `EUR/GBP_RBV_22` = c(0.0036581887941976,
0.00362298829344015, 0.00355498498935768, 0.0035465419934449,
0.00355752455210586, 0.00351669973034298), `EUR/GBP_RGV` = c(0.00306825643155514,
0.00280067842079775, 0.00275522601341373, 0.00296142025653418,
0.00320716195737542, 0.00398022367546721), `EUR/GBP_RGV_5` = c(0.00353290218424469,
0.00345194162523714, 0.00325362896209417, 0.00312087362386985,
0.00295854861593525, 0.00311308998902836), `EUR/GBP_RGV_22` = c(0.00359974659692405,
0.00356342531619103, 0.00352224165959556, 0.00351722666683608,
0.00349184335907274, 0.00346394410318992), `EUR/GBP_TotalCount` = structure(c(-0.179518680545716,
-0.0757259172924681, 0.333514120677483, 0.759064450015801, -0.419724789788948,
-0.360414639358521), .Dim = c(6L, 1L)), `EUR/GBP_BloombergCount` = structure(c(-0.701694550941621,
-0.669811381311996, -0.574161872423118, -0.644304845608295, -0.784590791978649,
-0.631551577756444), .Dim = c(6L, 1L)), `EUR/GBP_SocialMediaCount` = structure(c(-1.68861759789696,
-1.66829994393287, -1.5910928588693, -1.59515638966212, -1.6967446594826,
-1.63172816679749), .Dim = c(6L, 1L)), `EUR/GBP_NewsCount` = structure(c(0.76560533722738,
0.879161625683434, 1.33717198912285, 1.90306082659552, 0.487392430510049,
0.487392430510049), .Dim = c(6L, 1L))), na.action = structure(c(`6` = 6L,
`38` = 38L, `74` = 74L, `101` = 101L, `140` = 140L, `165` = 165L,
`189` = 189L, `197` = 197L, `236` = 236L, `256` = 256L, `323` = 323L,
`351` = 351L, `393` = 393L, `423` = 423L, `442` = 442L, `455` = 455L,
`490` = 490L, `510` = 510L, `551` = 551L, `576` = 576L, `605` = 605L,
`646` = 646L, `676` = 676L, `696` = 696L, `708` = 708L, `742` = 742L,
`762` = 762L, `793` = 793L, `829` = 829L, `858` = 858L, `904` = 904L,
`929` = 929L, `950` = 950L, `961` = 961L, `996` = 996L, `1016` = 1016L,
`1089` = 1089L, `1114` = 1114L, `1159` = 1159L, `1184` = 1184L,
`1207` = 1207L, `1216` = 1216L, `1238` = 1238L, `1243` = 1243L,
`1253` = 1253L, `1278` = 1278L, `1315` = 1315L, `1346` = 1346L,
`1372` = 1372L, `1416` = 1416L, `1441` = 1441L, `1473` = 1473L,
`1532` = 1532L, `1599` = 1599L, `1626` = 1626L, `1669` = 1669L,
`1694` = 1694L, `1718` = 1718L, `1726` = 1726L, `1766` = 1766L,
`1786` = 1786L, `1827` = 1827L, `1853` = 1853L, `1881` = 1881L,
`1922` = 1922L, `1952` = 1952L, `1971` = 1971L, `1984` = 1984L,
`2019` = 2019L, `2039` = 2039L, `2075` = 2075L, `2106` = 2106L,
`2135` = 2135L, `2181` = 2181L, `2206` = 2206L, `2227` = 2227L,
`2238` = 2238L, `2273` = 2273L, `2293` = 2293L, `2325` = 2325L,
`2366` = 2366L, `2391` = 2391L, `2436` = 2436L, `2461` = 2461L,
`2483` = 2483L, `2493` = 2493L), class = "omit"), row.names = c(1L,
2L, 3L, 4L, 5L, 7L), class = "data.frame")
I have built 9 regression models per forecast horizon (t+1, t+5 and t+22) and I am using the predict function to make my forecasts. I have coded this in an R loop, where I also try to assign each forecast to a matrix. My code is the following:
EUR/GBP_RV_5`+data.estimateI am trying to calculate realized volatility forecasts using a rolling window forecast. My aim is to use the first 500 observations to forecast the 501st observations, then shift the window forward one step using observations 2 to 501 to predict the 502nd observation. I want this to repeat until I have a complete pseudo out-of-sample forecast.
My df contains 2411 observations of 23 variables, here is small example:
Date
EUR/GBP_RV t+1
EUR/GBP_RV
EUR/GBP_RV_5
EUR/GBP_RV_22
2012-02-13
0.004019947
0.004467109
0.004995980
0.005150602
2012-02-14
0.004077322
0.004019947
0.004704742
0.005099209
2012-02-15
0.004666244
0.004077322
0.004564522
0.005020790
2012-02-16
0.004582351
0.004666244
0.004532930
0.005011078
2012-02-17
0.003951071
0.004582351
0.004362595
0.004999634
2012-02-21
0.005549329
0.004824547
0.004467109
0.004954358
The head of the df can be reproduced with
structure(list(Date = structure(c(15383, 15384, 15385, 15386,
15387, 15391), class = "Date"), `EUR/GBP_RV t+1,t+22` = c(0.00437808494654599,
0.00439764887779732, 0.00441997330738947, 0.00437799055732722,
0.00435021150904479, 0.00434881306458859), `EUR/GBP_RGV t+1,t+22` = c(0.00310674728131117,
0.00311502965608506, 0.00313756204195853, 0.00312923997431178,
0.00310846773074243, 0.00309755540903969), `EUR/GBP_RBV t+1,t+22` = c(0.00304961980133602,
0.00306866297401415, 0.00307794319983677, 0.00302801249035602,
0.00300946121851254, 0.00302272755554915), `EUR/GBP_RV t+1,t+5` = c(0.00425938711995146,
0.00442030721926592, 0.00471470868108043, 0.00487869292442023,
0.00476849421943949, 0.0046067439660438), `EUR/GBP_RGV t+1,t+5` = c(0.00287718093809447,
0.00311308998902836, 0.00344398536439729, 0.00376911066284235,
0.00377425759242542, 0.00353909902900148), `EUR/GBP_RBV t+1,t+5` = c(0.00313771439501486,
0.00310626895475871, 0.0031789431316576, 0.00305962424370556,
0.00288671182187571, 0.00291630955829613), `EUR/GBP_RV t+1` = c(0.00401994700051122,
0.00407732180013827, 0.00466624428620966, 0.00458235106134663,
0.00395107145155152, 0.00554932910921084), `EUR/GBP_RGV t+1` = c(0.00280067842079775,
0.00275522601341373, 0.00296142025653418, 0.00320716195737542,
0.00266141804235125, 0.00440970289025837), `EUR/GBP_RBV t+1` = c(0.00288377777753365,
0.00300554199386584, 0.00360608177982326, 0.00327292734850446,
0.0029202430753471, 0.00336891287836027), `EUR/GBP_RV` = c(0.00446710941914797,
0.00401994700051122, 0.00407732180013827, 0.00466624428620966,
0.00458235106134663, 0.00482454749708351), `EUR/GBP_RV_5` = c(0.00499598016427624,
0.00470474196716823, 0.00456452150727461, 0.00453292965488229,
0.00436259471347075, 0.00442030721926592), `EUR/GBP_RV_22` = c(0.00515060219897263,
0.00509920878086075, 0.00502079002092667, 0.00501107755050095,
0.00499963428727425, 0.00495435807685843), `EUR/GBP_RBV` = c(0.00324667045338159,
0.00288377777753365, 0.00300554199386584, 0.00360608177982326,
0.00327292734850446, 0.00272655057625291), `EUR/GBP_RBV_5` = c(0.0034985439252634,
0.00318731350301598, 0.00319529774619179, 0.0032799330165155,
0.00320299987062176, 0.00310626895475871), `EUR/GBP_RBV_22` = c(0.0036581887941976,
0.00362298829344015, 0.00355498498935768, 0.0035465419934449,
0.00355752455210586, 0.00351669973034298), `EUR/GBP_RGV` = c(0.00306825643155514,
0.00280067842079775, 0.00275522601341373, 0.00296142025653418,
0.00320716195737542, 0.00398022367546721), `EUR/GBP_RGV_5` = c(0.00353290218424469,
0.00345194162523714, 0.00325362896209417, 0.00312087362386985,
0.00295854861593525, 0.00311308998902836), `EUR/GBP_RGV_22` = c(0.00359974659692405,
0.00356342531619103, 0.00352224165959556, 0.00351722666683608,
0.00349184335907274, 0.00346394410318992), `EUR/GBP_TotalCount` = structure(c(-0.179518680545716,
-0.0757259172924681, 0.333514120677483, 0.759064450015801, -0.419724789788948,
-0.360414639358521), .Dim = c(6L, 1L)), `EUR/GBP_BloombergCount` = structure(c(-0.701694550941621,
-0.669811381311996, -0.574161872423118, -0.644304845608295, -0.784590791978649,
-0.631551577756444), .Dim = c(6L, 1L)), `EUR/GBP_SocialMediaCount` = structure(c(-1.68861759789696,
-1.66829994393287, -1.5910928588693, -1.59515638966212, -1.6967446594826,
-1.63172816679749), .Dim = c(6L, 1L)), `EUR/GBP_NewsCount` = structure(c(0.76560533722738,
0.879161625683434, 1.33717198912285, 1.90306082659552, 0.487392430510049,
0.487392430510049), .Dim = c(6L, 1L))), na.action = structure(c(`6` = 6L,
`38` = 38L, `74` = 74L, `101` = 101L, `140` = 140L, `165` = 165L,
`189` = 189L, `197` = 197L, `236` = 236L, `256` = 256L, `323` = 323L,
`351` = 351L, `393` = 393L, `423` = 423L, `442` = 442L, `455` = 455L,
`490` = 490L, `510` = 510L, `551` = 551L, `576` = 576L, `605` = 605L,
`646` = 646L, `676` = 676L, `696` = 696L, `708` = 708L, `742` = 742L,
`762` = 762L, `793` = 793L, `829` = 829L, `858` = 858L, `904` = 904L,
`929` = 929L, `950` = 950L, `961` = 961L, `996` = 996L, `1016` = 1016L,
`1089` = 1089L, `1114` = 1114L, `1159` = 1159L, `1184` = 1184L,
`1207` = 1207L, `1216` = 1216L, `1238` = 1238L, `1243` = 1243L,
`1253` = 1253L, `1278` = 1278L, `1315` = 1315L, `1346` = 1346L,
`1372` = 1372L, `1416` = 1416L, `1441` = 1441L, `1473` = 1473L,
`1532` = 1532L, `1599` = 1599L, `1626` = 1626L, `1669` = 1669L,
`1694` = 1694L, `1718` = 1718L, `1726` = 1726L, `1766` = 1766L,
`1786` = 1786L, `1827` = 1827L, `1853` = 1853L, `1881` = 1881L,
`1922` = 1922L, `1952` = 1952L, `1971` = 1971L, `1984` = 1984L,
`2019` = 2019L, `2039` = 2039L, `2075` = 2075L, `2106` = 2106L,
`2135` = 2135L, `2181` = 2181L, `2206` = 2206L, `2227` = 2227L,
`2238` = 2238L, `2273` = 2273L, `2293` = 2293L, `2325` = 2325L,
`2366` = 2366L, `2391` = 2391L, `2436` = 2436L, `2461` = 2461L,
`2483` = 2483L, `2493` = 2493L), class = "omit"), row.names = c(1L,
2L, 3L, 4L, 5L, 7L), class = "data.frame")
I have built 9 regression models per forecast horizon (t+1, t+5 and t+22) and I am using the predict function to make my forecasts. I have coded this in an R loop, where I also try to assign each forecast to a matrix. My code is the following:
EUR/GBP_RV_22`+data.estimateI am trying to calculate realized volatility forecasts using a rolling window forecast. My aim is to use the first 500 observations to forecast the 501st observations, then shift the window forward one step using observations 2 to 501 to predict the 502nd observation. I want this to repeat until I have a complete pseudo out-of-sample forecast.
My df contains 2411 observations of 23 variables, here is small example:
Date
EUR/GBP_RV t+1
EUR/GBP_RV
EUR/GBP_RV_5
EUR/GBP_RV_22
2012-02-13
0.004019947
0.004467109
0.004995980
0.005150602
2012-02-14
0.004077322
0.004019947
0.004704742
0.005099209
2012-02-15
0.004666244
0.004077322
0.004564522
0.005020790
2012-02-16
0.004582351
0.004666244
0.004532930
0.005011078
2012-02-17
0.003951071
0.004582351
0.004362595
0.004999634
2012-02-21
0.005549329
0.004824547
0.004467109
0.004954358
The head of the df can be reproduced with
structure(list(Date = structure(c(15383, 15384, 15385, 15386,
15387, 15391), class = "Date"), `EUR/GBP_RV t+1,t+22` = c(0.00437808494654599,
0.00439764887779732, 0.00441997330738947, 0.00437799055732722,
0.00435021150904479, 0.00434881306458859), `EUR/GBP_RGV t+1,t+22` = c(0.00310674728131117,
0.00311502965608506, 0.00313756204195853, 0.00312923997431178,
0.00310846773074243, 0.00309755540903969), `EUR/GBP_RBV t+1,t+22` = c(0.00304961980133602,
0.00306866297401415, 0.00307794319983677, 0.00302801249035602,
0.00300946121851254, 0.00302272755554915), `EUR/GBP_RV t+1,t+5` = c(0.00425938711995146,
0.00442030721926592, 0.00471470868108043, 0.00487869292442023,
0.00476849421943949, 0.0046067439660438), `EUR/GBP_RGV t+1,t+5` = c(0.00287718093809447,
0.00311308998902836, 0.00344398536439729, 0.00376911066284235,
0.00377425759242542, 0.00353909902900148), `EUR/GBP_RBV t+1,t+5` = c(0.00313771439501486,
0.00310626895475871, 0.0031789431316576, 0.00305962424370556,
0.00288671182187571, 0.00291630955829613), `EUR/GBP_RV t+1` = c(0.00401994700051122,
0.00407732180013827, 0.00466624428620966, 0.00458235106134663,
0.00395107145155152, 0.00554932910921084), `EUR/GBP_RGV t+1` = c(0.00280067842079775,
0.00275522601341373, 0.00296142025653418, 0.00320716195737542,
0.00266141804235125, 0.00440970289025837), `EUR/GBP_RBV t+1` = c(0.00288377777753365,
0.00300554199386584, 0.00360608177982326, 0.00327292734850446,
0.0029202430753471, 0.00336891287836027), `EUR/GBP_RV` = c(0.00446710941914797,
0.00401994700051122, 0.00407732180013827, 0.00466624428620966,
0.00458235106134663, 0.00482454749708351), `EUR/GBP_RV_5` = c(0.00499598016427624,
0.00470474196716823, 0.00456452150727461, 0.00453292965488229,
0.00436259471347075, 0.00442030721926592), `EUR/GBP_RV_22` = c(0.00515060219897263,
0.00509920878086075, 0.00502079002092667, 0.00501107755050095,
0.00499963428727425, 0.00495435807685843), `EUR/GBP_RBV` = c(0.00324667045338159,
0.00288377777753365, 0.00300554199386584, 0.00360608177982326,
0.00327292734850446, 0.00272655057625291), `EUR/GBP_RBV_5` = c(0.0034985439252634,
0.00318731350301598, 0.00319529774619179, 0.0032799330165155,
0.00320299987062176, 0.00310626895475871), `EUR/GBP_RBV_22` = c(0.0036581887941976,
0.00362298829344015, 0.00355498498935768, 0.0035465419934449,
0.00355752455210586, 0.00351669973034298), `EUR/GBP_RGV` = c(0.00306825643155514,
0.00280067842079775, 0.00275522601341373, 0.00296142025653418,
0.00320716195737542, 0.00398022367546721), `EUR/GBP_RGV_5` = c(0.00353290218424469,
0.00345194162523714, 0.00325362896209417, 0.00312087362386985,
0.00295854861593525, 0.00311308998902836), `EUR/GBP_RGV_22` = c(0.00359974659692405,
0.00356342531619103, 0.00352224165959556, 0.00351722666683608,
0.00349184335907274, 0.00346394410318992), `EUR/GBP_TotalCount` = structure(c(-0.179518680545716,
-0.0757259172924681, 0.333514120677483, 0.759064450015801, -0.419724789788948,
-0.360414639358521), .Dim = c(6L, 1L)), `EUR/GBP_BloombergCount` = structure(c(-0.701694550941621,
-0.669811381311996, -0.574161872423118, -0.644304845608295, -0.784590791978649,
-0.631551577756444), .Dim = c(6L, 1L)), `EUR/GBP_SocialMediaCount` = structure(c(-1.68861759789696,
-1.66829994393287, -1.5910928588693, -1.59515638966212, -1.6967446594826,
-1.63172816679749), .Dim = c(6L, 1L)), `EUR/GBP_NewsCount` = structure(c(0.76560533722738,
0.879161625683434, 1.33717198912285, 1.90306082659552, 0.487392430510049,
0.487392430510049), .Dim = c(6L, 1L))), na.action = structure(c(`6` = 6L,
`38` = 38L, `74` = 74L, `101` = 101L, `140` = 140L, `165` = 165L,
`189` = 189L, `197` = 197L, `236` = 236L, `256` = 256L, `323` = 323L,
`351` = 351L, `393` = 393L, `423` = 423L, `442` = 442L, `455` = 455L,
`490` = 490L, `510` = 510L, `551` = 551L, `576` = 576L, `605` = 605L,
`646` = 646L, `676` = 676L, `696` = 696L, `708` = 708L, `742` = 742L,
`762` = 762L, `793` = 793L, `829` = 829L, `858` = 858L, `904` = 904L,
`929` = 929L, `950` = 950L, `961` = 961L, `996` = 996L, `1016` = 1016L,
`1089` = 1089L, `1114` = 1114L, `1159` = 1159L, `1184` = 1184L,
`1207` = 1207L, `1216` = 1216L, `1238` = 1238L, `1243` = 1243L,
`1253` = 1253L, `1278` = 1278L, `1315` = 1315L, `1346` = 1346L,
`1372` = 1372L, `1416` = 1416L, `1441` = 1441L, `1473` = 1473L,
`1532` = 1532L, `1599` = 1599L, `1626` = 1626L, `1669` = 1669L,
`1694` = 1694L, `1718` = 1718L, `1726` = 1726L, `1766` = 1766L,
`1786` = 1786L, `1827` = 1827L, `1853` = 1853L, `1881` = 1881L,
`1922` = 1922L, `1952` = 1952L, `1971` = 1971L, `1984` = 1984L,
`2019` = 2019L, `2039` = 2039L, `2075` = 2075L, `2106` = 2106L,
`2135` = 2135L, `2181` = 2181L, `2206` = 2206L, `2227` = 2227L,
`2238` = 2238L, `2273` = 2273L, `2293` = 2293L, `2325` = 2325L,
`2366` = 2366L, `2391` = 2391L, `2436` = 2436L, `2461` = 2461L,
`2483` = 2483L, `2493` = 2493L), class = "omit"), row.names = c(1L,
2L, 3L, 4L, 5L, 7L), class = "data.frame")
I have built 9 regression models per forecast horizon (t+1, t+5 and t+22) and I am using the predict function to make my forecasts. I have coded this in an R loop, where I also try to assign each forecast to a matrix. My code is the following:
EUR/GBP_SocialMediaCount`)
EURGBP_HAR_RVt22_News_train <- lm(data.estimateI am trying to calculate realized volatility forecasts using a rolling window forecast. My aim is to use the first 500 observations to forecast the 501st observations, then shift the window forward one step using observations 2 to 501 to predict the 502nd observation. I want this to repeat until I have a complete pseudo out-of-sample forecast.
My df contains 2411 observations of 23 variables, here is small example:
Date
EUR/GBP_RV t+1
EUR/GBP_RV
EUR/GBP_RV_5
EUR/GBP_RV_22
2012-02-13
0.004019947
0.004467109
0.004995980
0.005150602
2012-02-14
0.004077322
0.004019947
0.004704742
0.005099209
2012-02-15
0.004666244
0.004077322
0.004564522
0.005020790
2012-02-16
0.004582351
0.004666244
0.004532930
0.005011078
2012-02-17
0.003951071
0.004582351
0.004362595
0.004999634
2012-02-21
0.005549329
0.004824547
0.004467109
0.004954358
The head of the df can be reproduced with
structure(list(Date = structure(c(15383, 15384, 15385, 15386,
15387, 15391), class = "Date"), `EUR/GBP_RV t+1,t+22` = c(0.00437808494654599,
0.00439764887779732, 0.00441997330738947, 0.00437799055732722,
0.00435021150904479, 0.00434881306458859), `EUR/GBP_RGV t+1,t+22` = c(0.00310674728131117,
0.00311502965608506, 0.00313756204195853, 0.00312923997431178,
0.00310846773074243, 0.00309755540903969), `EUR/GBP_RBV t+1,t+22` = c(0.00304961980133602,
0.00306866297401415, 0.00307794319983677, 0.00302801249035602,
0.00300946121851254, 0.00302272755554915), `EUR/GBP_RV t+1,t+5` = c(0.00425938711995146,
0.00442030721926592, 0.00471470868108043, 0.00487869292442023,
0.00476849421943949, 0.0046067439660438), `EUR/GBP_RGV t+1,t+5` = c(0.00287718093809447,
0.00311308998902836, 0.00344398536439729, 0.00376911066284235,
0.00377425759242542, 0.00353909902900148), `EUR/GBP_RBV t+1,t+5` = c(0.00313771439501486,
0.00310626895475871, 0.0031789431316576, 0.00305962424370556,
0.00288671182187571, 0.00291630955829613), `EUR/GBP_RV t+1` = c(0.00401994700051122,
0.00407732180013827, 0.00466624428620966, 0.00458235106134663,
0.00395107145155152, 0.00554932910921084), `EUR/GBP_RGV t+1` = c(0.00280067842079775,
0.00275522601341373, 0.00296142025653418, 0.00320716195737542,
0.00266141804235125, 0.00440970289025837), `EUR/GBP_RBV t+1` = c(0.00288377777753365,
0.00300554199386584, 0.00360608177982326, 0.00327292734850446,
0.0029202430753471, 0.00336891287836027), `EUR/GBP_RV` = c(0.00446710941914797,
0.00401994700051122, 0.00407732180013827, 0.00466624428620966,
0.00458235106134663, 0.00482454749708351), `EUR/GBP_RV_5` = c(0.00499598016427624,
0.00470474196716823, 0.00456452150727461, 0.00453292965488229,
0.00436259471347075, 0.00442030721926592), `EUR/GBP_RV_22` = c(0.00515060219897263,
0.00509920878086075, 0.00502079002092667, 0.00501107755050095,
0.00499963428727425, 0.00495435807685843), `EUR/GBP_RBV` = c(0.00324667045338159,
0.00288377777753365, 0.00300554199386584, 0.00360608177982326,
0.00327292734850446, 0.00272655057625291), `EUR/GBP_RBV_5` = c(0.0034985439252634,
0.00318731350301598, 0.00319529774619179, 0.0032799330165155,
0.00320299987062176, 0.00310626895475871), `EUR/GBP_RBV_22` = c(0.0036581887941976,
0.00362298829344015, 0.00355498498935768, 0.0035465419934449,
0.00355752455210586, 0.00351669973034298), `EUR/GBP_RGV` = c(0.00306825643155514,
0.00280067842079775, 0.00275522601341373, 0.00296142025653418,
0.00320716195737542, 0.00398022367546721), `EUR/GBP_RGV_5` = c(0.00353290218424469,
0.00345194162523714, 0.00325362896209417, 0.00312087362386985,
0.00295854861593525, 0.00311308998902836), `EUR/GBP_RGV_22` = c(0.00359974659692405,
0.00356342531619103, 0.00352224165959556, 0.00351722666683608,
0.00349184335907274, 0.00346394410318992), `EUR/GBP_TotalCount` = structure(c(-0.179518680545716,
-0.0757259172924681, 0.333514120677483, 0.759064450015801, -0.419724789788948,
-0.360414639358521), .Dim = c(6L, 1L)), `EUR/GBP_BloombergCount` = structure(c(-0.701694550941621,
-0.669811381311996, -0.574161872423118, -0.644304845608295, -0.784590791978649,
-0.631551577756444), .Dim = c(6L, 1L)), `EUR/GBP_SocialMediaCount` = structure(c(-1.68861759789696,
-1.66829994393287, -1.5910928588693, -1.59515638966212, -1.6967446594826,
-1.63172816679749), .Dim = c(6L, 1L)), `EUR/GBP_NewsCount` = structure(c(0.76560533722738,
0.879161625683434, 1.33717198912285, 1.90306082659552, 0.487392430510049,
0.487392430510049), .Dim = c(6L, 1L))), na.action = structure(c(`6` = 6L,
`38` = 38L, `74` = 74L, `101` = 101L, `140` = 140L, `165` = 165L,
`189` = 189L, `197` = 197L, `236` = 236L, `256` = 256L, `323` = 323L,
`351` = 351L, `393` = 393L, `423` = 423L, `442` = 442L, `455` = 455L,
`490` = 490L, `510` = 510L, `551` = 551L, `576` = 576L, `605` = 605L,
`646` = 646L, `676` = 676L, `696` = 696L, `708` = 708L, `742` = 742L,
`762` = 762L, `793` = 793L, `829` = 829L, `858` = 858L, `904` = 904L,
`929` = 929L, `950` = 950L, `961` = 961L, `996` = 996L, `1016` = 1016L,
`1089` = 1089L, `1114` = 1114L, `1159` = 1159L, `1184` = 1184L,
`1207` = 1207L, `1216` = 1216L, `1238` = 1238L, `1243` = 1243L,
`1253` = 1253L, `1278` = 1278L, `1315` = 1315L, `1346` = 1346L,
`1372` = 1372L, `1416` = 1416L, `1441` = 1441L, `1473` = 1473L,
`1532` = 1532L, `1599` = 1599L, `1626` = 1626L, `1669` = 1669L,
`1694` = 1694L, `1718` = 1718L, `1726` = 1726L, `1766` = 1766L,
`1786` = 1786L, `1827` = 1827L, `1853` = 1853L, `1881` = 1881L,
`1922` = 1922L, `1952` = 1952L, `1971` = 1971L, `1984` = 1984L,
`2019` = 2019L, `2039` = 2039L, `2075` = 2075L, `2106` = 2106L,
`2135` = 2135L, `2181` = 2181L, `2206` = 2206L, `2227` = 2227L,
`2238` = 2238L, `2273` = 2273L, `2293` = 2293L, `2325` = 2325L,
`2366` = 2366L, `2391` = 2391L, `2436` = 2436L, `2461` = 2461L,
`2483` = 2483L, `2493` = 2493L), class = "omit"), row.names = c(1L,
2L, 3L, 4L, 5L, 7L), class = "data.frame")
I have built 9 regression models per forecast horizon (t+1, t+5 and t+22) and I am using the predict function to make my forecasts. I have coded this in an R loop, where I also try to assign each forecast to a matrix. My code is the following:
EUR/GBP_RV t+1,t+22`~data.estimateI am trying to calculate realized volatility forecasts using a rolling window forecast. My aim is to use the first 500 observations to forecast the 501st observations, then shift the window forward one step using observations 2 to 501 to predict the 502nd observation. I want this to repeat until I have a complete pseudo out-of-sample forecast.
My df contains 2411 observations of 23 variables, here is small example:
Date
EUR/GBP_RV t+1
EUR/GBP_RV
EUR/GBP_RV_5
EUR/GBP_RV_22
2012-02-13
0.004019947
0.004467109
0.004995980
0.005150602
2012-02-14
0.004077322
0.004019947
0.004704742
0.005099209
2012-02-15
0.004666244
0.004077322
0.004564522
0.005020790
2012-02-16
0.004582351
0.004666244
0.004532930
0.005011078
2012-02-17
0.003951071
0.004582351
0.004362595
0.004999634
2012-02-21
0.005549329
0.004824547
0.004467109
0.004954358
The head of the df can be reproduced with
structure(list(Date = structure(c(15383, 15384, 15385, 15386,
15387, 15391), class = "Date"), `EUR/GBP_RV t+1,t+22` = c(0.00437808494654599,
0.00439764887779732, 0.00441997330738947, 0.00437799055732722,
0.00435021150904479, 0.00434881306458859), `EUR/GBP_RGV t+1,t+22` = c(0.00310674728131117,
0.00311502965608506, 0.00313756204195853, 0.00312923997431178,
0.00310846773074243, 0.00309755540903969), `EUR/GBP_RBV t+1,t+22` = c(0.00304961980133602,
0.00306866297401415, 0.00307794319983677, 0.00302801249035602,
0.00300946121851254, 0.00302272755554915), `EUR/GBP_RV t+1,t+5` = c(0.00425938711995146,
0.00442030721926592, 0.00471470868108043, 0.00487869292442023,
0.00476849421943949, 0.0046067439660438), `EUR/GBP_RGV t+1,t+5` = c(0.00287718093809447,
0.00311308998902836, 0.00344398536439729, 0.00376911066284235,
0.00377425759242542, 0.00353909902900148), `EUR/GBP_RBV t+1,t+5` = c(0.00313771439501486,
0.00310626895475871, 0.0031789431316576, 0.00305962424370556,
0.00288671182187571, 0.00291630955829613), `EUR/GBP_RV t+1` = c(0.00401994700051122,
0.00407732180013827, 0.00466624428620966, 0.00458235106134663,
0.00395107145155152, 0.00554932910921084), `EUR/GBP_RGV t+1` = c(0.00280067842079775,
0.00275522601341373, 0.00296142025653418, 0.00320716195737542,
0.00266141804235125, 0.00440970289025837), `EUR/GBP_RBV t+1` = c(0.00288377777753365,
0.00300554199386584, 0.00360608177982326, 0.00327292734850446,
0.0029202430753471, 0.00336891287836027), `EUR/GBP_RV` = c(0.00446710941914797,
0.00401994700051122, 0.00407732180013827, 0.00466624428620966,
0.00458235106134663, 0.00482454749708351), `EUR/GBP_RV_5` = c(0.00499598016427624,
0.00470474196716823, 0.00456452150727461, 0.00453292965488229,
0.00436259471347075, 0.00442030721926592), `EUR/GBP_RV_22` = c(0.00515060219897263,
0.00509920878086075, 0.00502079002092667, 0.00501107755050095,
0.00499963428727425, 0.00495435807685843), `EUR/GBP_RBV` = c(0.00324667045338159,
0.00288377777753365, 0.00300554199386584, 0.00360608177982326,
0.00327292734850446, 0.00272655057625291), `EUR/GBP_RBV_5` = c(0.0034985439252634,
0.00318731350301598, 0.00319529774619179, 0.0032799330165155,
0.00320299987062176, 0.00310626895475871), `EUR/GBP_RBV_22` = c(0.0036581887941976,
0.00362298829344015, 0.00355498498935768, 0.0035465419934449,
0.00355752455210586, 0.00351669973034298), `EUR/GBP_RGV` = c(0.00306825643155514,
0.00280067842079775, 0.00275522601341373, 0.00296142025653418,
0.00320716195737542, 0.00398022367546721), `EUR/GBP_RGV_5` = c(0.00353290218424469,
0.00345194162523714, 0.00325362896209417, 0.00312087362386985,
0.00295854861593525, 0.00311308998902836), `EUR/GBP_RGV_22` = c(0.00359974659692405,
0.00356342531619103, 0.00352224165959556, 0.00351722666683608,
0.00349184335907274, 0.00346394410318992), `EUR/GBP_TotalCount` = structure(c(-0.179518680545716,
-0.0757259172924681, 0.333514120677483, 0.759064450015801, -0.419724789788948,
-0.360414639358521), .Dim = c(6L, 1L)), `EUR/GBP_BloombergCount` = structure(c(-0.701694550941621,
-0.669811381311996, -0.574161872423118, -0.644304845608295, -0.784590791978649,
-0.631551577756444), .Dim = c(6L, 1L)), `EUR/GBP_SocialMediaCount` = structure(c(-1.68861759789696,
-1.66829994393287, -1.5910928588693, -1.59515638966212, -1.6967446594826,
-1.63172816679749), .Dim = c(6L, 1L)), `EUR/GBP_NewsCount` = structure(c(0.76560533722738,
0.879161625683434, 1.33717198912285, 1.90306082659552, 0.487392430510049,
0.487392430510049), .Dim = c(6L, 1L))), na.action = structure(c(`6` = 6L,
`38` = 38L, `74` = 74L, `101` = 101L, `140` = 140L, `165` = 165L,
`189` = 189L, `197` = 197L, `236` = 236L, `256` = 256L, `323` = 323L,
`351` = 351L, `393` = 393L, `423` = 423L, `442` = 442L, `455` = 455L,
`490` = 490L, `510` = 510L, `551` = 551L, `576` = 576L, `605` = 605L,
`646` = 646L, `676` = 676L, `696` = 696L, `708` = 708L, `742` = 742L,
`762` = 762L, `793` = 793L, `829` = 829L, `858` = 858L, `904` = 904L,
`929` = 929L, `950` = 950L, `961` = 961L, `996` = 996L, `1016` = 1016L,
`1089` = 1089L, `1114` = 1114L, `1159` = 1159L, `1184` = 1184L,
`1207` = 1207L, `1216` = 1216L, `1238` = 1238L, `1243` = 1243L,
`1253` = 1253L, `1278` = 1278L, `1315` = 1315L, `1346` = 1346L,
`1372` = 1372L, `1416` = 1416L, `1441` = 1441L, `1473` = 1473L,
`1532` = 1532L, `1599` = 1599L, `1626` = 1626L, `1669` = 1669L,
`1694` = 1694L, `1718` = 1718L, `1726` = 1726L, `1766` = 1766L,
`1786` = 1786L, `1827` = 1827L, `1853` = 1853L, `1881` = 1881L,
`1922` = 1922L, `1952` = 1952L, `1971` = 1971L, `1984` = 1984L,
`2019` = 2019L, `2039` = 2039L, `2075` = 2075L, `2106` = 2106L,
`2135` = 2135L, `2181` = 2181L, `2206` = 2206L, `2227` = 2227L,
`2238` = 2238L, `2273` = 2273L, `2293` = 2293L, `2325` = 2325L,
`2366` = 2366L, `2391` = 2391L, `2436` = 2436L, `2461` = 2461L,
`2483` = 2483L, `2493` = 2493L), class = "omit"), row.names = c(1L,
2L, 3L, 4L, 5L, 7L), class = "data.frame")
I have built 9 regression models per forecast horizon (t+1, t+5 and t+22) and I am using the predict function to make my forecasts. I have coded this in an R loop, where I also try to assign each forecast to a matrix. My code is the following:
EUR/GBP_RV`+data.estimateI am trying to calculate realized volatility forecasts using a rolling window forecast. My aim is to use the first 500 observations to forecast the 501st observations, then shift the window forward one step using observations 2 to 501 to predict the 502nd observation. I want this to repeat until I have a complete pseudo out-of-sample forecast.
My df contains 2411 observations of 23 variables, here is small example:
Date
EUR/GBP_RV t+1
EUR/GBP_RV
EUR/GBP_RV_5
EUR/GBP_RV_22
2012-02-13
0.004019947
0.004467109
0.004995980
0.005150602
2012-02-14
0.004077322
0.004019947
0.004704742
0.005099209
2012-02-15
0.004666244
0.004077322
0.004564522
0.005020790
2012-02-16
0.004582351
0.004666244
0.004532930
0.005011078
2012-02-17
0.003951071
0.004582351
0.004362595
0.004999634
2012-02-21
0.005549329
0.004824547
0.004467109
0.004954358
The head of the df can be reproduced with
structure(list(Date = structure(c(15383, 15384, 15385, 15386,
15387, 15391), class = "Date"), `EUR/GBP_RV t+1,t+22` = c(0.00437808494654599,
0.00439764887779732, 0.00441997330738947, 0.00437799055732722,
0.00435021150904479, 0.00434881306458859), `EUR/GBP_RGV t+1,t+22` = c(0.00310674728131117,
0.00311502965608506, 0.00313756204195853, 0.00312923997431178,
0.00310846773074243, 0.00309755540903969), `EUR/GBP_RBV t+1,t+22` = c(0.00304961980133602,
0.00306866297401415, 0.00307794319983677, 0.00302801249035602,
0.00300946121851254, 0.00302272755554915), `EUR/GBP_RV t+1,t+5` = c(0.00425938711995146,
0.00442030721926592, 0.00471470868108043, 0.00487869292442023,
0.00476849421943949, 0.0046067439660438), `EUR/GBP_RGV t+1,t+5` = c(0.00287718093809447,
0.00311308998902836, 0.00344398536439729, 0.00376911066284235,
0.00377425759242542, 0.00353909902900148), `EUR/GBP_RBV t+1,t+5` = c(0.00313771439501486,
0.00310626895475871, 0.0031789431316576, 0.00305962424370556,
0.00288671182187571, 0.00291630955829613), `EUR/GBP_RV t+1` = c(0.00401994700051122,
0.00407732180013827, 0.00466624428620966, 0.00458235106134663,
0.00395107145155152, 0.00554932910921084), `EUR/GBP_RGV t+1` = c(0.00280067842079775,
0.00275522601341373, 0.00296142025653418, 0.00320716195737542,
0.00266141804235125, 0.00440970289025837), `EUR/GBP_RBV t+1` = c(0.00288377777753365,
0.00300554199386584, 0.00360608177982326, 0.00327292734850446,
0.0029202430753471, 0.00336891287836027), `EUR/GBP_RV` = c(0.00446710941914797,
0.00401994700051122, 0.00407732180013827, 0.00466624428620966,
0.00458235106134663, 0.00482454749708351), `EUR/GBP_RV_5` = c(0.00499598016427624,
0.00470474196716823, 0.00456452150727461, 0.00453292965488229,
0.00436259471347075, 0.00442030721926592), `EUR/GBP_RV_22` = c(0.00515060219897263,
0.00509920878086075, 0.00502079002092667, 0.00501107755050095,
0.00499963428727425, 0.00495435807685843), `EUR/GBP_RBV` = c(0.00324667045338159,
0.00288377777753365, 0.00300554199386584, 0.00360608177982326,
0.00327292734850446, 0.00272655057625291), `EUR/GBP_RBV_5` = c(0.0034985439252634,
0.00318731350301598, 0.00319529774619179, 0.0032799330165155,
0.00320299987062176, 0.00310626895475871), `EUR/GBP_RBV_22` = c(0.0036581887941976,
0.00362298829344015, 0.00355498498935768, 0.0035465419934449,
0.00355752455210586, 0.00351669973034298), `EUR/GBP_RGV` = c(0.00306825643155514,
0.00280067842079775, 0.00275522601341373, 0.00296142025653418,
0.00320716195737542, 0.00398022367546721), `EUR/GBP_RGV_5` = c(0.00353290218424469,
0.00345194162523714, 0.00325362896209417, 0.00312087362386985,
0.00295854861593525, 0.00311308998902836), `EUR/GBP_RGV_22` = c(0.00359974659692405,
0.00356342531619103, 0.00352224165959556, 0.00351722666683608,
0.00349184335907274, 0.00346394410318992), `EUR/GBP_TotalCount` = structure(c(-0.179518680545716,
-0.0757259172924681, 0.333514120677483, 0.759064450015801, -0.419724789788948,
-0.360414639358521), .Dim = c(6L, 1L)), `EUR/GBP_BloombergCount` = structure(c(-0.701694550941621,
-0.669811381311996, -0.574161872423118, -0.644304845608295, -0.784590791978649,
-0.631551577756444), .Dim = c(6L, 1L)), `EUR/GBP_SocialMediaCount` = structure(c(-1.68861759789696,
-1.66829994393287, -1.5910928588693, -1.59515638966212, -1.6967446594826,
-1.63172816679749), .Dim = c(6L, 1L)), `EUR/GBP_NewsCount` = structure(c(0.76560533722738,
0.879161625683434, 1.33717198912285, 1.90306082659552, 0.487392430510049,
0.487392430510049), .Dim = c(6L, 1L))), na.action = structure(c(`6` = 6L,
`38` = 38L, `74` = 74L, `101` = 101L, `140` = 140L, `165` = 165L,
`189` = 189L, `197` = 197L, `236` = 236L, `256` = 256L, `323` = 323L,
`351` = 351L, `393` = 393L, `423` = 423L, `442` = 442L, `455` = 455L,
`490` = 490L, `510` = 510L, `551` = 551L, `576` = 576L, `605` = 605L,
`646` = 646L, `676` = 676L, `696` = 696L, `708` = 708L, `742` = 742L,
`762` = 762L, `793` = 793L, `829` = 829L, `858` = 858L, `904` = 904L,
`929` = 929L, `950` = 950L, `961` = 961L, `996` = 996L, `1016` = 1016L,
`1089` = 1089L, `1114` = 1114L, `1159` = 1159L, `1184` = 1184L,
`1207` = 1207L, `1216` = 1216L, `1238` = 1238L, `1243` = 1243L,
`1253` = 1253L, `1278` = 1278L, `1315` = 1315L, `1346` = 1346L,
`1372` = 1372L, `1416` = 1416L, `1441` = 1441L, `1473` = 1473L,
`1532` = 1532L, `1599` = 1599L, `1626` = 1626L, `1669` = 1669L,
`1694` = 1694L, `1718` = 1718L, `1726` = 1726L, `1766` = 1766L,
`1786` = 1786L, `1827` = 1827L, `1853` = 1853L, `1881` = 1881L,
`1922` = 1922L, `1952` = 1952L, `1971` = 1971L, `1984` = 1984L,
`2019` = 2019L, `2039` = 2039L, `2075` = 2075L, `2106` = 2106L,
`2135` = 2135L, `2181` = 2181L, `2206` = 2206L, `2227` = 2227L,
`2238` = 2238L, `2273` = 2273L, `2293` = 2293L, `2325` = 2325L,
`2366` = 2366L, `2391` = 2391L, `2436` = 2436L, `2461` = 2461L,
`2483` = 2483L, `2493` = 2493L), class = "omit"), row.names = c(1L,
2L, 3L, 4L, 5L, 7L), class = "data.frame")
I have built 9 regression models per forecast horizon (t+1, t+5 and t+22) and I am using the predict function to make my forecasts. I have coded this in an R loop, where I also try to assign each forecast to a matrix. My code is the following:
EUR/GBP_RV_5`+data.estimateI am trying to calculate realized volatility forecasts using a rolling window forecast. My aim is to use the first 500 observations to forecast the 501st observations, then shift the window forward one step using observations 2 to 501 to predict the 502nd observation. I want this to repeat until I have a complete pseudo out-of-sample forecast.
My df contains 2411 observations of 23 variables, here is small example:
Date
EUR/GBP_RV t+1
EUR/GBP_RV
EUR/GBP_RV_5
EUR/GBP_RV_22
2012-02-13
0.004019947
0.004467109
0.004995980
0.005150602
2012-02-14
0.004077322
0.004019947
0.004704742
0.005099209
2012-02-15
0.004666244
0.004077322
0.004564522
0.005020790
2012-02-16
0.004582351
0.004666244
0.004532930
0.005011078
2012-02-17
0.003951071
0.004582351
0.004362595
0.004999634
2012-02-21
0.005549329
0.004824547
0.004467109
0.004954358
The head of the df can be reproduced with
structure(list(Date = structure(c(15383, 15384, 15385, 15386,
15387, 15391), class = "Date"), `EUR/GBP_RV t+1,t+22` = c(0.00437808494654599,
0.00439764887779732, 0.00441997330738947, 0.00437799055732722,
0.00435021150904479, 0.00434881306458859), `EUR/GBP_RGV t+1,t+22` = c(0.00310674728131117,
0.00311502965608506, 0.00313756204195853, 0.00312923997431178,
0.00310846773074243, 0.00309755540903969), `EUR/GBP_RBV t+1,t+22` = c(0.00304961980133602,
0.00306866297401415, 0.00307794319983677, 0.00302801249035602,
0.00300946121851254, 0.00302272755554915), `EUR/GBP_RV t+1,t+5` = c(0.00425938711995146,
0.00442030721926592, 0.00471470868108043, 0.00487869292442023,
0.00476849421943949, 0.0046067439660438), `EUR/GBP_RGV t+1,t+5` = c(0.00287718093809447,
0.00311308998902836, 0.00344398536439729, 0.00376911066284235,
0.00377425759242542, 0.00353909902900148), `EUR/GBP_RBV t+1,t+5` = c(0.00313771439501486,
0.00310626895475871, 0.0031789431316576, 0.00305962424370556,
0.00288671182187571, 0.00291630955829613), `EUR/GBP_RV t+1` = c(0.00401994700051122,
0.00407732180013827, 0.00466624428620966, 0.00458235106134663,
0.00395107145155152, 0.00554932910921084), `EUR/GBP_RGV t+1` = c(0.00280067842079775,
0.00275522601341373, 0.00296142025653418, 0.00320716195737542,
0.00266141804235125, 0.00440970289025837), `EUR/GBP_RBV t+1` = c(0.00288377777753365,
0.00300554199386584, 0.00360608177982326, 0.00327292734850446,
0.0029202430753471, 0.00336891287836027), `EUR/GBP_RV` = c(0.00446710941914797,
0.00401994700051122, 0.00407732180013827, 0.00466624428620966,
0.00458235106134663, 0.00482454749708351), `EUR/GBP_RV_5` = c(0.00499598016427624,
0.00470474196716823, 0.00456452150727461, 0.00453292965488229,
0.00436259471347075, 0.00442030721926592), `EUR/GBP_RV_22` = c(0.00515060219897263,
0.00509920878086075, 0.00502079002092667, 0.00501107755050095,
0.00499963428727425, 0.00495435807685843), `EUR/GBP_RBV` = c(0.00324667045338159,
0.00288377777753365, 0.00300554199386584, 0.00360608177982326,
0.00327292734850446, 0.00272655057625291), `EUR/GBP_RBV_5` = c(0.0034985439252634,
0.00318731350301598, 0.00319529774619179, 0.0032799330165155,
0.00320299987062176, 0.00310626895475871), `EUR/GBP_RBV_22` = c(0.0036581887941976,
0.00362298829344015, 0.00355498498935768, 0.0035465419934449,
0.00355752455210586, 0.00351669973034298), `EUR/GBP_RGV` = c(0.00306825643155514,
0.00280067842079775, 0.00275522601341373, 0.00296142025653418,
0.00320716195737542, 0.00398022367546721), `EUR/GBP_RGV_5` = c(0.00353290218424469,
0.00345194162523714, 0.00325362896209417, 0.00312087362386985,
0.00295854861593525, 0.00311308998902836), `EUR/GBP_RGV_22` = c(0.00359974659692405,
0.00356342531619103, 0.00352224165959556, 0.00351722666683608,
0.00349184335907274, 0.00346394410318992), `EUR/GBP_TotalCount` = structure(c(-0.179518680545716,
-0.0757259172924681, 0.333514120677483, 0.759064450015801, -0.419724789788948,
-0.360414639358521), .Dim = c(6L, 1L)), `EUR/GBP_BloombergCount` = structure(c(-0.701694550941621,
-0.669811381311996, -0.574161872423118, -0.644304845608295, -0.784590791978649,
-0.631551577756444), .Dim = c(6L, 1L)), `EUR/GBP_SocialMediaCount` = structure(c(-1.68861759789696,
-1.66829994393287, -1.5910928588693, -1.59515638966212, -1.6967446594826,
-1.63172816679749), .Dim = c(6L, 1L)), `EUR/GBP_NewsCount` = structure(c(0.76560533722738,
0.879161625683434, 1.33717198912285, 1.90306082659552, 0.487392430510049,
0.487392430510049), .Dim = c(6L, 1L))), na.action = structure(c(`6` = 6L,
`38` = 38L, `74` = 74L, `101` = 101L, `140` = 140L, `165` = 165L,
`189` = 189L, `197` = 197L, `236` = 236L, `256` = 256L, `323` = 323L,
`351` = 351L, `393` = 393L, `423` = 423L, `442` = 442L, `455` = 455L,
`490` = 490L, `510` = 510L, `551` = 551L, `576` = 576L, `605` = 605L,
`646` = 646L, `676` = 676L, `696` = 696L, `708` = 708L, `742` = 742L,
`762` = 762L, `793` = 793L, `829` = 829L, `858` = 858L, `904` = 904L,
`929` = 929L, `950` = 950L, `961` = 961L, `996` = 996L, `1016` = 1016L,
`1089` = 1089L, `1114` = 1114L, `1159` = 1159L, `1184` = 1184L,
`1207` = 1207L, `1216` = 1216L, `1238` = 1238L, `1243` = 1243L,
`1253` = 1253L, `1278` = 1278L, `1315` = 1315L, `1346` = 1346L,
`1372` = 1372L, `1416` = 1416L, `1441` = 1441L, `1473` = 1473L,
`1532` = 1532L, `1599` = 1599L, `1626` = 1626L, `1669` = 1669L,
`1694` = 1694L, `1718` = 1718L, `1726` = 1726L, `1766` = 1766L,
`1786` = 1786L, `1827` = 1827L, `1853` = 1853L, `1881` = 1881L,
`1922` = 1922L, `1952` = 1952L, `1971` = 1971L, `1984` = 1984L,
`2019` = 2019L, `2039` = 2039L, `2075` = 2075L, `2106` = 2106L,
`2135` = 2135L, `2181` = 2181L, `2206` = 2206L, `2227` = 2227L,
`2238` = 2238L, `2273` = 2273L, `2293` = 2293L, `2325` = 2325L,
`2366` = 2366L, `2391` = 2391L, `2436` = 2436L, `2461` = 2461L,
`2483` = 2483L, `2493` = 2493L), class = "omit"), row.names = c(1L,
2L, 3L, 4L, 5L, 7L), class = "data.frame")
I have built 9 regression models per forecast horizon (t+1, t+5 and t+22) and I am using the predict function to make my forecasts. I have coded this in an R loop, where I also try to assign each forecast to a matrix. My code is the following:
EUR/GBP_RV_22`+data.estimateI am trying to calculate realized volatility forecasts using a rolling window forecast. My aim is to use the first 500 observations to forecast the 501st observations, then shift the window forward one step using observations 2 to 501 to predict the 502nd observation. I want this to repeat until I have a complete pseudo out-of-sample forecast.
My df contains 2411 observations of 23 variables, here is small example:
Date
EUR/GBP_RV t+1
EUR/GBP_RV
EUR/GBP_RV_5
EUR/GBP_RV_22
2012-02-13
0.004019947
0.004467109
0.004995980
0.005150602
2012-02-14
0.004077322
0.004019947
0.004704742
0.005099209
2012-02-15
0.004666244
0.004077322
0.004564522
0.005020790
2012-02-16
0.004582351
0.004666244
0.004532930
0.005011078
2012-02-17
0.003951071
0.004582351
0.004362595
0.004999634
2012-02-21
0.005549329
0.004824547
0.004467109
0.004954358
The head of the df can be reproduced with
structure(list(Date = structure(c(15383, 15384, 15385, 15386,
15387, 15391), class = "Date"), `EUR/GBP_RV t+1,t+22` = c(0.00437808494654599,
0.00439764887779732, 0.00441997330738947, 0.00437799055732722,
0.00435021150904479, 0.00434881306458859), `EUR/GBP_RGV t+1,t+22` = c(0.00310674728131117,
0.00311502965608506, 0.00313756204195853, 0.00312923997431178,
0.00310846773074243, 0.00309755540903969), `EUR/GBP_RBV t+1,t+22` = c(0.00304961980133602,
0.00306866297401415, 0.00307794319983677, 0.00302801249035602,
0.00300946121851254, 0.00302272755554915), `EUR/GBP_RV t+1,t+5` = c(0.00425938711995146,
0.00442030721926592, 0.00471470868108043, 0.00487869292442023,
0.00476849421943949, 0.0046067439660438), `EUR/GBP_RGV t+1,t+5` = c(0.00287718093809447,
0.00311308998902836, 0.00344398536439729, 0.00376911066284235,
0.00377425759242542, 0.00353909902900148), `EUR/GBP_RBV t+1,t+5` = c(0.00313771439501486,
0.00310626895475871, 0.0031789431316576, 0.00305962424370556,
0.00288671182187571, 0.00291630955829613), `EUR/GBP_RV t+1` = c(0.00401994700051122,
0.00407732180013827, 0.00466624428620966, 0.00458235106134663,
0.00395107145155152, 0.00554932910921084), `EUR/GBP_RGV t+1` = c(0.00280067842079775,
0.00275522601341373, 0.00296142025653418, 0.00320716195737542,
0.00266141804235125, 0.00440970289025837), `EUR/GBP_RBV t+1` = c(0.00288377777753365,
0.00300554199386584, 0.00360608177982326, 0.00327292734850446,
0.0029202430753471, 0.00336891287836027), `EUR/GBP_RV` = c(0.00446710941914797,
0.00401994700051122, 0.00407732180013827, 0.00466624428620966,
0.00458235106134663, 0.00482454749708351), `EUR/GBP_RV_5` = c(0.00499598016427624,
0.00470474196716823, 0.00456452150727461, 0.00453292965488229,
0.00436259471347075, 0.00442030721926592), `EUR/GBP_RV_22` = c(0.00515060219897263,
0.00509920878086075, 0.00502079002092667, 0.00501107755050095,
0.00499963428727425, 0.00495435807685843), `EUR/GBP_RBV` = c(0.00324667045338159,
0.00288377777753365, 0.00300554199386584, 0.00360608177982326,
0.00327292734850446, 0.00272655057625291), `EUR/GBP_RBV_5` = c(0.0034985439252634,
0.00318731350301598, 0.00319529774619179, 0.0032799330165155,
0.00320299987062176, 0.00310626895475871), `EUR/GBP_RBV_22` = c(0.0036581887941976,
0.00362298829344015, 0.00355498498935768, 0.0035465419934449,
0.00355752455210586, 0.00351669973034298), `EUR/GBP_RGV` = c(0.00306825643155514,
0.00280067842079775, 0.00275522601341373, 0.00296142025653418,
0.00320716195737542, 0.00398022367546721), `EUR/GBP_RGV_5` = c(0.00353290218424469,
0.00345194162523714, 0.00325362896209417, 0.00312087362386985,
0.00295854861593525, 0.00311308998902836), `EUR/GBP_RGV_22` = c(0.00359974659692405,
0.00356342531619103, 0.00352224165959556, 0.00351722666683608,
0.00349184335907274, 0.00346394410318992), `EUR/GBP_TotalCount` = structure(c(-0.179518680545716,
-0.0757259172924681, 0.333514120677483, 0.759064450015801, -0.419724789788948,
-0.360414639358521), .Dim = c(6L, 1L)), `EUR/GBP_BloombergCount` = structure(c(-0.701694550941621,
-0.669811381311996, -0.574161872423118, -0.644304845608295, -0.784590791978649,
-0.631551577756444), .Dim = c(6L, 1L)), `EUR/GBP_SocialMediaCount` = structure(c(-1.68861759789696,
-1.66829994393287, -1.5910928588693, -1.59515638966212, -1.6967446594826,
-1.63172816679749), .Dim = c(6L, 1L)), `EUR/GBP_NewsCount` = structure(c(0.76560533722738,
0.879161625683434, 1.33717198912285, 1.90306082659552, 0.487392430510049,
0.487392430510049), .Dim = c(6L, 1L))), na.action = structure(c(`6` = 6L,
`38` = 38L, `74` = 74L, `101` = 101L, `140` = 140L, `165` = 165L,
`189` = 189L, `197` = 197L, `236` = 236L, `256` = 256L, `323` = 323L,
`351` = 351L, `393` = 393L, `423` = 423L, `442` = 442L, `455` = 455L,
`490` = 490L, `510` = 510L, `551` = 551L, `576` = 576L, `605` = 605L,
`646` = 646L, `676` = 676L, `696` = 696L, `708` = 708L, `742` = 742L,
`762` = 762L, `793` = 793L, `829` = 829L, `858` = 858L, `904` = 904L,
`929` = 929L, `950` = 950L, `961` = 961L, `996` = 996L, `1016` = 1016L,
`1089` = 1089L, `1114` = 1114L, `1159` = 1159L, `1184` = 1184L,
`1207` = 1207L, `1216` = 1216L, `1238` = 1238L, `1243` = 1243L,
`1253` = 1253L, `1278` = 1278L, `1315` = 1315L, `1346` = 1346L,
`1372` = 1372L, `1416` = 1416L, `1441` = 1441L, `1473` = 1473L,
`1532` = 1532L, `1599` = 1599L, `1626` = 1626L, `1669` = 1669L,
`1694` = 1694L, `1718` = 1718L, `1726` = 1726L, `1766` = 1766L,
`1786` = 1786L, `1827` = 1827L, `1853` = 1853L, `1881` = 1881L,
`1922` = 1922L, `1952` = 1952L, `1971` = 1971L, `1984` = 1984L,
`2019` = 2019L, `2039` = 2039L, `2075` = 2075L, `2106` = 2106L,
`2135` = 2135L, `2181` = 2181L, `2206` = 2206L, `2227` = 2227L,
`2238` = 2238L, `2273` = 2273L, `2293` = 2293L, `2325` = 2325L,
`2366` = 2366L, `2391` = 2391L, `2436` = 2436L, `2461` = 2461L,
`2483` = 2483L, `2493` = 2493L), class = "omit"), row.names = c(1L,
2L, 3L, 4L, 5L, 7L), class = "data.frame")
I have built 9 regression models per forecast horizon (t+1, t+5 and t+22) and I am using the predict function to make my forecasts. I have coded this in an R loop, where I also try to assign each forecast to a matrix. My code is the following:
EUR/GBP_NewsCount`)
EURGBP_forecast.22[, 1 ] <- predict( EURGBP_HAR_RVt22_train, newdata=data.forecast )
EURGBP_forecast.22[, 2 ] <- predict( EURGBP_HAR_RVt22_NT_train, newdata=data.forecast )
EURGBP_forecast.22[, 3 ] <- predict( EURGBP_HAR_RVBt22_train, newdata=data.forecast )
EURGBP_forecast.22[, 4 ] <- predict( EURGBP_HAR_RVBt22_NT_train, newdata=data.forecast )
EURGBP_forecast.22[, 5 ] <- predict( EURGBP_HAR_RVGt22_train, newdata=data.forecast )
EURGBP_forecast.22[, 6 ] <- predict( EURGBP_HAR_RVGt22_NT_train, newdata=data.forecast )
EURGBP_forecast.22[, 7 ] <- predict( EURGBP_HAR_RVt22_Bloomberg_train, newdata=data.forecast )
EURGBP_forecast.22[, 8 ] <- predict( EURGBP_HAR_RVt22_SocialMedia_train, newdata=data.forecast )
EURGBP_forecast.22[, 9 ] <- predict( EURGBP_HAR_RVt22_News_train, newdata=data.forecast )
EURGBP_actuals.22[, 1] <- data.forecastI am trying to calculate realized volatility forecasts using a rolling window forecast. My aim is to use the first 500 observations to forecast the 501st observations, then shift the window forward one step using observations 2 to 501 to predict the 502nd observation. I want this to repeat until I have a complete pseudo out-of-sample forecast.
My df contains 2411 observations of 23 variables, here is small example:
Date
EUR/GBP_RV t+1
EUR/GBP_RV
EUR/GBP_RV_5
EUR/GBP_RV_22
2012-02-13
0.004019947
0.004467109
0.004995980
0.005150602
2012-02-14
0.004077322
0.004019947
0.004704742
0.005099209
2012-02-15
0.004666244
0.004077322
0.004564522
0.005020790
2012-02-16
0.004582351
0.004666244
0.004532930
0.005011078
2012-02-17
0.003951071
0.004582351
0.004362595
0.004999634
2012-02-21
0.005549329
0.004824547
0.004467109
0.004954358
The head of the df can be reproduced with
structure(list(Date = structure(c(15383, 15384, 15385, 15386,
15387, 15391), class = "Date"), `EUR/GBP_RV t+1,t+22` = c(0.00437808494654599,
0.00439764887779732, 0.00441997330738947, 0.00437799055732722,
0.00435021150904479, 0.00434881306458859), `EUR/GBP_RGV t+1,t+22` = c(0.00310674728131117,
0.00311502965608506, 0.00313756204195853, 0.00312923997431178,
0.00310846773074243, 0.00309755540903969), `EUR/GBP_RBV t+1,t+22` = c(0.00304961980133602,
0.00306866297401415, 0.00307794319983677, 0.00302801249035602,
0.00300946121851254, 0.00302272755554915), `EUR/GBP_RV t+1,t+5` = c(0.00425938711995146,
0.00442030721926592, 0.00471470868108043, 0.00487869292442023,
0.00476849421943949, 0.0046067439660438), `EUR/GBP_RGV t+1,t+5` = c(0.00287718093809447,
0.00311308998902836, 0.00344398536439729, 0.00376911066284235,
0.00377425759242542, 0.00353909902900148), `EUR/GBP_RBV t+1,t+5` = c(0.00313771439501486,
0.00310626895475871, 0.0031789431316576, 0.00305962424370556,
0.00288671182187571, 0.00291630955829613), `EUR/GBP_RV t+1` = c(0.00401994700051122,
0.00407732180013827, 0.00466624428620966, 0.00458235106134663,
0.00395107145155152, 0.00554932910921084), `EUR/GBP_RGV t+1` = c(0.00280067842079775,
0.00275522601341373, 0.00296142025653418, 0.00320716195737542,
0.00266141804235125, 0.00440970289025837), `EUR/GBP_RBV t+1` = c(0.00288377777753365,
0.00300554199386584, 0.00360608177982326, 0.00327292734850446,
0.0029202430753471, 0.00336891287836027), `EUR/GBP_RV` = c(0.00446710941914797,
0.00401994700051122, 0.00407732180013827, 0.00466624428620966,
0.00458235106134663, 0.00482454749708351), `EUR/GBP_RV_5` = c(0.00499598016427624,
0.00470474196716823, 0.00456452150727461, 0.00453292965488229,
0.00436259471347075, 0.00442030721926592), `EUR/GBP_RV_22` = c(0.00515060219897263,
0.00509920878086075, 0.00502079002092667, 0.00501107755050095,
0.00499963428727425, 0.00495435807685843), `EUR/GBP_RBV` = c(0.00324667045338159,
0.00288377777753365, 0.00300554199386584, 0.00360608177982326,
0.00327292734850446, 0.00272655057625291), `EUR/GBP_RBV_5` = c(0.0034985439252634,
0.00318731350301598, 0.00319529774619179, 0.0032799330165155,
0.00320299987062176, 0.00310626895475871), `EUR/GBP_RBV_22` = c(0.0036581887941976,
0.00362298829344015, 0.00355498498935768, 0.0035465419934449,
0.00355752455210586, 0.00351669973034298), `EUR/GBP_RGV` = c(0.00306825643155514,
0.00280067842079775, 0.00275522601341373, 0.00296142025653418,
0.00320716195737542, 0.00398022367546721), `EUR/GBP_RGV_5` = c(0.00353290218424469,
0.00345194162523714, 0.00325362896209417, 0.00312087362386985,
0.00295854861593525, 0.00311308998902836), `EUR/GBP_RGV_22` = c(0.00359974659692405,
0.00356342531619103, 0.00352224165959556, 0.00351722666683608,
0.00349184335907274, 0.00346394410318992), `EUR/GBP_TotalCount` = structure(c(-0.179518680545716,
-0.0757259172924681, 0.333514120677483, 0.759064450015801, -0.419724789788948,
-0.360414639358521), .Dim = c(6L, 1L)), `EUR/GBP_BloombergCount` = structure(c(-0.701694550941621,
-0.669811381311996, -0.574161872423118, -0.644304845608295, -0.784590791978649,
-0.631551577756444), .Dim = c(6L, 1L)), `EUR/GBP_SocialMediaCount` = structure(c(-1.68861759789696,
-1.66829994393287, -1.5910928588693, -1.59515638966212, -1.6967446594826,
-1.63172816679749), .Dim = c(6L, 1L)), `EUR/GBP_NewsCount` = structure(c(0.76560533722738,
0.879161625683434, 1.33717198912285, 1.90306082659552, 0.487392430510049,
0.487392430510049), .Dim = c(6L, 1L))), na.action = structure(c(`6` = 6L,
`38` = 38L, `74` = 74L, `101` = 101L, `140` = 140L, `165` = 165L,
`189` = 189L, `197` = 197L, `236` = 236L, `256` = 256L, `323` = 323L,
`351` = 351L, `393` = 393L, `423` = 423L, `442` = 442L, `455` = 455L,
`490` = 490L, `510` = 510L, `551` = 551L, `576` = 576L, `605` = 605L,
`646` = 646L, `676` = 676L, `696` = 696L, `708` = 708L, `742` = 742L,
`762` = 762L, `793` = 793L, `829` = 829L, `858` = 858L, `904` = 904L,
`929` = 929L, `950` = 950L, `961` = 961L, `996` = 996L, `1016` = 1016L,
`1089` = 1089L, `1114` = 1114L, `1159` = 1159L, `1184` = 1184L,
`1207` = 1207L, `1216` = 1216L, `1238` = 1238L, `1243` = 1243L,
`1253` = 1253L, `1278` = 1278L, `1315` = 1315L, `1346` = 1346L,
`1372` = 1372L, `1416` = 1416L, `1441` = 1441L, `1473` = 1473L,
`1532` = 1532L, `1599` = 1599L, `1626` = 1626L, `1669` = 1669L,
`1694` = 1694L, `1718` = 1718L, `1726` = 1726L, `1766` = 1766L,
`1786` = 1786L, `1827` = 1827L, `1853` = 1853L, `1881` = 1881L,
`1922` = 1922L, `1952` = 1952L, `1971` = 1971L, `1984` = 1984L,
`2019` = 2019L, `2039` = 2039L, `2075` = 2075L, `2106` = 2106L,
`2135` = 2135L, `2181` = 2181L, `2206` = 2206L, `2227` = 2227L,
`2238` = 2238L, `2273` = 2273L, `2293` = 2293L, `2325` = 2325L,
`2366` = 2366L, `2391` = 2391L, `2436` = 2436L, `2461` = 2461L,
`2483` = 2483L, `2493` = 2493L), class = "omit"), row.names = c(1L,
2L, 3L, 4L, 5L, 7L), class = "data.frame")
I have built 9 regression models per forecast horizon (t+1, t+5 and t+22) and I am using the predict function to make my forecasts. I have coded this in an R loop, where I also try to assign each forecast to a matrix. My code is the following:
EUR/GBP_RV t+1,t+22`
}
This returns the following error:
Error in EURGBP_forecast.1[, 1] <- predict(EURGBP_HAR_RV_train, newdata = data.forecast) :
number of items to replace is not a multiple of replacement length
In addition: Warning message:
'newdata' had 1 row but variables found have 500 rows
I do not know what my mistake is, and I would appreciate any type of assistance.
Please let me know if I need to provide any more information.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
我想我会设置几个这样的函数:
首先是一个生成模型的函数,给定一个 data.estimate 和一个horizon。这将返回
lm
对象列表然后是一个返回预测的函数,给定模型列表和
data.forecast
框架然后,您可以使用类似的方法循环遍历
number_of_forecasts
,每次返回单行 tibbles 的列表。然后可以使用 bind_rows 将所得的 tibbles 绑定在一起
现在,
f1
、f5
和f22
中的每一个都是包含预测的 tibbles从第 501 行到原始帧的末尾。如果您愿意,您可以轻松添加日期。f1
如下所示:I think I would set up a couple of functions like this:
First a function to generate the models, given a
data.estimate
and ahorizon
. This returns a list oflm
objectsThen a function to return the predictions, given a list of models, and a
data.forecast
frameThen, you can use something like this to loop through the
number_of_forecasts
, each time returning a list of single row tibbles.The resulting set of tibbles, can then be binded together using bind_rows
Now, each of
f1
,f5
, andf22
is a tibble with the forecasts from row 501 to the end of original frame.. You could add the date easily if you wanted to. Here is whatf1
looks like: