The pinball (quantile) loss for level τ∈(0,1) is ρτ(r)=τr if r≥0 and (τ−1)r if r<0, with r=y−c. Show that the constant c minimising E ρτ(Y−c) is the τ-quantile of Y. How do you check it numerically for τ=0.7 on {1,2,3,4,10}?

Supervised learning, Quantile regression
Level L3 Intermediate. Length Long. Nature Th+Mat Both.

What's being asked

Whether you can derive that the pinball loss elicits quantiles (just as squared loss gives the mean and absolute loss gives the median), by differentiating under the expectation.

Key idea

ddcEρτ(Y−c)=F(c)−τ, where F is the cumulative distribution function of Y. The minimiser is where F(c) crosses τ.

Steps

  1. Write the expected loss as Eρτ(Y−c)=τ∫c∞(y−c) dF(y)+(1−τ)∫−∞c(c−y) dF(y).
  2. Differentiate in c (the boundary terms vanish because the integrands are zero at y=c): −τ P(Y>c)+(1−τ) P(Y<c).
  3. Simplify using P(Y>c)=1−F(c): the derivative is −τ+τF(c)+(1−τ)F(c)=F(c)−τ.
  4. The derivative is negative while F(c)<τ and positive once F(c)>τ, so the loss is convex in c with its minimum at the τ-quantile. For τ=0.5 this is the median, and ρ0.5(r)=12∣r∣.
  5. Numerical check with τ=0.7. At c=3 the residuals y−c are −2,−1,0,1,7. Negative residuals cost 0.3∣r∣ and positive ones 0.7r, so the total is 0.3(2+1)+0.7(1+7)=0.9+5.6=6.5.
  6. At c=4 the residuals are −3,−2,−1,0,6, giving 0.3(3+2+1)+0.7⋅6=1.8+4.2=6.0. At c=5 the residuals are −4,−3,−2,−1,5, giving 0.3⋅10+0.7⋅5=3+3.5=6.5.
  7. So c=4 is lowest. It is the 0.7-quantile: F(3)=0.6<0.7≤F(4)=0.8. Note the slopes: moving from 3 to 4 the loss falls by 0.5, moving from 4 to 5 it rises by 0.5.
  8. Use: fit a model f(x) with this loss to predict conditional quantiles, for example the 0.9 quantile for demand forecasting, or two quantiles to form a prediction interval.

Common mistakes

How long your answer should be

One page; 8 minutes.

Last checked on 4 December 2026.

Read this

Previous in Supervised learning: Locally weighted linear regression predicts at a query xq by minimising ∑iwi (yi−θ0−θ1xi)2 with weights wi=exp⁡ ⁣(−(xi−xq)2/(2τ2)). For the data (0,1),(1,3),(2,2), bandwidth τ=1 and query xq=0, compute the prediction. How does it compare with the ordinary least-squares prediction at x=0?
Next in Supervised learning: Gradient boosting for binary classification uses the log loss with F(x) as the log-odds. The data are x=1,2,3,4,5 with labels y=1,1,0,0,0. Start from the best constant, grow a stump that splits between x=2 and x=3, and use Newton leaf values with learning rate 0.5. What are the new probabilities?