df=structure(list(X.1 = 1:6, X = c(1L, 1L, 1L, 1L, 1L, 1L), json_data.time.updated = structure(1:6, .Label = c("Jan 19, 2019 15:18:00 UTC",
"Jan 19, 2019 15:19:00 UTC", "Jan 19, 2019 15:51:00 UTC", "Jan 19, 2019 15:52:00 UTC",
"Jan 19, 2019 15:54:00 UTC", "Jan 19, 2019 15:55:00 UTC"), class = "factor"),
json_data.time.updatedISO = structure(1:6, .Label = c("2019-01-19T15:18:00+00:00",
"2019-01-19T15:19:00+00:00", "2019-01-19T15:51:00+00:00",
"2019-01-19T15:52:00+00:00", "2019-01-19T15:54:00+00:00",
"2019-01-19T15:55:00+00:00"), class = "factor"), json_data.time.updateduk = structure(1:6, .Label = c("Jan 19, 2019 at 15:18 GMT",
"Jan 19, 2019 at 15:19 GMT", "Jan 19, 2019 at 15:51 GMT",
"Jan 19, 2019 at 15:52 GMT", "Jan 19, 2019 at 15:54 GMT",
"Jan 19, 2019 at 15:55 GMT"), class = "factor"), code = structure(c(1L,
1L, 1L, 1L, 1L, 1L), .Label = "USD", class = "factor"), rate = structure(c(2L,
3L, 6L, 1L, 5L, 4L), .Label = c("3,735.3200", "3,735.7750",
"3,735.9150", "3,736.0750", "3,736.7717", "3,736.9100"), class = "factor"),
description = structure(c(1L, 1L, 1L, 1L, 1L, 1L), .Label = "United States Dollar", class = "factor"),
rate_float = structure(c(2L, 3L, 6L, 1L, 5L, 4L), .Label = c("3735.32",
"3735.775", "3735.915", "3736.075", "3736.7717", "3736.91"
), class = "factor")), class = "data.frame", row.names = c(NA,
-6L))
-
require(rugarch)
#We can then compute the ARMA(1,1)-GARCH(1,1) model as an example:
spec <- ugarchspec(variance.model = list(model = "sGARCH",
garchOrder = c(1, 1),
submodel = NULL,
external.regressors = NULL,
variance.targeting = FALSE),
mean.model = list(armaOrder = c(1, 1),
external.regressors = NULL,
distribution.model = "norm",
start.pars = list(),
fixed.pars = list()))
garch <- ugarchfit(spec = spec, data = df$rate_float, solver.control = list(trace=0))
ugarchforecast(garch, n.ahead = 5)
I will run the forecast script every 5 minutes from this line of spec <- ugarchspec (variance.model = list (model = "sGARCH
", for example, the script was launched at 10:10, the forecast was made by 5 steps, this result must be written into csv file
then it was launched in 10:15, the forecast was made by 5 steps, then this result must be written into csv file with date mark
then at 10:20 and so on. How to append predictions to one csv with date mark every time when script runs?
output can be so