Skip to content

Commit

Permalink
fix: get rid og QA decomp not matching linear model message
Browse files Browse the repository at this point in the history
  • Loading branch information
laresbernardo committed Jan 13, 2023
1 parent f1c0ae4 commit 5a036c4
Showing 1 changed file with 18 additions and 18 deletions.
36 changes: 18 additions & 18 deletions R/R/model.R
Original file line number Diff line number Diff line change
Expand Up @@ -1041,24 +1041,24 @@ model_decomp <- function(coefs, dt_modSaturated, y_pred, dt_saturatedImmediate,
regressor * coeff
}, regressor = dt_saturatedCarryover, coeff = coefs_media))

## QA decomp
check_split <- all(round(xDecomp[, names(coefs_media)], 2) ==
round(mediaDecompImmediate + mediaDecompCarryover, 2))
if (!check_split) {
message(paste0(
"Attention for loop ", i,
": immediate & carryover decomp don't sum up to total"
))
}
y_hat <- rowSums(xDecomp, na.rm = TRUE)
errorTerm <- y_hat - y_pred
if (prod(round(y_pred) == round(y_hat)) == 0) {
message(paste0(
"Attention for loop ", i,
": manual decomp is not matching linear model prediction. ",
"Deviation is ", round(mean(errorTerm / y) * 100, 2), "%"
))
}
# ## QA decomp
# check_split <- all(round(xDecomp[, names(coefs_media)], 2) ==
# round(mediaDecompImmediate + mediaDecompCarryover, 2))
# if (!check_split) {
# message(paste0(
# "Attention for loop ", i,
# ": immediate & carryover decomp don't sum up to total"
# ))
# }
# y_hat <- rowSums(xDecomp, na.rm = TRUE)
# errorTerm <- y_hat - y_pred
# if (prod(round(y_pred) == round(y_hat)) == 0) {
# message(paste0(
# "Attention for loop ", i,
# ": manual decomp is not matching linear model prediction. ",
# "Deviation is ", round(mean(errorTerm / y) * 100, 2), "%"
# ))
# }

## Output decomp
y_hat.scaled <- rowSums(abs(xDecomp), na.rm = TRUE)
Expand Down

0 comments on commit 5a036c4

Please sign in to comment.