You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
ENH: add GLM Margins and supporting helper functions #4751
GEE has margins, although incomplete, see #3704
GLM has nothing related yet.
To compute hatmatrix or, more precisely, generalized leverage for generic MLE that have predict, I need one method d mu / d params, which is in discrete_models used for the margin computations.
GEE has _derivative_exog which is almost the same as _derivative_predict which is needed for margins but not yet in GEE.
GEE has model specific methods that compute with different argument, eg, mean_deriv, which should extend to GLM also.
I need _derivative_predict and similar derivatives in a generic interface, so I don't have to access the link directly.
To go the other way as a generic cross-model pattern see #3915
(e.g. I added the family to Poisson so I have access to the inverse link deriv)
naming: I think we need more explicit names to refere to the function and wrt which variable we take the derivative, e.g. deriv_predict_params or deriv_mean_params deriv_mean_exog deriv_mean_linpred deriv_score_endog (that's what I also need for generalized leverage)
or maybe another d in there deriv_mean_dlinpred
(The new count models have many "which" in predict and we need derivatives to be able to get standard errors. It will be similar for other two part models like BetaRegression)
To get the equivalent of DFFITS, I also need deriv_mean_params or derivative_predict
e.g. currently I have it specific to the availability of model.family.link, i.e. GLM, and Poisson for now
def d_fittedvalues(self):
# in discrete we cannot reuse results.fittedvalues
fittedvalues = self.results.predict()
deriv = self.results.model.family.link.inverse_deriv(fittedvalues)
return deriv * self.d_linpred
I just realized (again) that GLMResults still does not have get_margeff
We need it to e.g. compare logit and probit, Binomial with different link functions, params have different scaling and cannot be directly compared.
see also #8802 for another reason to look at margins in binomial
If we don't want to support weights in the first version #7341, then we could raise NotImplementedError for non-default weights.
Activity
ENH: add MLEInfluence, supporting code in GLM (see statsmodels#4751)
josef-pkt commentedon Apr 24, 2023
I just realized (again) that GLMResults still does not have
get_margeffWe need it to e.g. compare logit and probit, Binomial with different link functions, params have different scaling and cannot be directly compared.
see also #8802 for another reason to look at margins in binomial
If we don't want to support weights in the first version #7341, then we could raise NotImplementedError for non-default weights.