Skip to main content
Glama
Ian3738
by Ian3738

survey_mean

Compute survey-adjusted means and standard errors for clustered or stratified data using replicate weights or jackknife zones. Supports plausible values and group estimates to avoid inaccurate inference.

Instructions

Means for complex survey data, with design-correct standard errors. Use this instead of describe whenever the data comes from a clustered or stratified sample — the ordinary standard error assumes a simple random sample and can be less than half the true value.

For achievement scores use plausible values, never a single score: pv_prefix='BSMMAT' expands to BSMMAT01..05 (TIMSS style), or pv_pattern='PV{i}MATH' expands to PV1MATH.. (PISA style). The output reports how much of the standard error comes from sampling versus measurement.

Give the design one of two ways: replicate_weights (existing columns — either a list of names or a prefix such as 'W_FSTURWT' that matches W_FSTURWT1..80), or jkzone + jkrep so JK2 replicates are built for you (TIMSS/PIRLS ship JKZONE and JKREP). method defaults to JK2 for constructed replicates and Fay for 60+ supplied columns, which is what PISA needs.

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
byNoReport the mean separately for each level of this column.
fayNoFay factor when method='fay'; PISA uses 0.5.
dataYesDataset name in the session.
jkrepNoJackknife replicate indicator column (TIMSS: JKREP).
digitsNoDecimal places.
jkzoneNoJackknife zone column (TIMSS: JKZONE).
methodNoReplication method: auto, jk2, jk1, brr or fay.auto
weightYesFinal sampling weight column, e.g. TOTWGT (TIMSS) or W_FSTUWT (PISA).
pv_countNoHow many plausible values (default 5 for prefix, 10 for pattern).
pv_prefixNoPlausible-value prefix, e.g. 'BSMMAT' for BSMMAT01..05.
variablesNoOrdinary numeric columns to average. Omit when using plausible values.
pv_patternNoPlausible-value pattern with {i}, e.g. 'PV{i}MATH'.
replicate_weightsNoReplicate weight columns, or a prefix matching them.

Schema Changelog

Changes observed during successful MCP inspections. Dates show when Glama detected each change.

  1. First observedv0.1.0

TDQS

A4.9/5.0
Behavior5/5

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

With no annotations, the description carries the full behavioral burden and meets it: it discloses design-correct error computation, the risk of understated SEs, multi-stage plausible-value expansion, two accepted design specifications, and the fact that output separates sampling versus measurement error. It also states method defaults for JK2 and Fay, which is exactly the behavioral nuance an agent needs beyond the schema.

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

Conciseness4/5

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

The description is front-loaded and every sentence adds relevant guidance with no filler. It is dense rather than concise, packing three distinct topics (when-to-use, plausible values, replicate-weight designs) into one paragraph, but the complexity of the tool justifies the length.

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 13-parameter tool with no output schema and no annotations, the description covers the crucial decision points: sampling design, plausible values, replicate-weight specification, and method defaults. It still relies on the schema for obvious details like `by`, `digits`, and `fay`, but the high-risk ambiguity areas are all resolved.

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

Parameters5/5

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

Although schema coverage is 100%, the description adds substantial meaning: `pv_prefix='BSMMAT'` expands to BSMMAT01..05, `pv_pattern='PV{i}MATH'` expands to PV1MATH..., `replicate_weights` accepts either lists or prefixes, and `jkzone` + `jkrep` builds JK2 replicates automatically. This is essential operational detail that the bare schema fields do not convey.

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?

The opening sentence names a specific verb, resource, and key differentiator: 'Means for complex survey data, with design-correct standard errors.' It also explicitly contrasts with `describe`, which lets an agent immediately know this is the survey-aware mean tool rather than a generic descriptive tool.

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

Usage Guidelines5/5

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

The description explicitly says to use this tool 'instead of `describe`' for clustered or stratified samples and explains why the ordinary standard error is inadequate. It also gives concrete conditions for plausible values versus single scores and how to supply replicate weights, providing clear when-to-use and how-to-proceed guidance.

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

Latest Blog Posts

MCP directory API

We provide all the information about MCP servers via our MCP API.

curl -X GET 'https://glama.ai/api/mcp/v1/servers/Ian3738/r-stats-mcp'

If you have feedback or need assistance with the MCP directory API, please join our Discord server