Repository navigation
beta-regression - #2030
beta-regression#2030brentp wants to merge 18 commits into
Conversation
There was a problem hiding this comment.
Z should be renamed into an exog_xxx
link_phi to link_xxx where xxx is not greek.
is phi dispersion or precision ?
|
I don't see any real problems right now, this seems to be working fine. My guess is that the TravisCI failures are If the In general: We need better multi-equation or multi-parameter support in statsmodels, to handle second exog like for example:
|
|
I'm briefly browsing some articles that I downloaded some time ago. seems to have the score. http://www.ime.usp.br/~sferrari/13EMRslidesSilvia.pdf are slides with a large list of references for extensions to the simple beta regression and extensions. |
|
I think we can stay with GenericLikelihoodModel for now. I'm not sure yet how it will fit in the class hierarchy, except for the top level LikelihoodModel. Some things for extending the usage of the model: a related to predict: the parameterization is not the one of the standard beta distribution. We need a helper function or method that returns the Eventually we will also need additional results attributes that we have for GLM and discrete models. For example different kinds of residuals that can be used for further inference or diagnostics. |
|
about the score: "Improved likelihood inference in beta regression" equations (4) and (5): |
|
@brentp The extra work is to create a new model group for an additional data type similar to binary and count data in GLM and discrete, and to handle the two parameter/two exog structure. |
|
@josef-pkt no problem. I'm happy for the feedback. I'll have to go through your comments in more detail as I have time. Here's a start of the list:
|
The score function on slide 11 is for constant phi. We still need the |
|
I just updated to the latest version and optimization doesn't work anymore because of the incorrect score. Debugging tip: in general: |
|
special functions: the math psi in the expression for mu_star is the digamma function http://docs.scipy.org/doc/scipy-0.7.x/reference/generated/scipy.special.psi.html#scipy.special.psi which is the derivative of the gamma function. The hessian requires the trigamma function psi-prime, which (after a google search) is available with the (too much greek) |
|
FYI: I'm debugging score right now. I got the first part of the derivative working. |
|
thanks. it's all greek to me. you had suggested to add a function to pull out the a, b parameters for the Beta, what would the signature of that be? ? I'll add precision_formula kwarg to from_formula since that should be pretty simple. |
|
As reference, the latest version for parameter tests in Beta regression (I didn't read yet. According to abstract score test and bootstrap are best in small samples) |
I think it should have the same signature as predict and include the two exog as keyword parameters, and use self.exog if the arguments are None. |
"to gently bound the predicted values away from 0 or 1 for mu, and 0 for phi." |
|
two things: start_params and convergence: I'm getting a non convergence warning in the last score test, with log-link, but the test doesn't fail (score is very large but both methods agree) As alternative unit tests: |
there will still be some work todo for the 0, 1 boundaries. We will also need to check the data, endog. I saw another example/tutorial where they moved extreme observations into the interior, In general, there might be something "fishy" if there are exact 0s and 1s in the data or prediction, and we might have to warn the user. I didn't look at anything related yet, but for Stata there is a user contributed package for |
|
to add to previous comment: |
|
I got the hessian and hessian factors and will push them later. |
|
comment to hessian |
|
It looks like maybe you merged master (at some point) in to this branch? Let me know if you need help sorting it out. |
|
Yes, how can I fix this? On Fri, Nov 21, 2014 at 12:25 PM, Skipper Seabold [email protected]
|
|
Hmm. This is going to be tricky. The history doesn't make too much sense to me at a few points. It looks like you may have done a non-fast-forward merge on this branch at some point? Are you working across different machines? Anyway, there are a few different ways to get back to a reasonable history I think, depending on your git-fu. The most manual way to do it where it's going to be mostly obvious what's going on is just to cherry-pick the commits you want to a new branch. First get your master up to date Now make a new branch. From here you can see what commits are in betareg that aren't in current master. Now you'll just cherry-pick these by hand over to your betareg-tmp branch. You can also skip some commits, if you want. For example, it looks like there is a duplicate commit with the message Then you just need to do that for each one you want. After that, you might push betareg-tmp to github and look at it, make sure the history looks right, etc. Then you can either make a new PR or delete your existing |
|
I like interactive rebase, which does essentially the same as cherry picking but git is doing most of the work, just removing lines with commits that we don't want. |
|
Interactive rebase is an option. I tried both (and a hard rebase, fixing |
|
I added a few more things in my branch. I will look at it a bit more tonight or tomorrow. |
|
Hi, I've used the gist and it works well, I'm interested in seeing this PR merged, is it still alive? |
|
@yoavram It's stalled, and on the "need to come back to this" waiting list. master...josef-pkt:betareg_2030_3 It will need updating to current master. AFAIR, there were some ideas in here and in related work that have in the meantime been implemented in a more general way or for other cases. |
|
Ok makes sense. I’ll use this gist in the meantime. |
|
I rebased my branch of this and opened #4238 From a very brief look at a commented out test failure, I think it either needs more work on optimization, or, maybe better, needs a "nicer" testcase that doesn't use identity link. |
|
I think I can provide a test case using simulated data which uses logit link, would that be helpful? |
|
@yoavram Yes, that would be helpful. |
|
just checking in to say that myself and plenty of people I know would be immensely grateful for a proper beta regression implementation to be available as part of a proper python package! AFAIK there literally isn't one anywhere else. |
|
looks like a problem from the renaming, this should not be closed dead because the original branch doesn't exist anymore |
|
This is a bug on GitHub when branches or reps don't exist. Numpy had 8 or
so.
…On Fri, Mar 26, 2021, 21:01 Josef Perktold ***@***.***> wrote:
looks like a problem from the renaming, this should not be closed
dead because the original branch doesn't exist anymore
—
You are receiving this because you are subscribed to this thread.
Reply to this email directly, view it on GitHub
<#2030 (comment)>,
or unsubscribe
<https://github.com/notifications/unsubscribe-auth/ABKTSRML3FPXN4PPQ5DA33DTFTY2FANCNFSM4AVNPX3Q>
.
|
|
I have them in my local clone, I just checked 2030 and I can create a branch from it. |
|
This is the only branch that was affected based on the list of recently updated, closed branches |
|
Hi, just wondering if this is still open? I'm very interested in seeing this in the statsmodels library, it would be immensely useful |
|
Still open. One of my favorite examples for planning and designing more general models, but I haven't done any work on that yet. |
|
@josef-pkt wonderful, thank you for the response! I have been having some issues relating to a "HessianInversionWarning" with the gist, so I'm very excited for a more stable option - would there happen to be any active branches that are more updated? |
This is an initial go at adding beta-regression starting from
GenericLikelihoodModelfor feedback.Here is the mailing list discussion: https://groups.google.com/forum/#!topic/pystatsmodels/3qEp-0YpEIc
and gist: https://gist.github.com/brentp/089c7d6d69d78d26437f
Josef suggested adding analytical derivatives and moving out of
miscmodels. I will require some hand-holding to implement that so I have left it inmiscmodelsfor now.Currently, it has a separate link for the precision parameter (a + b == phi), but the results are reported in the context of the link for the X covariates. I'm not sure how to separate them out in the summary()
The Z matrix for modeling the precision currently must be specified as a matrix. Perhaps it makes sense to allow a z_formula to the
from_formulamethod.I put the csv data for the tests in the
miscmodels/testsdirectory.The paper for R's
betaregincludes methods for bias-correction and bias-reduction, which I would like to implement eventually.