linearmodels.panel.model.PanelOLS.from_formula¶
- classmethod PanelOLS.from_formula(formula, data, *, weights=None, other_effects=None, singletons=True, drop_absorbed=False, check_rank=True)[source]¶
Create a model from a formula
- Parameters:
- formula
str
Formula to transform into model. Conforms to formulaic formula rules with two special variable names, EntityEffects and TimeEffects which can be used to specify that the model should contain an entity effect or a time effect, respectively. See Examples.
- dataarray_like
Data structure that can be coerced into a PanelData. In most cases, this should be a multi-index DataFrame where the level 0 index contains the entities and the level 1 contains the time.
- weights: array_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.
- 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.
- formula
- Returns:
PanelOLS
Model specified using the formula
Examples
>>> from linearmodels import PanelOLS >>> from linearmodels.panel import generate_panel_data >>> panel_data = generate_panel_data() >>> mod = PanelOLS.from_formula("y ~ 1 + x1 + EntityEffects", panel_data.data) >>> res = mod.fit(cov_type="clustered", cluster_entity=True)
- Return type: