linearmodels.panel.model.PanelOLS¶
- class PanelOLS(dependent, exog, *, weights=None, entity_effects=False, time_effects=False, other_effects=None, singletons=True, drop_absorbed=False, check_rank=True)[source]¶
One- and two-way fixed effects estimator for panel data
- Parameters:
- dependentarray_like
Dependent (left-hand-side) variable (time by entity).
- exogarray_like
Exogenous or right-hand-side variables (variable by time by entity).
- weightsarray_like
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_effectsbool
Flag whether to include entity (fixed) effects in the model
- time_effectsbool
Flag whether to include time effects in the model
- other_effectsarray_like
Category codes to use for any effects that are not entity or time effects. Each variable is treated as an effect.
- singletonsbool
Flag indicating whether to drop singleton observation
- drop_absorbedbool
Flag indicating whether to drop absorbed variables
- check_rankbool
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`` areFalse
, and no other effects are included, the model reduces toPooledOLS
.Model supports at most 2 effects. These can be entity-time, entity-other, time-other or 2 other.
- Attributes:
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
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, context])Predict values for additional data
reformat_clusters
(clusters)Reformat cluster variables
Properties
Flag indicating whether entity effects are included
Formula used to construct the model
Flag indicating the model a constant or implicit constant
Locations of non-missing observations
Flag indicating whether other (generic) effects are included
Flag indicating whether time effects are included