linearmodels.panel.data.PanelData.demean

PanelData.demean(group='entity', weights=None, return_panel=True, low_memory=False)[source]

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

Union[PanelData, ndarray]