Some reproducible code to have in your environment a time series and a possible forecast:
packages <- c('forecast',
'robets',
'quantmod')
lapply(X = packages,
FUN = function(package){
if (!require(package = package,
character.only = TRUE))
{
install.packages(pkgs = package,
repos = "https://cloud.r-project.org")
library(package = package,
character.only = TRUE)
} else {
library(package = package,
character.only = TRUE)
}
})
getSymbols('GLD')
adjustOHLC(GLD)
GLD %>%
Cl() %>%
log() %>%
robets() %>%
forecast(h = 250, level = seq(from = 51, to = 99, by = 1)) %>%
autoplot()
I would like to draw a random sample from the distribution of forecasted values, in order to possibly fit a probability density function. The value returned by forecast
has some slots which might be useful, like $mean
and $residuals
, but I don't know how to draw such a sample. Furthermore, aside from this specific example, I would like to understand the theoretical procedure to get a density from a forecast with expected value and prediction interval only.