Skip to content

Commit

Permalink
feat: include time units used on adstock plots
Browse files Browse the repository at this point in the history
  • Loading branch information
laresbernardo committed May 20, 2022
1 parent d3f15e7 commit 7d46fe4
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 12 deletions.
4 changes: 2 additions & 2 deletions R/R/plots.R
Original file line number Diff line number Diff line change
Expand Up @@ -342,7 +342,7 @@ robyn_onepagers <- function(InputCollect, OutputCollect, select_model = NULL, qu
scale_y_percent(limit = c(0, 1)) +
labs(
title = "Geometric Adstock: Fixed Decay Rate Over Time",
y = NULL, x = NULL
y = sprintf("Thetas [by %s]", InputCollect$intervalType), x = NULL
)
}
if (InputCollect$adstock %in% c("weibull_cdf", "weibull_pdf")) {
Expand All @@ -356,7 +356,7 @@ robyn_onepagers <- function(InputCollect, OutputCollect, select_model = NULL, qu
theme_lares(legend = "none", grid = "Xx") +
labs(
title = paste0("Weibull Adstock ", wb_type, ": Flexible Decay Rate Over Time"),
x = "Time Unit", y = NULL
x = sprintf("Time unit [%ss]", InputCollect$intervalType), y = NULL
)
}

Expand Down
20 changes: 10 additions & 10 deletions R/R/transformation.R
Original file line number Diff line number Diff line change
Expand Up @@ -215,11 +215,11 @@ plot_adstock <- function(plot = TRUE) {
geom_hline(yintercept = 0.5, linetype = "dashed", color = "gray") +
geom_text(aes(x = max(x), y = 0.5, vjust = -0.5, hjust = 1, label = "Halflife"), colour = "gray") +
labs(
title = "Geometric adstock (fixed decay rate)",
title = "Geometric Adstock\n(fixed decay rate)",
subtitle = "Halflife = time until effect reduces to 50%",
x = "time unit",
x = "Time unit",
y = "Media decay accumulated"
)
) + theme_lares(pal = 2)

## plot weibull
weibullCollect <- list()
Expand Down Expand Up @@ -252,11 +252,11 @@ plot_adstock <- function(plot = TRUE) {
geom_hline(yintercept = 0.5, linetype = "dashed", color = "gray") +
geom_text(aes(x = max(x), y = 0.5, vjust = -0.5, hjust = 1, label = "Halflife"), colour = "gray") +
labs(
title = "Weibull adstock CDF vs PDF (flexible decay rate)",
title = "Weibull Adstock CDF vs PDF\n(flexible decay rate)",
subtitle = "Halflife = time until effect reduces to 50%",
x = "time unit",
x = "Time unit",
y = "Media decay accumulated"
)
) + theme_lares(pal = 2)
return(wrap_plots(A = p1, B = p2, design = "ABB"))
}
}
Expand All @@ -279,7 +279,7 @@ plot_saturation <- function(plot = TRUE) {
alphaSamp <- c(0.1, 0.5, 1, 2, 3)
gammaSamp <- c(0.1, 0.3, 0.5, 0.7, 0.9)

## plot alphas
## Plot alphas
hillAlphaCollect <- list()
for (i in 1:length(alphaSamp)) {
hillAlphaCollect[[i]] <- data.table(
Expand All @@ -295,9 +295,9 @@ plot_saturation <- function(plot = TRUE) {
labs(
title = "Cost response with hill function",
subtitle = "Alpha changes while gamma = 0.5"
)
) + theme_lares(pal = 2)

## plot gammas
## Plot gammas
hillGammaCollect <- list()
for (i in 1:length(gammaSamp)) {
hillGammaCollect[[i]] <- data.table(
Expand All @@ -313,7 +313,7 @@ plot_saturation <- function(plot = TRUE) {
labs(
title = "Cost response with hill function",
subtitle = "Gamma changes while alpha = 2"
)
) + theme_lares(pal = 2)

return(p1 + p2)
}
Expand Down

0 comments on commit 7d46fe4

Please sign in to comment.