From 04da868a840f2d789e01e3450529253f63f02150 Mon Sep 17 00:00:00 2001 From: nikosbosse Date: Fri, 15 May 2020 18:05:20 +0200 Subject: [PATCH] changed to work with the mean calculated by forecastHybrid instead of a mean calculated from CI --- R/forecastHybrid_model.R | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/R/forecastHybrid_model.R b/R/forecastHybrid_model.R index 5f5ef42..eb16fc6 100644 --- a/R/forecastHybrid_model.R +++ b/R/forecastHybrid_model.R @@ -73,10 +73,12 @@ forecastHybrid_model <- function(y = NULL, samples = NULL, sample_from_model <- data.frame(t(as.data.frame(sample_from_model$mean))) rownames(sample_from_model) <- NULL }else{ + mean <- as.numeric(prediction$mean) upper <- prediction$upper[, ncol(prediction$upper)] lower <- prediction$lower[, ncol(prediction$lower)] - sample_from_model <- purrr::map2(lower, upper, - ~ rnorm(samples, .x + (.y - .x) / 2, (.y - .x) / 3.92)) + sd <- (upper - lower) / 3.92 + sample_from_model <- purrr::map2(mean, sd, + ~ rnorm(samples, mean = .x, sd = .y)) sample_from_model <- dplyr::bind_cols(sample_from_model) }