linearmodels.panel.model.BetweenOLS.from_formula

classmethod BetweenOLS.from_formula(formula: str, data: Union[linearmodels.panel.data.PanelData, numpy.ndarray, xarray.core.dataarray.DataArray, pandas.core.frame.DataFrame, pandas.core.series.Series], *, weights: Union[linearmodels.panel.data.PanelData, numpy.ndarray, xarray.core.dataarray.DataArray, pandas.core.frame.DataFrame, pandas.core.series.Series, NoneType] = None) → 'BetweenOLS'[source]

Create a model from a formula

Parameters
formulastr

Formula to transform into model. Conforms to patsy 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, optional

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

Returns
BetweenOLS

Model specified using the formula

Notes

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

Examples

>>> from linearmodels import BetweenOLS
>>> from linearmodels.panel import generate_panel_data
>>> panel_data = generate_panel_data()
>>> mod = BetweenOLS.from_formula('y ~ 1 + x1', panel_data.data)
>>> res = mod.fit()
Return type

BetweenOLS