linearmodels.panel.model.FirstDifferenceOLS.from_formula

classmethod FirstDifferenceOLS.from_formula(formula, data, *, weights=None, check_rank=True)[source]

Create a model from a formula

Parameters:
formulastr

Formula to transform into model. Conforms to formulaic formula rules.

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 times the weight should be homoskedastic.

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.

Returns:
FirstDifferenceOLS

Model specified using the formula

Notes

Unlike standard formula syntax, it is necessary to explicitly include a constant using the constant indicator (1)

Examples

>>> from linearmodels import FirstDifferenceOLS
>>> from linearmodels.panel import generate_panel_data
>>> panel_data = generate_panel_data()
>>> mod = FirstDifferenceOLS.from_formula("y ~ x1", panel_data.data)
>>> res = mod.fit()
Return type:

FirstDifferenceOLS