Analyze Weighted IBGE Distribution
ibge_microdata_weighted_distributionCompute weighted distribution statistics and top-bracket shares from IBGE microdata Parquet views via a custom SQL query.
Instructions
Calculate weighted distribution summaries and top-bracket shares over local IBGE Parquet views.
Use this after converting microdata to Parquet when you need income, consumption, wealth, or other distribution statistics without hand-writing all aggregation SQL. Provide unitSql as a read-only SELECT/WITH query that returns a numeric value column, a numeric weight column, and optionally a group column. The tool ranks units by value, computes total weight/value/mean, group population and value shares, and top brackets such as top 1%, 5%, and 10%. Cutoff ties are allocated proportionally across groups.
Input Schema
| Name | Required | Description | Default |
|---|---|---|---|
| views | Yes | Named local Parquet views to create before calculating the distribution. | |
| unitSql | Yes | Read-only SELECT/WITH query that returns one row per analytical unit with value, weight, and optional group columns. | |
| maxGroups | No | Maximum group summaries to return. Defaults to 100 and is capped at 1000. | |
| groupColumn | No | Optional column name from unitSql used for group breakdowns, e.g. region or category. | |
| topPercents | No | Top brackets as fractions, e.g. [0.01, 0.05, 0.1]. Defaults to [0.01, 0.05, 0.1]. | |
| valueColumn | Yes | Column name from unitSql containing the income, consumption, wealth, or other value to rank. | |
| weightColumn | Yes | Column name from unitSql containing the survey/sample weight. |