Search code examples
python-2.7regressionquantilenon-linear-regressionquantile-regression

Quantile regression in python


I have a data set in python (python 2.7). I want to find the Quantile regression for this data set. Can anybody help me to how to solve it? Thank you. Here is my code:

import numpy as np
import matplotlib.pyplot as plt
X = np.random.random(100)
noise = np.random.normal(0, 0.05, 100)
Y = X*X*X
Y = Y+noise
plt.plot(X,Y, 'o', color='black')
plt.show()

Solution

  • Statsmodels library has two implementations of quantile regression. The first is by using statsmodels.regression.quantile_regression.QuantReg and the other one is statsmodels.formula.api.quant_reg
    There is a marginal difference between the two and further reading can be done here.