estimation.feglm_.Feglm
estimation.feglm_.Feglm(
self,
FixestFormula,
data,
ssc_dict,
drop_singletons,
drop_intercept,
weights,
weights_type,
collin_tol,
fixef_tol,
fixef_maxiter,
lookup_demeaned_data,
tol,
maxiter,
solver,
store_data=True,
copy_data=True,
lean=False,
sample_split_var=None,
sample_split_value=None,
separation_check=None,
context=0,
)Abstract base class for the estimation of a fixed-effects GLM model.
Methods
| Name | Description |
|---|---|
| get_fit | Fit the GLM model via iterated weighted least squares. |
| predict | Return predicted values from regression model. |
| prepare_model_matrix | Prepare model inputs for estimation. |
| residualize | Residualize v and X by flist using weights. |
| to_array | Turn estimation DataFrames to np arrays. |
get_fit
estimation.feglm_.Feglm.get_fit()Fit the GLM model via iterated weighted least squares.
All equations in the code refer to Stammann ‘Fast and Feasible Estimation of Generalized Linear Models with High-Dimensional k-way fixed effects’: https://arxiv.org/pdf/1707.01815
predict
estimation.feglm_.Feglm.predict(
newdata=None,
atol=1e-06,
btol=1e-06,
type='link',
se_fit=False,
interval=None,
alpha=0.05,
)Return predicted values from regression model.
Return a flat np.array with predicted values of the regression model. If new fixed effect levels are introduced in newdata, predicted values for such observations will be set to NaN.
Parameters
| Name | Type | Description | Default |
|---|---|---|---|
| newdata | Union[None, pd.DataFrame] | A pd.DataFrame with the new data, to be used for prediction. If None (default), uses the data used for fitting the model. | None |
| atol | Float | Stopping tolerance for scipy.sparse.linalg.lsqr(). See https://docs.scipy.org/doc/ scipy/reference/generated/scipy.sparse.linalg.lsqr.html | 1e-6 |
| btol | Float | Another stopping tolerance for scipy.sparse.linalg.lsqr(). See https://docs.scipy.org/doc/ scipy/reference/generated/scipy.sparse.linalg.lsqr.html | 1e-6 |
| type | str | The type of prediction to be computed. Can be either “response” (default) or “link”. If type=“response”, the output is at the level of the response variable, i.e., it is the expected predictor E(Y|X). If “link”, the output is at the level of the explanatory variables, i.e., the linear predictor X @ beta. | 'link' |
| atol | Float | Stopping tolerance for scipy.sparse.linalg.lsqr(). See https://docs.scipy.org/doc/scipy/reference/generated/scipy.sparse.linalg.lsqr.html | 1e-6 |
| btol | Float | Another stopping tolerance for scipy.sparse.linalg.lsqr(). See https://docs.scipy.org/doc/scipy/reference/generated/scipy.sparse.linalg.lsqr.html | 1e-6 |
| se_fit | Optional[bool] | If True, the standard error of the prediction is computed. Only feasible for models without fixed effects. GLMs are not supported. Defaults to False. | False |
| interval | Optional[PredictionErrorOptions] | The type of interval to compute. Can be either ‘prediction’ or None. | None |
| alpha | float | The alpha level for the confidence interval. Defaults to 0.05. Only used if interval = “prediction” is not None. | 0.05 |
Returns
| Name | Type | Description |
|---|---|---|
| Union[np.ndarray, pd.DataFrame] | Returns a pd.Dataframe with columns “fit”, “se_fit” and CIs if argument “interval=prediction”. Otherwise, returns a np.ndarray with the predicted values of the model or the prediction standard errors if argument “se_fit=True”. |
prepare_model_matrix
estimation.feglm_.Feglm.prepare_model_matrix()Prepare model inputs for estimation.
residualize
estimation.feglm_.Feglm.residualize(v, X, flist, weights, tol, maxiter)Residualize v and X by flist using weights.
to_array
estimation.feglm_.Feglm.to_array()Turn estimation DataFrames to np arrays.