Analysis qa

From vm0-ai/vm0-skills · View interactive version

Analysis qa is an AI agent skill from the GitHub repository vm0-ai/vm0-skills. Quality-check data analysis for joins, metrics, denominators, date ranges, leakage, and statistical pitfalls.

How to use this skill

Skill file

Review Checklist

Select checks relevant to the question, data, and method. Prioritize failures that could change the conclusion or action. Keep calculations and source traces in working notes; include methods, caveats, and supporting detail in the user's requested format where they affect interpretation. Preserve the task's permitted sources and deliverable scope.

Data Foundation

Computation Integrity

Plausibility Assessment

Presentation Quality

Recognizing Common Mistakes

Join Grain and Inflated Totals

What goes wrong: A join changes the row grain, and a measure is then aggregated as if its original grain were preserved. Even a legitimate one-to-many join repeats the parent's measures.

Detection method:

-- Compare row counts before and after the join
SELECT COUNT(*) FROM orders;          -- 1,000 order rows
SELECT COUNT(*) FROM orders o
JOIN line_items li ON o.id = li.order_id;  -- 3,500 may be correct line-item rows

Prevention:

Survivorship Bias

What goes wrong: The analysis only covers entities that still exist, ignoring those that were removed, churned, or failed.

Typical scenarios:

Prevention: Before drawing conclusions, ask: "Who is absent from this dataset, and would their presence change the story?"

Partial Period Comparisons

What goes wrong: A month, week, or quarter that is still in progress gets compared to a completed one.

Typical scenarios:

Prevention: Compare completed or matched elapsed periods where possible. Equal day counts alone do not adjust for weekdays, holidays, exposure, or late-arriving data; disclose those differences. Extrapolation of a partial period is a separate assumption, not an observed total.

Shifting Denominators

What goes wrong: The population used as a denominator changes between periods, making rate comparisons invalid.

Typical scenarios:

Prevention: Lock in consistent definitions across every period being compared. Flag any definition changes.

Averaging Pre-Computed Averages

What goes wrong: Taking the mean of group-level averages ignores differences in group size, producing an incorrect overall figure.

Illustration:

Prevention: Recompute from raw records or combine group sums and the correct denominator counts. An unweighted mean of group means answers a different question (equal weight per group) and equals the pooled mean only under appropriate conditions, such as equal group sizes.

Timezone Inconsistencies

What goes wrong: Different source systems record timestamps in different zones, causing misaligned daily rollups and join mismatches.

Typical scenarios:

Prevention: Parse each source's timezone and align timestamps as instants before joining. Bucket dates in the requested business/reporting timezone, accounting for daylight-saving changes. UTC storage is compatible with local reporting, but UTC calendar days need not match business days. If the source timezone is unknown and boundary records matter, disclose the ambiguity rather than assuming it away.

Circular Segmentation

What goes wrong: Segments are defined using the very outcome being measured, creating tautological findings.

Typical scenarios:

Prevention: Base segment definitions on characteristics measured before the outcome period, not on the outcome itself.

Sanity-Checking Results

Quick Magnitude Tests

| Metric Category | Validation Approach |

|---|---|

| User counts | Cross-reference against known DAU/MAU benchmarks |

| Revenue totals | Reconcile to a comparable revenue control; ARR is a run-rate measure, not interchangeable with period revenue |

| Conversion proportions | 0-100% only when the numerator is a subset of unique eligible trials; event-per-user ratios can exceed 100% |

| Growth rates | Verify the base, sign, and coverage; a zero base is undefined and rapid growth is not itself an error |

| Averages | Verify sums, weights, and denominator grain; inspect the relevant distribution |

| Segment shares | Sum to 100% only for an exhaustive, mutually exclusive partition; explain overlap or missing segments |

Cross-Validation Approaches

  1. Dual calculation: Derive the same metric via two independent query paths and confirm they match
  2. Record-level spot checks: Select a handful of specific entities and manually trace their numbers end to end
  3. Benchmark comparison: Use available, authorized dashboards, finance controls, or prior outputs only when their definitions are comparable
  4. Arithmetic reversal: If total revenue is X and there are N users, does X / N approximate the reported per-user figure?
  5. Micro-slice testing: Filter to a single day, user, or category and confirm the micro-result is sensible

Signals That Demand Investigation

Ensuring Reproducibility

Working Record and Reader-Facing Detail

Retain enough detail internally to reproduce the material calculations. Use the fields below as relevant working notes or as a methods appendix when requested; they are not a mandatory report structure. A concise answer or requested Office artifact need not ship all SQL/code, a separate audit file, or a second deliverable.


## Analysis: [Title]

### Business Question
[The precise question this work answers]

### Sources
- Table: [schema.table_name] (snapshot date: [date])
- Table: [schema.other_table] (snapshot date: [date])
- External file: [filename] (origin: [description])

### Metric and Segment Definitions
- [Metric A]: [Precise calculation formula]
- [Segment X]: [Exact inclusion/exclusion criteria]
- [Time window]: [Start] through [end], [timezone]

### Analytical Approach
1. [First step and its purpose]
2. [Second step]
3. [Third step]

### Assumptions and Known Limitations
- [Assumption and why it holds]
- [Limitation and its potential effect on conclusions]

### Results
1. [Finding with supporting evidence]
2. [Finding with supporting evidence]

### Calculations and Queries
[Relevant workings, source locations, query/code versions, and reconciliation checks]

### Warnings for the Reader
- [Anything the audience should weigh before acting on these results]

Annotating Analytical Code

For SQL or Python that others may reuse:

"""
Title: Monthly Cohort Retention
Author: [Name]
Created: [Date]
Sources: events, users
Last cross-checked: [Date] — matched dashboard within 2%

Objective:
    Build monthly retention cohorts anchored on each user's first event date.

Assumptions:
    - "Active" = at least one recorded event in the calendar month
    - Internal and test accounts excluded (user_type != 'internal')
    - Event timestamps aligned as instants; cohort months use [reporting timezone]

Output:
    Retention grid: rows are cohort months, columns are months since first event.
    Cell values are retention percentages (0-100).
"""

Maintaining an Audit Trail

Use this skill with your AI agent: Open on Skill Issue to copy, download, or add to your library. Works with Claude, ChatGPT, Gemini, Cursor, Windsurf and more.