# You must have Robyn installed and some models stored as JSON files
if (FALSE) {
# Import and recreate the models
files <- c("BrandA.json", "BrandB.json", "BrandC.json", "BrandN.json")
models <- lapply(files, function(x) Robyn::robyn_recreate(x))
names(models) <- gsub("\\.json", "", files)
# Calculate cross-brand optimal allocation
res <- robyn_xmodels(
models,
cores = 10,
start_dates = "2023-01-01",
end_dates = "2023-12-01"
)
print(res)
res$summary
}
if (FALSE) {
# Calculate cross-brand optimal allocation
res <- robyn_xchannels(
models,
start_dates = "2023-01-01",
end_dates = "2023-12-01"
)
}
Run the code above in your browser using DataLab