Analyze an experiment: intention to treat and per protocol, permutation test
analyze_experimentAnalyzes a Suunto sleep experiment by comparing median outcomes on intervention versus control nights, running a permutation test and returning effect size, p-value, and a plain-language verdict.
Instructions
Analyzes an experiment (default: the newest): the difference in MEDIANS of the outcome metric on the night after intervention days minus the night after control days, with a two-sided permutation test over the randomized pairs (the arms swapped within each pair; all swaps are enumerated up to 15 informative pairs, else 20000 random swaps with a fixed seed, so the same data always gives the same p; WITHOUT a washout the p-value is exact when the intervention does nothing, WITH a washout it is an approximation, checked by simulation in the project's tests, and pValueBasis says which), the effect against the same noise scale get_tag_effects uses (noiseThreshold = 3 * 1.25 * (IQR of the control nights / 1.35) * sqrt(1/nIntervention + 1/nControl), effectInStandardErrors), the nights per arm, the missing nights per arm, and a verdict. Both analyses are reported: intentionToTreat (every assigned day counts as assigned, followed or not; the PRIMARY one) and perProtocol (only days logged as followed; not protected by the randomization). verdict: 'insufficient' with fewer than 6 nights with a value in either arm (nothing is claimed; 6 is the least with which a permutation test over pairs can reach p < 0.05); 'intervention-higher' / 'intervention-lower' only when p <= 0.05 AND the median difference is larger than noiseThreshold (compared as printed); else 'no-clear-difference', which does not show there is no effect. statement says it in plain language, randomized says what was randomized and notControlled what was not (everything else on those days, no blinding, carry-over between nights, the watch's estimate, missing nights). Allowed only from the second day after the planned end (the last night must be recorded); before it an early look needs early: true and is flagged exploratory (exploratory: true, the statement starts with 'Exploratory'), as is a stopped experiment (analysed up to the day it was stopped). Reads Suunto's sleep list (and the recovery list for recoveryMorning), one request each, and the local file; writes nothing. A failed request is an error, never silently 'missing nights'. Output: { id, name, metric, today, status, exploratory, exploratoryReason, window: { from, through, plannedEnd }, hypothesis, verdict, statement, intentionToTreat: { nIntervention, nControl, interventionMedian, controlMedian, medianDiff, meanDiff, noiseThreshold, effectInStandardErrors, pValue, test: { method, permutations, informativePairs }, missingNights: { intervention, control }, verdict }, perProtocol (the same fields + note), adherence, randomized, pValueBasis, notControlled, thresholds, notes }. Read-only.
Tool call template
This tool declares no required parameters. Add optional parameters from the input schema as needed.
{
"id": 1,
"jsonrpc": "2.0",
"method": "tools/call",
"params": {
"arguments": {},
"name": "analyze_experiment"
}
}Input Schema
| Name | Required | Description | Default |
|---|---|---|---|
| id | No | The experiment id (default: the newest). | |
| early | No | true: analyze before the planned end (exploratory, flagged as such). Default false: refused until the last night is recorded. |