user8947896
user8947896

Reputation: 151

Transformed beta regression in python

Has anyone tried implementing beta transformed regression python? It is used to model values that lie between 0 and 1 and has a distribution with heteroskedasticity ineherently present. Essentially you first transform the dependent variable to a beta distribution and apply a second transformation or a link function such as logit or probit to restrict its values bw 0 and 1. The link below explains in detail the code for R: https://cran.r-project.org/web/packages/betareg/vignettes/betareg.pdf

However, I'm having a hard time finding functions/libraries to do this in python. Even if i try using brute force method, once we have the predicted transformed Ys, transforming it back to original Ys is challenging. Moreover I don't want to go the brute force route and was wondering if there is a sophisticated way to implement this in python. Thanks a lot!

Upvotes: 15

Views: 3587

Answers (2)

Johnny Cheesecutter
Johnny Cheesecutter

Reputation: 2852

Statsmodels package has a Beta regression model that you can use for this purpose (as far as I understood your question).

https://www.statsmodels.org/stable/generated/statsmodels.othermod.betareg.BetaModel.html

You can also check other link functions in the glm API from the statsmodels. I think it is very similar to what is usually provided in R.

https://www.statsmodels.org/stable/glm.html

I've also found notebook with example how to model data using BetaModel from the statsmodels: https://gist.github.com/josef-pkt/4d0fd829c8fbc1c4237d989ba3dbb088

Upvotes: 1

jtlz2
jtlz2

Reputation: 8417

Apologies for the link-only answer (with which I am not associated) - but look at the following for this:

https://towardsdatascience.com/a-guide-to-the-regression-of-rates-and-proportions-bcfe1c35344f

Upvotes: 0

Related Questions