Synthetic datasets#

Generators return data together with known population quantities and are intended for examples, tests, and method studies.

Each generator accepts a sample size, random seed, and dataframe backend. Its return value contains the generated frame and a mapping of known population quantities.

Three functions serve the navigation program that the examples share.

function

what it returns

navigation_data

the make_nonlinear_bounded draw, with the columns under the program’s names

navigation_protocol

the StudyProtocol of the one-decision program

longitudinal_navigation_protocol

the StudyProtocol of the two-decision program

Eight names serve the subscription-retailer program of the offers tutorial.

name

what it holds

make_sequential_offers

a long panel of three weekly offers, with the logged probabilities and the exact truth. policy= draws a deployment-check cohort

offers_truth

the exact week-4 share under each plan, and each contrast with no offers

offers_protocol

the StudyProtocol of the campaign

win_back, win_back_then_ship

the two dynamic rules, as functions of the week’s engagement

OFFER_PLANS, OFFER_LEVELS, OFFER_WEEKS

the five plans by name, the three offer levels, and the number of weekly sends

make_sequential_offers returns a long panel and takes the keyword policy. It is not in GENERATORS, which holds generators of one wide frame with the columns Y and A.

Seven names serve the pricing tutorial of the same program.

name

what it holds

make_sequential_pricing

a wide frame of three monthly renewal prices with engagement, the renewal, and the revenue, with the exact truth

pricing_truth

the exact mean renewal and revenue under each plan, each effect against the engine’s own prices, and the decomposition of the effect by path

pricing_protocol

the StudyProtocol of the pricing question

price_rise

a plan that raises each price by a factor and keeps the engine’s price where the raised price would leave the band

PRICE_PLANS, PRICE_BANDS, PRICE_NODES

the three plans by name, the price band of each month, and the number of monthly prices

make_sequential_pricing is not in GENERATORS either. Its columns are usage, engaged_1, price_1, engaged_2, price_2, engaged_3, price_3, renewed, and revenue.

cleverly.datasets.available

Names of the bundled data-generating processes.

cleverly.datasets.make_linear_ate

Generate point-treatment data with a constant additive effect.

cleverly.datasets.make_nonlinear_ate

Nonlinear nuisance functions and a heterogeneous effect.

cleverly.datasets.make_nonlinear_bounded

Generate a bounded outcome with nonlinear nuisance functions.

cleverly.datasets.make_binary_outcome

A binary outcome with known risks, risk ratio and odds ratio.

cleverly.datasets.make_multi_arm

A three-armed confounded process with known counterfactual means.

cleverly.datasets.make_heterogeneous

A sample whose treated and control populations have genuinely different effects.

cleverly.datasets.make_instrument

Instrument-inflation: a covariate that predicts treatment but not the outcome.

cleverly.datasets.make_shift_dose

A confounded continuous dose with known means under each declared shift.

cleverly.datasets.make_missing_outcome

Missing outcomes, with a missingness mechanism that depends on treatment.

cleverly.datasets.make_missing_outcome_binary

A binary outcome with outcomes missing at random given (A, W).

cleverly.datasets.make_missing_outcome_bounded

Missing outcomes on the known support (0, 1), with a nonlinear outcome mean.

cleverly.datasets.make_cde

Controlled direct effect: the effect of A with Z held fixed.

cleverly.datasets.make_clustered

Clustered data with an unobserved shared effect modifying the treatment effect.

cleverly.datasets.make_biased_sample

A sample selected with known, unequal probabilities from a known population.

cleverly.datasets.make_weak_overlap

A practical positivity violation.

cleverly.datasets.make_longitudinal

Two time points, a binary outcome and (optionally) monotone censoring.

cleverly.datasets.make_longitudinal_survival

Two time points, an absorbing event at each, and monotone censoring.

cleverly.datasets.make_longitudinal_repeated

Three time points, a repeated binary outcome at each, and monotone censoring.

cleverly.datasets.make_longitudinal_competing

Two time points, two competing absorbing causes at each, monotone censoring.

cleverly.datasets.make_longitudinal_weighted

A biased sample of make_longitudinal(), with the design weights that undo it.

cleverly.datasets.make_point_survival

A baseline treatment, a discrete-time event, and dropout at the visits.

cleverly.datasets.point_survival_truth

The exact truth of make_point_survival() under an intervention on \(A\).

cleverly.datasets.navigation_data

Draw the point-treatment program data, with the columns under the program's names.

cleverly.datasets.navigation_protocol

Return the protocol for the standard navigation offer in the tutorial program.

cleverly.datasets.longitudinal_navigation_protocol

Return the protocol for navigation offered at two decisions after discharge.

cleverly.datasets.make_sequential_offers

Draw a weekly-offer campaign as a long panel, with the exact truth of its plans.

cleverly.datasets.offers_truth

Return the exact week-4 full-price share under each plan, and each contrast with no offers.

cleverly.datasets.offers_protocol

Return the protocol of the weekly-offer campaign.

cleverly.datasets.win_back

Return the win-back offer: the discount for a customer who is not engaged, else nothing.

cleverly.datasets.win_back_then_ship

Return the win-back-then-ship offer: the discount if not engaged, else free shipping.

cleverly.datasets.make_sequential_pricing

Draw three monthly renewal prices and the renewal, with the exact truth of the plans.

cleverly.datasets.pricing_truth

Return the exact mean renewal and revenue under each plan, and the effect of each plan.

cleverly.datasets.pricing_protocol

Return the protocol of the monthly renewal-price program.

cleverly.datasets.price_rise

Return the plan that raises each price by factor and keeps the price in the band.