Skip to content

Commit

Permalink
Merge pull request #148 from microsoft/mitokic/11122023/hts-resid-fix
Browse files Browse the repository at this point in the history
fix residual issue in hts
  • Loading branch information
mitokic authored Nov 29, 2023
2 parents 5102209 + 40916e2 commit 37e6fb8
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 1 deletion.
2 changes: 1 addition & 1 deletion DESCRIPTION
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
Package: finnts
Title: Microsoft Finance Time Series Forecasting Framework
Version: 0.3.0.9006
Version: 0.3.0.9007
Authors@R:
c(person(given = "Mike",
family = "Tokic",
Expand Down
6 changes: 6 additions & 0 deletions R/hierarchy.R
Original file line number Diff line number Diff line change
Expand Up @@ -423,6 +423,9 @@ reconcile_hierarchical_data <- function(run_info,
Forecast_Adj = ifelse((abs(Target) + 1) * residual_multiplier < abs(Forecast), (Target + 1) * residual_multiplier, Forecast), # prevent hts recon issues
Residual = Target - Forecast_Adj
) %>%
dplyr::rowwise() %>%
dplyr::mutate(Residual = ifelse(Residual == 0, 0.0001, Residual)) %>%
dplyr::ungroup() %>%
dplyr::select(Combo, Date, Train_Test_ID, Residual) %>%
tidyr::pivot_wider(names_from = Combo, values_from = Residual) %>%
dplyr::select(-Date, -Train_Test_ID) %>%
Expand Down Expand Up @@ -640,6 +643,9 @@ reconcile_hierarchical_data <- function(run_info,
Forecast_Adj = ifelse((abs(Target) + 1) * residual_multiplier < abs(Forecast), (Target + 1) * residual_multiplier, Forecast), # prevent hts recon issues
Residual = Target - Forecast_Adj
) %>%
dplyr::rowwise() %>%
dplyr::mutate(Residual = ifelse(Residual == 0, 0.0001, Residual)) %>%
dplyr::ungroup() %>%
dplyr::select(Combo, Date, Train_Test_ID, Residual) %>%
tidyr::pivot_wider(names_from = Combo, values_from = Residual) %>%
tibble::as_tibble() %>%
Expand Down

0 comments on commit 37e6fb8

Please sign in to comment.