Skip to main content
Glama

Analyze an experiment: intention to treat and per protocol, permutation test

analyze_experiment
Read-only

Analyzes 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

NameRequiredDescriptionDefault
idNoThe experiment id (default: the newest).
earlyNotrue: analyze before the planned end (exploratory, flagged as such). Default false: refused until the last night is recorded.

Schema Changelog

Changes observed during successful MCP inspections.

  1. Addedv1.3.0

TDQS

A4.5/5.0
Behavior5/5

Does the description disclose side effects, auth requirements, rate limits, or destructive behavior?

Annotations only cover readOnlyHint and openWorldHint; the description adds substantial context beyond them: it performs exactly one request each to the sleep list (and recovery list for recoveryMorning) plus the local file, writes nothing, and treats a failed request as an error rather than silently missing nights. It also discloses determinism (fixed seed, enumerated swaps up to 15 informative pairs) and that exactness depends on washout, reported via pValueBasis — all consistent with the annotations.

Agents need to know what a tool does to the world before calling it. Descriptions should go beyond structured annotations to explain consequences.

Conciseness3/5

Is the description appropriately sized, front-loaded, and free of redundancy?

The core purpose is front-loaded, but the body is a single wall of nested parentheticals that is hard to scan, and the verdict logic is restated at length. Since there is no output schema, enumerating return fields is justified rather than wasteful, but the presentation is dense and could be broken into labelled sections without losing content.

Shorter descriptions cost fewer tokens and are easier for agents to parse. Every sentence should earn its place.

Completeness5/5

Given the tool's complexity, does the description cover enough for an agent to succeed on first attempt?

For a high-complexity statistical tool with no output schema, the description covers the estimator, the test mechanics and their limitations, the verdict thresholds, the minimum-6-night guard, what is and is not randomized, and the full return shape. Nothing an agent needs to invoke or interpret it correctly appears to be missing.

Complex tools with many parameters or behaviors need more documentation. Simple tools need less. This dimension scales expectations accordingly.

Parameters4/5

Does the description clarify parameter syntax, constraints, interactions, or defaults beyond what the schema provides?

Schema coverage is 100% and both parameters are documented there, so the baseline is 3; the description earns more by explaining the consequence of early=true (exploratory flag set, statement prefixed 'Exploratory') and the id default of newest, which goes beyond the schema's own wording.

Input schemas describe structure but not intent. Descriptions should explain non-obvious parameter relationships and valid value ranges.

Purpose5/5

Does the description clearly state what the tool does and how it differs from similar tools?

States a specific verb and resource (analyzes an experiment), plus the exact estimand: median difference of outcome on nights after intervention vs control, with a two-sided permutation test over randomized pairs. It distinguishes itself from the sibling set by describing both the intention-to-treat and per-protocol reports and by tying its effect scale to get_tag_effects, so an agent knows this is the analysis tool rather than get_experiment or log_experiment_day.

Agents choose between tools based on descriptions. A clear purpose with a specific verb and resource helps agents select the right tool.

Usage Guidelines4/5

Does the description explain when to use this tool, when not to, or what alternatives exist?

Gives explicit when-to-use conditions: allowed only from the second day after the planned end, with the last night recorded, and the early:true escape hatch for an early look that is flagged exploratory (also for a stopped experiment). It does not name the alternative tools an agent might reach for instead (e.g. get_experiment for raw views), so it stops short of full alternative routing.

Agents often have multiple tools that could apply. Explicit usage guidance like "use X instead of Y when Z" prevents misuse.