Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Allow running non inferiority tests #203

Open
Gabrielcidral1 opened this issue Dec 12, 2024 · 0 comments
Open

Allow running non inferiority tests #203

Gabrielcidral1 opened this issue Dec 12, 2024 · 0 comments
Labels
enhancement New feature or request

Comments

@Gabrielcidral1
Copy link
Collaborator

Gabrielcidral1 commented Dec 12, 2024

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

@Gabrielcidral1 Gabrielcidral1 added the enhancement New feature or request label Dec 12, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

No branches or pull requests

1 participant