Search code examples
pythonstatsmodelsglm

Where is eta in statsmodels GLM?


Where is the linear predictors (eta) located in the statsmodels.GLM class?

If a fitted model mdl = sm.GLM(Y, X, family = family()).fit() is equal to R's mdl <- glm.fit(X, Y, family = family()), then R's eta can be found mdl$linear.predictors. But i can't seem to find eta in statsmodels.

Right now i calculate them by X @ mdl.params, which seems a bit tedious


Solution

  • eta is not a very descriptive name. The internal name in statsmodels is linpred.

    The linear predictor including offset and exposure can be obtained using the results predict method

    results_glm.predict(..., linear=True)

    or md1.predict in your case.

    Offset can be set to zero using the keyword to obtain the linear predictor without offset, similar for exposure.