Skip to content

Commit bcd0a13

Browse files
committed
doc: update demo.R
- adapted demo.R to match all new changes - demo.R version bump to 3.12.0 - slight adaption of r&f plot title - package documentation
1 parent 5df9fe5 commit bcd0a13

File tree

5 files changed

+154
-222
lines changed

5 files changed

+154
-222
lines changed

R/R/calibration.R

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -85,7 +85,7 @@ robyn_calibrate <- function(
8585
curve_collect[[i]] <- robyn_calibrate_single_dim(
8686
df_curve = df_curve_i,
8787
curve_type,
88-
force_shape = "c",
88+
force_shape = "c", # assumption: reach saturation is always concave
8989
hp_bounds,
9090
max_trials,
9191
max_iters,
@@ -103,7 +103,8 @@ robyn_calibrate <- function(
103103
geom_point(aes(y = .data$response_cumulated, colour = .data$freq_bucket)) +
104104
geom_line(aes(y = .data$response_pred, colour = .data$freq_bucket), alpha = 0.5) +
105105
labs(
106-
title = "Cumulative reach saturation fitting",
106+
title = "Cumulative reach & frequency saturation fitting",
107+
subtitle = "The dots are input R&F data. The lines are fitted curves.",
107108
x = "cumulative spend",
108109
y = "cumulative reach"
109110
) +

R/R/inputs.R

Lines changed: 13 additions & 38 deletions
Original file line numberDiff line numberDiff line change
@@ -468,39 +468,14 @@ Adstock: {x$adstock}
468468
#' hyperparameters that is inserted into \code{robyn_inputs(hyperparameters = ...)}
469469
#'
470470
#' @section Guide to setup hyperparameters:
471-
#' \enumerate{
472-
#' \item Get correct hyperparameter names:
473-
#' All variables in \code{paid_media_vars} or \code{organic_vars} require hyperprameters
474-
#' and will be transformed by adstock & saturation. Difference between \code{paid_media_vars}
475-
#' and \code{organic_vars} is that \code{paid_media_vars} has spend that
476-
#' needs to be specified in \code{paid_media_spends} specifically. Run \code{hyper_names()}
477-
#' to get correct hyperparameter names. All names in hyperparameters must
478-
#' equal names from \code{hyper_names()}, case sensitive.
479-
#' \item Get guidance for setting hyperparameter bounds:
480-
#' For geometric adstock, use theta, alpha & gamma. For both weibull adstock options,
481-
#' use shape, scale, alpha, gamma.
482-
#' \itemize{
483-
#' \item Theta: In geometric adstock, theta is decay rate. guideline for usual media genre:
484-
#' TV c(0.3, 0.8), OOH/Print/Radio c(0.1, 0.4), digital c(0, 0.3)
485-
#' \item Shape: In weibull adstock, shape controls the decay shape. Recommended c(0.0001, 2).
486-
#' The larger, the more S-shape. The smaller, the more L-shape. Channel-type specific
487-
#' values still to be investigated
488-
#' \item Scale: In weibull adstock, scale controls the decay inflexion point. Very conservative
489-
#' recommended bounce c(0, 0.1), because scale can increase adstocking half-life greatly.
490-
#' Channel-type specific values still to be investigated
491-
#' \item Gamma: In s-curve transformation with hill function, gamma controls the inflexion point.
492-
#' Recommended bounce c(0.3, 1). The larger the gamma, the later the inflection point
493-
#' in the response curve
494-
#' }
495-
#' \item Set each hyperparameter bounds. They either contains two values e.g. c(0, 0.5),
496-
#' or only one value (in which case you've "fixed" that hyperparameter)
497-
#' }
471+
#' See section "Hyperparameter interpretation & recommendation" in demo
472+
#' https://github.com/facebookexperimental/Robyn/blob/main/demo/demo.R
498473
#'
499474
#' @section Helper plots:
500475
#' \describe{
501-
#' \item{plot_adstock}{Get adstock transformation example plot,
476+
#' \item{plot_adstock(TRUE)}{Get adstock transformation example plot,
502477
#' helping you understand geometric/theta and weibull/shape/scale transformation}
503-
#' \item{plot_saturation}{Get saturation curve transformation example plot,
478+
#' \item{plot_saturation(TRUE)}{Get saturation curve transformation example plot,
504479
#' helping you understand hill/alpha/gamma transformation}
505480
#' }
506481
#'
@@ -511,13 +486,13 @@ Adstock: {x$adstock}
511486
#' @param all_vars Used to check the penalties inputs, especially for refreshing models.
512487
#' @examples
513488
#' \donttest{
514-
#' media <- c("facebook_S", "print_S", "tv_S")
489+
#' media <- c("facebook_I", "print_S", "tv_S")
515490
#' hyper_names(adstock = "geometric", all_media = media)
516491
#'
517492
#' hyperparameters <- list(
518-
#' facebook_S_alphas = c(0.5, 3), # example bounds for alpha
519-
#' facebook_S_gammas = c(0.3, 1), # example bounds for gamma
520-
#' facebook_S_thetas = c(0, 0.3), # example bounds for theta
493+
#' facebook_I_alphas = c(0.5, 3), # example bounds for alpha
494+
#' facebook_I_gammas = c(0.3, 1), # example bounds for gamma
495+
#' facebook_I_thetas = c(0, 0.3), # example bounds for theta
521496
#' print_S_alphas = c(0.5, 3),
522497
#' print_S_gammas = c(0.3, 1),
523498
#' print_S_thetas = c(0.1, 0.4),
@@ -527,13 +502,13 @@ Adstock: {x$adstock}
527502
#' )
528503
#'
529504
#' # Define hyper_names for weibull adstock
530-
#' hyper_names(adstock = "weibull", all_media = media)
505+
#' hyper_names(adstock = "weibull_pdf", all_media = media)
531506
#'
532507
#' hyperparameters <- list(
533-
#' facebook_S_alphas = c(0.5, 3), # example bounds for alpha
534-
#' facebook_S_gammas = c(0.3, 1), # example bounds for gamma
535-
#' facebook_S_shapes = c(0.0001, 2), # example bounds for shape
536-
#' facebook_S_scales = c(0, 0.1), # example bounds for scale
508+
#' facebook_I_alphas = c(0.5, 3), # example bounds for alpha
509+
#' facebook_I_gammas = c(0.3, 1), # example bounds for gamma
510+
#' facebook_I_shapes = c(0.0001, 2), # example bounds for shape
511+
#' facebook_I_scales = c(0, 0.1), # example bounds for scale
537512
#' print_S_alphas = c(0.5, 3),
538513
#' print_S_gammas = c(0.3, 1),
539514
#' print_S_shapes = c(0.0001, 2),

R/man/hyper_names.Rd

Lines changed: 13 additions & 38 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

R/man/set_default_hyppar.Rd

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

0 commit comments

Comments
 (0)