# AI-assisted analysis: specify, inspect, verify

AI can propose code, transformations, models, or explanations. The analyst remains responsible for the question and whether the result supports the claim. Fluency, executable code, and agreement between assistants are not independent evidence of validity.

## Three roles, three verification targets

| Role | What to preserve | What to verify |
|---|---|---|
| AI drafts code or prose | Reviewed artifact, consequential suggestions and revisions | Estimand, executable behavior, units, citations and claims |
| AI creates labels or features | Source/output records, model/version, prompt/settings, date, transformations and failures | Independent-label agreement, subgroup errors, stability and measurement validity |
| AI is a prediction system | Frozen evaluation cases, development decisions and settings | Baselines, held-out loss, uncertainty, calibration and transport limits |

If a model runs in the analysis path, cache outputs where permitted and version them as data. Replaying a prompt against a changing service may not reproduce the result. If AI only drafts code, the reviewed code can be a durable artifact independent of future model behavior.

## A practical protocol

1. Write the question, expected input/output, assumptions, and failure case yourself.
2. Give an assistant only permitted information; use synthetic examples or schemas for restricted data. Never place credentials in prompts or notebooks.
3. Inspect code and compare behavior with a reference calculation or known simulation.
4. Record the suggestion, verification, accepted changes, and remaining uncertainty.
5. Reproduce the result in a fresh kernel. Check every reported number and citation.

Tests should probe the scientific computation: null false-positive calibration, group overlap across folds, or a coefficient's response to a unit conversion. A second AI opinion may suggest checks but does not replace them.

## Offline activities

The [annotation audit](../notebooks/ai-annotation-audit.ipynb) uses explicitly fabricated assistant outputs and independent teaching labels. These are **not** measured results from a real AI model. Inspect subgroup errors and paired uncertainty without an account or service call.

The [model comparison](../notebooks/modern-model-comparison.ipynb) compares a linear model with a bagged-tree ensemble on identical evaluation cases. The optional pretrained-feature extension requires documented frozen features; synthetic vectors are not misrepresented as embeddings.

## Saved claim to audit

> “I tried many models and prompts, picked the highest test accuracy, and obtained a small p-value. This proves the model understands the mechanism and will work for everyone.”

Identify selection contamination, unsupported mechanism claims, and missing population evidence. Propose an independent evaluation and rewrite the claim.

## Capstone

Analyze a scientific question using the shared workflow. Exchange packages, reproduce one result, and challenge one assumption. Submit original and revised claims, explain disagreements, and identify a discriminating observation that would change your conclusion. Document AI assistance without treating it as evidence for the scientific conclusion.
