Liking cljdoc? Tell your friends :D

org.replikativ.marketing.decision

Decisions from a fitted posterior: future response paths, paired plan comparisons and concave, constant-weekly-budget allocation.

Every function takes the built model and a posterior (from inference/fit or io/read!) and evaluates future plans after the model's training history, including the adstock carryover of past spend.

Decisions from a fitted posterior: future response paths, paired plan
comparisons and concave, constant-weekly-budget allocation.

Every function takes the built model and a posterior (from `inference/fit`
or `io/read!`) and evaluates future plans after the model's training
history, including the adstock carryover of past spend.
raw docstring

allocateclj

(allocate model
          posterior
          {:keys [budget horizon controls lower upper tolerance max-iterations
                  max-draws]
           :or {tolerance 1.0E-6 max-iterations 500}})

Maximize posterior expected response with a weekly budget and channel bounds. This objective is concave for this model. Returns a projected-gradient residual in budget fractions and target-scaled response units, plus :converged?; reaching the iteration limit is never reported as success. Internal value/gradient normalization makes stopping and line search independent of currency units.

Options: :budget (per period, required), :horizon (periods, required), :controls (one row per horizon period), :lower/:upper per-channel weekly bounds (default 0 and budget), :tolerance (1e-6), :max-iterations (500) and :max-draws, which thins the posterior first (see thin); the objective's cost grows linearly with the number of draws.

Maximize posterior expected response with a weekly budget and channel bounds.
This objective is concave for this model. Returns a projected-gradient residual
in budget fractions and target-scaled response units, plus :converged?; reaching
the iteration limit is never reported as success. Internal value/gradient
normalization makes stopping and line search independent of currency units.

Options: `:budget` (per period, required), `:horizon` (periods, required),
`:controls` (one row per horizon period), `:lower`/`:upper` per-channel
weekly bounds (default 0 and budget), `:tolerance` (1e-6), `:max-iterations`
(500) and `:max-draws`, which thins the posterior first (see `thin`); the
objective's cost grows linearly with the number of draws.
sourceraw docstring

allocation-objectiveclj

(allocation-objective model posterior horizon controls)

Expected response and its raster AD gradient for constant weekly budgets. Historical spend is fixed; gradients accumulate only over decision periods.

Expected response and its raster AD gradient for constant weekly budgets.
Historical spend is fixed; gradients accumulate only over decision periods.
sourceraw docstring

compare-plansclj

(compare-plans model posterior baseline candidate)
(compare-plans model posterior baseline candidate {:keys [max-draws]})

Compare future spend plans using paired posterior draws and shared history. Includes l-max-1 zero-spend tail periods; controls in those periods cancel. Results describe uncertainty in conditional mean response, not observation noise. Options: :max-draws thins the posterior first (see thin).

Compare future spend plans using paired posterior draws and shared history.
Includes l-max-1 zero-spend tail periods; controls in those periods cancel.
Results describe uncertainty in conditional mean response, not observation noise.
Options: `:max-draws` thins the posterior first (see `thin`).
sourceraw docstring

plan-responsesclj

(plan-responses model posterior plan)
(plan-responses model posterior plan {:keys [max-draws]})

Posterior weekly conditional-mean response paths for one future spend plan. plan is {:x [[spend per channel] ...] :controls [[control values] ...]} (plus optional :time-index), one row per future period, continuing from the model's training history. Each path covers the plan's periods followed by l-max-1 zero-spend carryover periods, in original target units. :draws holds one path per posterior draw, in chain order. Options: :max-draws thins the posterior first (see thin).

Posterior weekly conditional-mean response paths for one future spend plan.
`plan` is {:x [[spend per channel] ...] :controls [[control values] ...]}
(plus optional :time-index), one row per future period, continuing from the
model's training history. Each path covers the plan's periods followed by
l-max-1 zero-spend carryover periods, in original target units.
`:draws` holds one path per posterior draw, in chain order.
Options: `:max-draws` thins the posterior first (see `thin`).
sourceraw docstring

thinclj

(thin posterior max-draws)

Keep at most max-draws posterior draws, evenly spaced within each chain. Each of the k chains keeps every s-th draw, starting with its first, where s = ceil(chain length / floor(max-draws / k)). Only :chains changes; the selection is deterministic, so repeated runs see the same draws. Returns the posterior unchanged when max-draws is nil.

Keep at most `max-draws` posterior draws, evenly spaced within each chain.
Each of the k chains keeps every s-th draw, starting with its first, where
s = ceil(chain length / floor(max-draws / k)). Only `:chains` changes; the
selection is deterministic, so repeated runs see the same draws. Returns
the posterior unchanged when `max-draws` is nil.
sourceraw docstring

cljdoc builds & hosts documentation for Clojure/Script libraries

Keyboard shortcuts
Ctrl+kJump to recent docs
←Move to previous article
→Move to next article
Ctrl+/Jump to the search field
× close