1

When computing the Pseudo R-squared value in quantreg in R or statsmodel in Python, what is an acceptable range to justify goodness of fit? Also, what is the functional form of Pseudo R-Squared computed in those packages?

Him
  • 31

1 Answers1

1

As far as what constitutes a good value for a performance metric, this answer explains why that is context-dependent, so there is no hard rule. This makes a lot of sense. While one might view $R^2$ -style metrics as being like letter grades in school where $R^2=0.9$ is the kind of score that seems like an $\text{A}$-grade that makes us happy while $R^2=0.4$ is the kind of score that seems like an $\text{F}$-grade that makes us sad, I remember celebrating a $41\%$ on an extremely challenging exam in graduate school that qualified as one of the higher scores in the class, so even letter grades in school are not as simple as $90/80/70/\text{etc}$.

As far as what constitutes an $R^2$-style metric for quantile regression, it depends on what you want your metric to tell you. My take on the usual $R^2$ is that it is a comparison of the performance of your model on some metric of interest (sum of squared residuals, for the usual $R^2$) to the performance of a "must-beat" model. With that in mind, the typical loss function for quantile regression, much like how the typical loss function for linear regression is the sum of squared residuals, is the quantile loss ("pinball loss" in many circles), $L_{\tau}(y, \hat y)$ in the language below.

$$ l_{\tau}(y_i, \hat y_i) = \begin{cases} \tau\vert y_i - \hat y_i\vert, & y_i - \hat y_i \ge 0 \\ (1 - \tau)\vert y_i - \hat y_i\vert, & y_i - \hat y_i < 0 \end{cases}\\ L_{\tau}(y, \hat y) = \sum_{i=1}^n l_{\tau}(y_i, \hat y_i) $$

As I discuss here, a reasonable $R^2$-style performance metric for a quantile regression would compare the pinball loss of your model to the pinball loss of a "must-beat" model that always predicts the $\tau^{th}$ quantile of all $y$ values combined together. This is more-or-less implemented in Python using sklearn.metrics.d2_pinball_score, though I have some issues with how sklearn performs and documents the calculation. (I have strong feelings about how to calculate the $R^2$-style metrics when it comes to out-of-sample performance, and the sklearn $D^2$ function suffers from the same issues I bemoan in the link. Further, sklearn remarks that the $D^2$ is the proportion of pinball loss explained by the model. This alludes to how $R^2$ is a measure of the proportion of variance explained by a linear regression model, though this breaks down in all but the nicest of circumstances (1)(2), and I expect the same to happen for $D^2$.)

Dave
  • 62,186