weighted_stats
Compute weighted statistics (mean, median, percentiles, min, max, std) for a numeric survey variable, with optional filtering and grouping by another variable.
Instructions
Compute weighted descriptive statistics for a variable.
Args: variable: The numeric variable to analyze (e.g., 'ingc_pc', 'educ'). filter: Optional filter expression (e.g., "sexo == 1"). by: Optional grouping variable (e.g., "region", "sexo", "cohorte"). dataset: Which dataset to use (default: entrevistado).
Returns weighted mean, median, std, percentiles (25th, 75th), min, max, and sample sizes. If 'by' is specified, returns stats per group.
Tool call template
Replace each placeholder with a value matching the input schema. Only required parameters are included; add optional parameters as needed.
{
"id": 1,
"jsonrpc": "2.0",
"method": "tools/call",
"params": {
"arguments": {
"variable": "<variable>"
},
"name": "weighted_stats"
}
}Input Schema
| Name | Required | Description | Default |
|---|---|---|---|
| variable | Yes | ||
| filter | No | ||
| by | No | ||
| dataset | No | entrevistado |
Output Schema
| Name | Required | Description | Default |
|---|---|---|---|
| result | Yes |