Abnormal Impact Differential (AID) analysis with ANOVA significance testing for year-over-year event impact measurement.
Project description
aid-analysis
Abnormal Impact Differential (AID) — a difference-in-differences style tool for measuring how much a metric deviated from its normal year-over-year pattern during a specific event window, with a two-way ANOVA significance test included.
Installation
pip install aid-analysis
What it does
Given daily (or other tidy) time-series data for one or more numeric metrics, AID asks:
"How much did my metric change from Period 1 to Period 2 this year, compared to how much it normally changes from Period 1 to Period 2 in a baseline year?"
The answer is a single number in percentage points (the AID), plus a p-value from a two-way ANOVA testing whether that difference is statistically significant.
The formula
$$\text{AID} = 100 \times \left[\left(\frac{\mu_{\text{current}, P_2}}{\mu_{\text{current}, P_1}} - 1\right) - \left(\frac{\mu_{\text{baseline}, P_2}}{\mu_{\text{baseline}, P_1}} - 1\right)\right]$$
A negative AID means the metric performed worse in the current year than prior-year seasonality would predict; positive means better.
Quick start
from aid_analysis import run_analysis, PeriodConfig
cfg = PeriodConfig(
current_year=2026,
baseline_year=2025,
period_1=("01-29", "02-28"), # "before" window, inclusive
period_2=("03-01", "03-31"), # "after" window, inclusive
)
# Single metric
summary = run_analysis("data.csv", metrics="Revenue", config=cfg)
# Multiple metrics
summary = run_analysis(
"data.csv",
metrics=["Transactions", "Count of Users", "Revenue"],
config=cfg,
)
Your CSV just needs a date column and one or more numeric columns.
Input data format
A tidy CSV (or pandas.DataFrame) with:
- a
datecolumn (any parseable date format — you can change the column name viaPeriodConfig(date_col="...")) - one or more numeric metric columns (any names, including names with spaces like
"Count of Users")
Example:
date,Transactions,Revenue
2025-01-29,142,8930.50
2025-01-30,156,9420.00
...
2026-03-31,98,6110.25
Output
Three things:
- A printed report with the means, step-by-step AID calculation, the full ANOVA table, and plain-English interpretation.
- A CSV summary (
aid_summary.csvby default) with one row per metric. - A pandas DataFrame returned from
run_analysis()for further work.
Example summary:
| metric | mean_2026_period_1 | mean_2026_period_2 | mean_2025_period_1 | mean_2025_period_2 | change_2026_pct | change_2025_pct | aid_pp | anova_interaction_pvalue |
|---|---|---|---|---|---|---|---|---|
| Revenue | 8,430.50 | 6,120.75 | 8,200.10 | 8,350.40 | -27.39 | 1.83 | -29.22 | 0.00023 |
Class-based API
For more control over intermediate steps:
from aid_analysis import AbnormalImpactAnalyzer, PeriodConfig
cfg = PeriodConfig(
current_year=2026,
baseline_year=2025,
period_1=("01-29", "02-28"),
period_2=("03-01", "03-31"),
)
analyzer = AbnormalImpactAnalyzer("data.csv", config=cfg)
analyzer.run(metrics=["Revenue", "Transactions"])
analyzer.print_report()
# Access individual results
revenue_result = analyzer.results["Revenue"]
print(revenue_result.delta_pp) # the AID value
print(revenue_result.anova_table) # full ANOVA table
print(revenue_result.anova_interaction_pvalue)
# Get the summary as a DataFrame
df = analyzer.summary_frame()
# Or export to CSV
analyzer.export("my_summary.csv")
How to interpret the results
| AID value | p-value | Meaning |
|---|---|---|
| Large negative | < 0.05 | Real, significant underperformance vs the seasonal baseline |
| Large negative | ≥ 0.05 | Looks like a drop, but could be random noise |
| Large positive | < 0.05 | Real, significant outperformance vs the seasonal baseline |
| Large positive | ≥ 0.05 | Looks like an uplift, but could be random noise |
| Near zero | any | No abnormal impact vs the prior-year pattern |
Requirements
- Python 3.9+
- pandas ≥ 1.5
- numpy ≥ 1.22
- statsmodels ≥ 0.13
License
MIT
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file aid_analysis-0.1.0.tar.gz.
File metadata
- Download URL: aid_analysis-0.1.0.tar.gz
- Upload date:
- Size: 10.6 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.2.0 CPython/3.11.0
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
7588d317c6568470d1f1ec8e4794d3962e575059e6a7203d273e9504adfe534d
|
|
| MD5 |
d5bc32e65b5861c7848ea923455b8e27
|
|
| BLAKE2b-256 |
bfac8559ea61e08a75fed03a098703b38a44381b174ab5a69d2ae04851247625
|
File details
Details for the file aid_analysis-0.1.0-py3-none-any.whl.
File metadata
- Download URL: aid_analysis-0.1.0-py3-none-any.whl
- Upload date:
- Size: 8.6 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.2.0 CPython/3.11.0
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
737e7d9c3fd735021a933fdb31e5a62df46bceae5e15465e3cf89fe986c86bcf
|
|
| MD5 |
f8eeca81dc2b81c218968d2a980714aa
|
|
| BLAKE2b-256 |
ed2038ab8a268cb7b56b54709a0c4ad0f9e30734f0bd7bd0661b0207a215e029
|