1
$\begingroup$

The following equation: y = a*x**b where y is a nonlinear function of x. By taking logs, the equation can be expressed as: ln(y) = ln(a) + bln(x). I would like to run a quantile regression instead of least squares. In Python, Scipy.optimize.curve_fit can handle exponential model functions (since a is nonlinear) but the method doesn't allow for quantile regression. Questions:

  1. Is it a correct assumption that least squares cannot be used, i.e. because the intercept is nonlinear?
  2. If yes, how to fit using quantile regression?
$\endgroup$
3
  • $\begingroup$ What do you mean by "the intercept is nonlinear"? It's irrelevant whether you write it as $\log(a)$ or, say, $\alpha:$ it is involved in the model in a purely linear way. See stats.stackexchange.com/questions/148638 for the various meanings of "linear" and "nonlinear" in regression models. $\endgroup$
    – whuber
    Apr 14 at 16:36
  • $\begingroup$ your relationships are additive on the log scale and multiplicative on the log scale. If you want to model them without log transforming you have to include multiplicative terms in your model (regardless of least squares or quantile regression). $\endgroup$ Apr 14 at 17:39
  • 1
    $\begingroup$ Thanks, the post was helpful. Using the log transformation of the function, I can run a quantile regression model. In Python this would be something like model = smf.quantreg('np.log(y) ~ np.log(x)', df).fit(q=0.5) for a median fit. Then to get the intercept, I transform back using exp(a). $\endgroup$ Apr 14 at 19:00

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Browse other questions tagged or ask your own question.