Skip to content

Quantile Regression #908

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

Draft
wants to merge 10 commits into
base: master
Choose a base branch
from
Draft

Quantile Regression #908

wants to merge 10 commits into from

Conversation

s3alfisc
Copy link
Member

@s3alfisc s3alfisc commented May 20, 2025

What this PR does:

  • Implements quantile regression via a quantreg function via the Frisch-Newton Interior Point solver as described in Koenker and Ng or Portnoy & Koenker.
  • Additionally, implements preprocessing as explained in Chernozkukov et al or Portnoy & Koenker mentioned above.
  • Implements skeleton of Algo 2 in Chernozhukov et al "Preprocessing for the quantile regression process"
  • Implements a qplot method for visualization.

Status:

  • Runs, with some minor bugs (i.e. poorly initialised starting values), non-convergence.
  • Tests against R implemented.
  • Tests against R pass.
  • Only one vcov type supported so far, no clustering. Seems to have bugs as SEs are completely off (see below).
  • Add function arguments to quantreg function: rng, tol, maxiter.
  • Get @kinto-b to port the FN algo to Rust ;-)

Example:

%load_ext autoreload

import pyfixest as pf
data = pf.get_data(N = 1000)

fit_1_pf = pf.quantreg("Y ~ X1 + X2 + f1", data = data, quantile = 0.1)
fit_1_pf.tidy()

# Estimate	Std. Error	t value	Pr(>|t|)	2.5%	97.5%
# Coefficient						
# Intercept	-2.030300	0.000023	-90149.457722	0.0	-2.030344	-2.030256
# X1	    -0.938896	0.000097	-9704.853077	0.0	-0.939086	-0.938706
# X2	    -0.190710	0.000004	-51162.093928	0.0	-0.190718	-0.190703
# f1	     0.011888	0.000480	24.749725	0.0	0.010946	0.012831

R instead:

quantreg::rq(formula = Y ~ X1 + X2 + f1, tau = 0.1, data = data, method = "fn")
# Coefficients:
# (Intercept)          X1          X2          f1 
# -2.03029974 -0.93889613 -0.19071031  0.01188816 

@s3alfisc s3alfisc marked this pull request as draft May 20, 2025 19:38
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.

1 participant