Working with panel data¶
In the app: Help → Help contents, Working with panel data.
A panel holds the same series for several entities (countries, firms, sectors) over time. PyMetrix keeps it in long form, one row per entity and period, indexed by a pandas MultiIndex; lags are always taken within each entity.
Pivot tables summarise series by axes or categories: the mean of inflation by region and year, or counts of observations by country. Wide form (one column per entity, y_AUS, y_NZL) suits graphs and spreadsheets; long form suits estimation; reshape with wide() and long(). Take one country's time series with entity(), or one period's cross-section with cross_section().
Group-wise functions work in any expression or derived series: mean(y, country) is each country's mean on every row, mean(y, time) the cross-country mean each period, and demean(), share(), rank(), sum(), sd(), count(), min(), max() and median() follow the same pattern; group by an axis or by a series of categories such as region, as mean(y, country) or mean(y, by=country). For max and min, write by=: max(a, b) is the larger of two values in each period.
Before estimating, check coverage: which entity has data when, and where the gaps are. balance() keeps the periods (or entities) with complete data. The overall, between and within standard deviations show whether a series varies mostly across entities or over time, which matters for fixed-effects estimation: a series that hardly varies within entities is poorly identified once their means are removed.