Using trapezoidal method (because I have a vector and no function is available) I know how to calculate the area difference one gets when the integral (Fig. 1) is cut by a horizontal line such as the mean (Fig. 2). The areas above the line become positive, the areas below negative.
$$\quad\sum_{k=1}^{N}\frac{x_{ik-1} + x_{ik}}{2}\Delta t_k-\bar{x}_{i}\big(t_{k} - t_{1}\big)$$
But how to do this when the line has a slope, such as a quantile regression line (Fig. 3)?
