Skip to content

Allow running non inferiority tests #203

Open
@Gabrielcidral1

Description

@Gabrielcidral1

I would like to be able to run a non inferiority power analysis,
Ho: B - A ≤ -Δ
H1: B - A > -Δ

From what I understand, it's the same as the superiority test, but with the addition of a non inferiority margin (delta).

So I am thinking of achieving it by:

alpha = 0.05
power = 0.8
delta = -3

pw_normal = NormalPowerAnalysis.from_dict(
    {
        "splitter": "clustered",
        "analysis": "clustered_ols",
        "cluster_cols": ["customer_id"],
        "n_simulations": 5,
        "hypothesis": "greater",
        "seed": 3,
        "time_col": "margin_date",
        "target_col": "revenue_value"
    }
)

z_alpha = norm.ppf(1 - alpha)
z_beta = norm.ppf(power)

generator_se = pw_normal.run_average_standard_error(
    df=df,
    experiment_length=range(1,31),
)

mde_results = []
for se, days in generator_se:
    mde = se * (z_alpha + z_beta) + delta
    mde_results.append((days, se, mde))

mde_df = pd.DataFrame(mde_results, columns=["days", "standard_error", "mde"])

I am not sure if this should be implemented as a new capability of the NormalPowerAnalysis, or it we create a new NonInferiorityNormalPowerAnalysis

Metadata

Metadata

Assignees

No one assigned

    Labels

    enhancementNew feature or request

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions