Base class for the estimation of a fixed-effects GLM model.
Returned by feglm(). Fixed effects are handled via iteratively reweighted least squares with demeaning, following Stammann (2018), arXiv:1707.01815. The family is set with the family argument and implemented by a subclass. poisson dispatches to Fepois.
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
bool | None
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
PredictionErrorOptions | None
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”.
Feglm.prepare_model_matrix
prepare_model_matrix()
Prepare model inputs for estimation.
Feglm.resid
resid(type='response')
Return residuals from a fitted GLM.
Parameters
Name
Type
Description
Default
type
str
The type of residuals to return. Either “response” (default) or “working”.