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