Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

add AsymmetricLaplace family (Quantile Regression) #591

Merged
merged 2 commits into from
Nov 25, 2022

Conversation

aloctavodia
Copy link
Collaborator

@aloctavodia aloctavodia commented Nov 24, 2022

This is useful for performing quantile regression. To do so we have to fix the value of the kappa parameter to a suitable value. For example, to fit the 0.1 quantile we do the following:

q = 0.1
κ = (q/(1-q))**0.5
Model("y ~ x", data, family="asymmetriclaplace", priors={"kappa":κ})

The following figure shows the fit to the 0.1 and 0.9 quantiles

quantile_regression

Having to transform from q to κ can be annoying, So I will add an alternative parametrization to the AssymetricLaplace in PyMC, so we can directly set the quantiles.

@tomicapretto
Copy link
Collaborator

See this for why tests are failing #589 (comment)

do you think we have to constrain either to PyMC >= 4.4 or PyMC < 4.4?

Another option is to determine the name of the argument at runtime, checking what's the PyMC version being used.

@aloctavodia
Copy link
Collaborator Author

I think it is better to just restraint the pymc version

@tomicapretto
Copy link
Collaborator

Do you plan to merge this only after the parametrization is implemented in PyMC, or do you plan to merge this and then open a new PR to update?

@aloctavodia
Copy link
Collaborator Author

I was planning on doing a follow-up PR, so we don't need to wait. But I am open to alternatives

@tomicapretto
Copy link
Collaborator

I was planning on doing a follow-up PR, so we don't need to wait. But I am open to alternatives

I think that's fine. I don't think many people are going to use this feature right now before you open the follow-up PR. Let's do the following:

  • Merge this
  • Open PR to restrict the version of PyMC to >= 4.4 (I can do it now)
  • Follow up PR on this issue

Sounds good?

@aloctavodia
Copy link
Collaborator Author

sounds good to me. I will also add an example in a future PR.

@tomicapretto tomicapretto merged commit e61f0d5 into bambinos:main Nov 25, 2022
@aloctavodia aloctavodia restored the qr branch December 6, 2022 16:49
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants