ModelDescription

ModelDescription(
    parsed_formula,
    method,
    is_iv,
    model_name,
    sample_split,
    inference_dist,
    depvar='',
    fixed_effects=(),
    interacted_covariates=(),
    model_spec=None,
)

What a fitted model estimates: its formula, estimator, and design names.

Every fitted model publishes one value as fit.model. The formula-time fields are known when the model object is built. The matrix-time fields (depvar, fixed_effects, interacted_covariates, and model_spec) are only known once the model matrix exists, and are empty ("", (), and None) until the description is republished with them. The value survives store_data=False and lean=True.

Parameters

Name Type Description Default
parsed_formula Formula The parsed formula, with its stages, fixed effects, and instruments. required
method str Name of the estimator: the estimation function that fitted the model ("feols", "fepois", "feglm-logit", "quantreg_fn", and so on), or the DiD estimator for fits returned by event_study() ("twfe", "saturated") and did2s() ("did2s"), which republish the description of their underlying feols() fit with it. summary() labels the estimation with it, and refits such as the CRV3 jackknife dispatch on it. required
is_iv bool Whether a model with instrumental variables was fitted. required
model_name str Key the model is stored under in a multiple-estimation result. required
sample_split SampleSplit or None The variable and value by which the estimation sample was split. None for an unsplit fit. required
inference_dist InferenceDist Reference distribution of the coefficient p-values and confidence bounds: Student’s t for OLS, IV, quantile, and Gaussian GLM fits, the normal distribution for the other GLM families. required
depvar str Name of the dependent-variable column of the model matrix. ''
fixed_effects tuple[str, …] Names of the absorbed fixed effects in formula order, as fixest’s fixef_vars; empty when the model has none. ()
interacted_covariates tuple[str, …] Names of the coefficients generated by the i() interaction syntax, which iplot() plots; empty when the formula has no i() term. ()
model_spec Mapping[str, formulaic.ModelSpec] or None Formulaic specification of each model-matrix stage, which predict() and fixef() materialize newdata with. It is left out of the repr because it prints the full encoder state of every stage. None

Examples

import pyfixest as pf

fit = pf.feols("Y ~ X1 + i(f2) | f1", pf.get_data())
fit.model.method, fit.model.depvar, fit.model.fixed_effects
('feols', 'Y', ('f1',))

Attributes

Name Description
ModelDescription.fixef The fixed effects in the +-joined spelling of the formula.
ModelDescription.formula The expanded formula, preserving quoting, expressions, and intercepts.
ModelDescription.has_fixef Whether the model absorbs fixed effects.