Description Usage Arguments Value Examples
This function generates a marketing mix modeling data set based on the parameters given for a Retail case with Revenue as it's response. It uses many different stochastical processes to accomplish this and the dynamics behind them are not available to the user to manipulate.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 | generateRetailData(
fromDate = Sys.Date() - 3 * 365,
toDate = Sys.Date(),
kpi = "units",
sector = "retail",
onlineInsertionNames = c("display", "facebook", "search_branded"),
offlineInsertionNames = c("tv", "radio", "ooh", "print"),
priceNames = c("price_product_a", "price_product_b", "price_product_c"),
distributionNames = c("dist_product_a", "dist_product_b", "dist_product_c"),
weatherNames = c("sunshine", "precipitation", "temperature"),
competitorNames = c("competitor_a", "competitor_b", "competitor_c"),
macroNames = c("cpi", "cci", "gdp"),
eventNames = c("event_a", "event_b")
)
|
fromDate |
the beginning of the time series |
toDate |
the end of the time series |
kpi |
the name of the kpi (response) to simulate |
sector |
the name of the sector to simulate (currently not used) |
onlineInsertionNames |
the names of each online media insertion you wish to use |
offlineInsertionNames |
the names of each offline media insertion you wish to use |
priceNames |
the names of the different product prices |
distributionNames |
the names of the different product distributions |
weatherNames |
the names of the weather data measurements to use |
competitorNames |
the names of each competitor considered |
macroNames |
the names of the macroeconomical factors to simulate |
eventNames |
the names of events to add |
a list of tibble containing each data mentioned
1 2 3 4 5 6 7 8 9 10 11 12 | library(ggplot2)
library(nord)
ret <- generateRetailData()
dates <- ret[["covariates"]][["Macro"]][["date"]]
qplot(dates, ret[["response"]]) + geom_line() + ylim(0, NA)
# entrytocolname <- function(x) a <- ret[["effects"]][[x]] %>% setNames(c(tolower(paste0(x, "_", names(.)))))
entrytocolname <- function(x) tibble::tibble(rowSums(ret[["effects"]][[x]])) %>% setNames(x)
Reduce(dplyr::bind_cols, lapply(names(ret[["effects"]]), entrytocolname)) %>%
dplyr::mutate(date = dates) %>%
tidyr::pivot_longer(-date, names_to = "variable", values_to = "value") %>%
ggplot2::ggplot(ggplot2::aes(x = date, y = value, fill = variable)) +
ggplot2::geom_bar(stat = "identity")
|
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.