Skip to content

Inclusion of non-negative continuous probability distributions (e.g. Weibull, Pareto) for regression? #5094

Open

Description

@Irene-GM

Hi,

Apologies if this is not the right place to ask/request this functionality. I have been exploring the code of statsmodels to learn whether this (fantastic!) piece of software includes continuous probability distributions for multivariate regression (e.g. Weibull, Pareto, exponential), in a similar fashion as the discrete case (e.g Poisson, Neg. Binomial and its zero-inflated versions). I am modelling daily values of precipitation data, and this type of "power law" models (continuous or discrete) are really handy for these tasks, because they handle decently skewed distributions.

For what I understood, with the current version of statsmodels, it is possible to fit a multivariate Gamma distribution as a combination of a GLM and a link function from the gamma family (please, correct me if I use the wrong terms):

def fitting_gamma(xtrain, ytrain):
    # Shape of xtr/ytr: (800 rows, 8 columns) / (800 rows, 1 column)
    gam_mod = sm.GLM(ytrain, xtrain, family=sm.families.Gamma(link=sm.genmod.families.links.identity), disp=1).fit(method="nm", maxiter=100)
    gam_pred = gam_mod.predict(xtrain)
    return [gam_mod, gam_pred]

gam_mod, gam_pred  = fitting_gamma(xtrain, ytrain)
prediction = gam_mod.predict(xtest)
# more stuff

Thus, I can train my gamma model with part of my multivariate data , and then test its performance with unseen data to calculate few statistical metrics.

In Python, there are some great examples to learn how to fit probability distributions to univariate data, mostly relying on scipy.stats. However, I could not find similar software packages doing the same for multivariate data. Actually with statsmodels, I think the only continuous distributions that I found is gamma (perhaps I overlooked the rest).

Is there any way of doing the same multivariate fitting I did with Gamma but with a Weibull/Pareto distribution? Are there any plans to include these multivariate regression models in statsmodels?

Thanks a lot for your work!

Activity

  1. josef-pkt commented on Sep 3, 2018

    @josef-pkt
    Member

    To clarify a bit the terminology

    I assume you mean using a regression setting where the distribution depends on explanatory variables.
    multivariate models means in general that endog, i.e. ytrain, is multivariate. GLM Gamma estimate a "Univariate Gamma Regression". endog ytrain is univariate, exog xtrain is multivariate

    short answer: statsmodels does currently not include Weibull/Pareto and similar distributions.

    in decreasing generality

    aside:
    Our count models allow for continuous data with exponential mean function E(y | x) = exp( x b)
    The parameters for the mean models can be consistently estimated, but we need to correct the cov_params (cov_type=HC0). However, it will not model correctly other properties of the distribution besides mean/expected value, i.e. it's fine for mean prediction but not for predicting quantiles of the observations.

    GLM also has InverseGaussian and Tweedie as distribution with positive valued observations (endog). Tweedie has in general an additional mass point at zero, and is identical to gamma for a special case.
    But GLM does not include parametric failure time models, and is restricted to models without shape parameters (i.e. only for one parameter families, and dispersion as nuisance parameter).

  2. changed the title [-]Inclusion of continuous probability distributions (e.g. Weibull, Pareto) for regression?[/-] [+]Inclusion of non-negative continuous probability distributions (e.g. Weibull, Pareto) for regression?[/+] on Sep 3, 2018
  3. josef-pkt commented on Sep 3, 2018

    @josef-pkt
    Member

    I changed title to reflect that the issue is for positive or non-negative endog.

  4. josef-pkt commented on Jun 16, 2021

    @josef-pkt
    Member

    bump

    simplest case might be distributions on R+ with exp scale function that depends on explanatory variables, and constant shape parameters in the intitial version. #4217 (comment)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions