Skip to main content
Glama

Propensity score matching (PSM) / 倾向性评分匹配 PSM

propensity_score_matching
Read-only

Propensity score matching (PSM) / 倾向性评分匹配 PSM | USE WHEN: match treated and control subjects on baseline covariates (1:1 nearest neighbour within caliper), then report SMD balance | ALIASES: PSM, 倾向性评分, 倾向评分匹配, propensity score, 1:1匹配, 基线可比, 混杂控制, 匹配后均衡 | RETURNS: 匹配后样本与均衡性

Example tool call

This call uses example arguments supplied in the tool’s input schema.

{
  "id": 1,
  "jsonrpc": "2.0",
  "method": "tools/call",
  "params": {
    "arguments": {
      "data": [
        {
          "age": 62,
          "sex": 0,
          "treat": 1
        },
        {
          "age": 58,
          "sex": 1,
          "treat": 0
        },
        {
          "age": 65,
          "sex": 0,
          "treat": 1
        },
        {
          "age": 61,
          "sex": 1,
          "treat": 0
        },
        {
          "age": 70,
          "sex": 0,
          "treat": 1
        },
        {
          "age": 55,
          "sex": 0,
          "treat": 0
        }
      ],
      "caliper": 0.2,
      "treatment": "treat",
      "covariates": [
        "age",
        "sex"
      ]
    },
    "name": "propensity_score_matching"
  }
}

Input Schema

NameRequiredDescriptionDefault
XNo协变量矩阵(二维数值数组,每行一例)。与 covariates(列名式) 二选一,X 优先。
dataNo样本表:每行一个受试者的字典,如 [{"treat":1,"age":62,"sex":0}, …](也可改用 treatment/covariates 直接传数组)
rowsNorecords 的历史别名(等价,两者都认)。新代码建议统一用 records。
ratioNo匹配比例 1:k 中的 k,默认 1。
caliperNo卡钳值(倾向评分 logit 尺度的最大允许差),默认 0.2×SD(logit PS)。不设卡钳会匹配出「评分差很大但硬凑」的对子。
recordsNo逐例原始记录(对象数组,每行含协变量与分组列)。传了才能回溯匹配前后究竟是哪几例,否则只得到匹配后的统计量、无法核对个体。
treatmentYes处理变量(1=处理组,0=对照组)。传 data 时填列名 "treat";也可直接传 0/1 数组
covariatesYes协变量列名数组,如 ["age","sex"](传 data 时)或二维数值矩阵

Schema Changelog

Changes observed during successful MCP inspections.

  1. Changed6 schema fields changed
    • addedInput schema / properties / X
      Added value: +{
      +  "description": "协变量矩阵(二维数值数组,每行一例)。与 covariates(列名式) 二选一,X 优先。",
      +  "items": {
      +    "type": "string"
      +  },
      +  "type": "array"
      +}
    • addedInput schema / properties / caliper
      Added value: +{
      +  "description": "卡钳值(倾向评分 logit 尺度的最大允许差),默认 0.2×SD(logit PS)。不设卡钳会匹配出「评分差很大但硬凑」的对子。",
      +  "type": "number"
      +}
    • changedInput schema / properties / ratio / description
      Previous value: -"匹配比例,默认 1"New value: +"匹配比例 1:k 中的 k,默认 1。"
    • changedInput schema / properties / ratio / type
      Previous value: -"number"New value: +"integer"
    • addedInput schema / properties / records
      Added value: +{
      +  "description": "逐例原始记录(对象数组,每行含协变量与分组列)。传了才能回溯匹配前后究竟是哪几例,否则只得到匹配后的统计量、无法核对个体。",
      +  "items": {
      +    "type": "string"
      +  },
      +  "type": "array"
      +}
    • addedInput schema / properties / rows
      Added value: +{
      +  "description": "records 的历史别名(等价,两者都认)。新代码建议统一用 records。",
      +  "items": {
      +    "type": "string"
      +  },
      +  "type": "array"
      +}
  2. Changed1 schema field changed
    • changedInput schema / required
      Previous value: -[]New value: +[
      +  "treatment",
      +  "covariates"
      +]
  3. Added

TDQS

A3.6/5.0
Behavior3/5

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

Annotations already declare readOnlyHint=true, destructiveHint=false and openWorldHint=false, so the safety profile is covered. The description adds useful method context (1:1 nearest neighbour, caliper, SMD balance output), but omits operationally relevant behaviour: whether matching is with or without replacement, what happens to unmatched cases, and whether results are deterministic. For a compute tool that silently drops unmatched subjects, that is a real gap.

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?

Front-loaded and pipe-structured: use case first, then aliases, then return contract, with no filler sentences. Minor waste from restating the bilingual title at the head and a long alias list that adds little for an English-driven agent.

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

Completeness3/5

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

An 8-parameter statistical procedure with no output schema needs the description to say what comes back; 'RETURNS: 匹配后样本与均衡性' is too vague to tell an agent whether to expect matched pair indices, SMD per covariate, or an ATT estimate. The input side is well covered by the schema, but the return side is under-specified for a tool this complex.

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

Parameters3/5

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

Schema description coverage is 100% and the schema goes further than the description — it explains the caliper default, that X takes priority over covariates, and that records is the new name for rows. The description itself contributes no parameter meaning, so the baseline 3 applies.

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

Purpose4/5

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

States a specific verb+resource with method detail: match treated and control subjects on baseline covariates via 1:1 nearest-neighbour within a caliper, then report SMD balance. That is far more specific than a name restatement. No sibling in the provided list does matching, so there is nothing to explicitly distinguish from, which keeps it just short of a 5.

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?

The 'USE WHEN' clause gives a clear triggering condition (need to make treated and control groups comparable on baseline covariates). It stops short of the 5 bar because it names no exclusions or alternatives — e.g. when to prefer stratification, weighting, or a plain adjusted regression instead.

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

Try in Browser

Glama MCP Gateway

Add one secure layer between your agents and this server.

Resources