Create model matrices for fixed effects estimation.
This function processes the data and then calls formulaic.Formula.get_model_matrix() to create the model matrices.
Parameters
Name
Type
Description
Default
FixestFormula
A pyfixest.estimation.FormulaParser.FixestFormula object
that contains information on the model formula, the formula of the first and second stage, dependent variable, covariates, fixed effects, endogenous variables (if any), and instruments (if any).
required
data
pd.DataFrame
The input DataFrame containing the data.
required
drop_singletons
bool
Whether to drop singleton fixed effects. Default is False.
False
weights
str or None
A string specifying the name of the weights column in data. Default is None.
None
data
pd.DataFrame
The input DataFrame containing the data.
required
drop_intercept
bool
Whether to drop the intercept from the model matrix. Default is False. If True, the intercept is dropped ex post from the model matrix created by formulaic.
False
Returns
Name
Type
Description
dict
A dictionary with the following keys and value types: - ‘Y’ : pd.DataFrame The dependent variable. - ‘X’ : pd.DataFrame The Design Matrix. - ‘fe’ : Optional[pd.DataFrame] The model’s fixed effects. None if not applicable. - ‘endogvar’ : Optional[pd.DataFrame] The model’s endogenous variable(s), None if not applicable. - ‘Z’ : np.ndarray The model’s set of instruments (exogenous covariates plus instruments). None if not applicable. - ‘weights_df’ : Optional[pd.DataFrame] DataFrame containing weights, None if weights are not used. - ‘na_index’ : np.ndarray Array indicating rows droppled beause of NA values or singleton fixed effects. - ‘na_index_str’ : str String representation of ‘na_index’. - ’_icovars’ : Optional[list[str]] List of variables interacted with i() syntax, None if not applicable. - ‘X_is_empty’ : bool Flag indicating whether X is empty.