linearmodels.panel.model.PanelOLS

class linearmodels.panel.model.PanelOLS(dependent: PanelData | ndarray | DataArray | DataFrame | Series, exog: PanelData | ndarray | DataArray | DataFrame | Series, *, weights: PanelData | ndarray | DataArray | DataFrame | Series | None = None, entity_effects: bool = False, time_effects: bool = False, other_effects: PanelData | ndarray | DataArray | DataFrame | Series | None = None, singletons: bool = True, drop_absorbed: bool = False, check_rank: bool = True)[source]

One- and two-way fixed effects estimator for panel data

Parameters:
dependent: PanelData | ndarray | DataArray | DataFrame | Series

Dependent (left-hand-side) variable (time by entity).

exog: PanelData | ndarray | DataArray | DataFrame | Series

Exogenous or right-hand-side variables (variable by time by entity).

weights: PanelData | ndarray | DataArray | DataFrame | Series | None = None

Weights to use in estimation. Assumes residual variance is proportional to inverse of weight to that the residual time the weight should be homoskedastic.

entity_effects: bool = False

Flag whether to include entity (fixed) effects in the model

time_effects: bool = False

Flag whether to include time effects in the model

other_effects: PanelData | ndarray | DataArray | DataFrame | Series | None = None

Category codes to use for any effects that are not entity or time effects. Each variable is treated as an effect.

singletons: bool = True

Flag indicating whether to drop singleton observation

drop_absorbed: bool = False

Flag indicating whether to drop absorbed variables

check_rank: bool = True

Flag indicating whether to perform a rank check on the exogenous variables to ensure that the model is identified. Skipping this check can reduce the time required to validate a model specification. Results may be numerically unstable if this check is skipped and the matrix is not full rank.

Notes

Many models can be estimated. The most common included entity effects and can be described

\[y_{it} = \alpha_i + \beta^{\prime}x_{it} + \epsilon_{it}\]

where \(\alpha_i\) is included if entity_effects=True.

Time effect are also supported, which leads to a model of the form

\[y_{it}= \gamma_t + \beta^{\prime}x_{it} + \epsilon_{it}\]

where \(\gamma_i\) is included if time_effects=True.

Both effects can be simultaneously used,

\[y_{it}=\alpha_i + \gamma_t + \beta^{\prime}x_{it} + \epsilon_{it}\]

Additionally , arbitrary effects can be specified using categorical variables.

If both entity_effect and time_effects are False, and no other effects are included, the model reduces to PooledOLS.

Model supports at most 2 effects. These can be entity-time, entity-other, time-other or 2 other.

Methods

fit(*[, use_lsdv, use_lsmr, low_memory, ...])

Estimate model parameters

from_formula(formula, data, *[, weights, ...])

Create a model from a formula

predict(params, *[, exog, data, eval_env, ...])

Predict values for additional data

reformat_clusters(clusters)

Reformat cluster variables

Properties

entity_effects

Flag indicating whether entity effects are included

formula

Formula used to construct the model

has_constant

Flag indicating the model a constant or implicit constant

not_null

Locations of non-missing observations

other_effects

Flag indicating whether other (generic) effects are included

time_effects

Flag indicating whether time effects are included