linearmodels.panel.data.PanelData.demean

PanelData.demean(group: Literal['entity', 'time', 'both'], *, return_panel: Literal[False]) ndarray[source]
PanelData.demean(group: Literal['entity', 'time', 'both'] = 'entity', weights: PanelData | None = None, return_panel: Literal[True] = True, low_memory: bool = False) PanelData
PanelData.demean(group: Literal['entity', 'time', 'both'], weights: PanelData | None, return_panel: Literal[False]) ndarray

Demeans data by either entity or time group

Parameters:
group{“entity”, “time”, “both”}

Group to use in demeaning

weightsPanelData

Weights to implement weighted averaging

return_panelbool

Flag indicating to return a PanelData object. If False, a 2-d NumPy representation of the panel is returned

low_memorybool

Flag indicating whether to use a low memory implementation that avoids constructing dummy variables. Only relevant when group is “both”

Returns:
PanelData

Demeaned data according to type

Notes

If weights are provided, the values returned will be scaled by the square root of the weights so that they can be used in WLS estimation.

Return type:

PanelData | Float64Array