moderndid.core.panel.are_varying#

moderndid.core.panel.are_varying(data: Any, idname: str, cols: list[str] | None = None) dict[str, bool][source]#

Check which columns vary within units over time.

Difference-in-differences estimators distinguish between time-varying and time-invariant covariates. Time-invariant covariates (e.g., baseline demographics) are appropriate for inclusion in the propensity score or outcome regression model, while time-varying covariates require additional assumptions. This function classifies columns so you can make informed covariate-selection decisions before estimation.

Parameters:
dataDataFrame

Panel data. Accepts any object implementing the Arrow PyCapsule Interface (__arrow_c_stream__), including polars, pandas, pyarrow Table, and cudf DataFrames.

idnamestr

Unit identifier column.

colslist[str] or None

Columns to check. Defaults to all columns except idname.

Returns:
dict[str, bool]

Mapping of column name to True if the column varies within any unit, False otherwise.

See also

diagnose_panel

Full diagnostic battery including treatment variation.