Repository navigation
Description
Our models hardcode loglike, score, score_obs, hessian, .... This makes it difficult to reuse the code across models.
genmod.families are only for one-parameter LEF, with auxiliary support for scale.
The idea is to create new distribution classes in support of models, complementary to scipy, and not subclasses of scipy distributions. Same idea as for genmod families, but covering a larger set of distribution.
- parameterization as used in models, possible several different parameterization e.g. as in GAMLSS
- derivatives for MLE, first and second deriv w.r.t parameters
- other derivatives, e.g. CDFLink needs derivative of cdf, pdf with respect to the rv, e.g. needed for censoring/truncation models.
- get_distribution, code to convert parameters to scipy parameterization
- restrictions on parameters and possible or allowed links.
I'm not sure whether the families should contain only the info or also the links. (*) - additional properties of the distribution not available in scipy, e.g. hazard rate for lifetime models.
usecase:
- different models for the same underlying distribution family, e.g. gaussian with heteroscedasticity, truncated models, ...
- reusing loglike, score and similar with different exog, endog than in the model.
- we needed and need this for prediction "which" in count models. We will need more when we get
get_predictioninference
- we needed and need this for prediction "which" in count models. We will need more when we get
- reusable model classes, similar to GLM that works with all supported families.
- computational efficiency/precision: e.g. avoid division by scale, if
precision = 1/scaleparameterization is used as in AFT models.
As alternative, we can write generic models based on scipy distribution classes, e.g. logpdf, cdf, ...
However, those don't include the extras that we want to have if available, e.g. analytical derivatives.
We can delegate to scipy distributions for methods that are available and not in heavy usage, e.g. we usually implement our own logpdf.
(*) As families are currently used in GLM, I would prefer if links where separate and not accessed through the family.
e.g. for nonlinear prediction we just need the link and not the family.
However, if the link is included, then the family could be defined in the final parameterization, e.g. derivatives of the link are included in family derivatives.
GLM does not do that. Adding links and link derivatives is done in GLM class itself, Families take mean mu as parameter and not linpred (eta in GLM terminology).
I guess those distribution families would have to be private for considerable time, because design will need to change in response to our internal usage.
Activity