Skip to content
Submodule
causalis.shared.rct_design.mde

mde

Submodule causalis.shared.rct_design.mde with no child pages and 1 documented members.

Functions

Jump directly into the documented functions for this page.

1 items
function
causalis.shared.rct_design.mde.calculate_mde

calculate_mde

Calculate the Minimum Detectable Effect (MDE) for conversion or continuous data_contracts.

Parameters

sample_sizeint or tuple of int

Total sample size or a tuple of (control_size, treatment_size). If a single integer is provided, the sample will be split according to the ratio parameter.

baseline_ratefloat, optional

Baseline conversion rate (for conversion data_contracts) or baseline mean (for continuous data_contracts). Required for conversion data_contracts.

variancefloat or tuple of float, optional

Variance of the data_contracts. For conversion data_contracts, this is calculated from the baseline rate if not provided. For continuous data_contracts, this parameter is required. Can be a single float (assumed same for both groups) or a tuple of (control_variance, treatment_variance).

alphafloat, default 0.05

Significance level (Type I error rate).

powerfloat, default 0.8

Statistical power (1 - Type II error rate).

data_typestr, default ‘conversion’

Type of data_contracts. Either ‘conversion’ for binary/conversion data_contracts or ‘continuous’ for continuous data_contracts.

ratiofloat, default 0.5

Ratio of the sample allocated to the control group if sample_size is a single integer.

Returns

Dict[str, Any]

A dictionary containing: - ‘mde’: The minimum detectable effect (absolute) - ‘mde_relative’: The minimum detectable effect as a percentage of the baseline (relative) - ‘parameters’: The parameters used for the calculation

Examples

Calculate MDE for conversion data_contracts with 1000 total sample size and 10% baseline conversion rate

Calculate MDE for continuous data_contracts with 500 samples in each group and variance of 4

Notes

For conversion data_contracts, the MDE is calculated using the formula: MDE = (z_α/2 + z_β) * sqrt((p1*(1-p1)/n1) + (p2*(1-p2)/n2))

For continuous data_contracts, the MDE is calculated using the formula: MDE = (z_α/2 + z_β) * sqrt((σ1²/n1) + (σ2²/n2))

where:

  • z_α/2 is the critical value for significance level α

  • z_β is the critical value for power

  • p1 and p2 are the conversion rates in the control and treatment groups

  • σ1² and σ2² are the variances in the control and treatment groups

  • n1 and n2 are the sample sizes in the control and treatment groups

Canonical target

causalis.shared.rct_design.mde.calculate_mde

Sections

ParametersReturnsNotesExamples
Link to this symbol