Plotting a line which would include 95% of points above and below the regression line

2 ビュー (過去 30 日間)
Hello,
I have used the segmented regression method to plot linear lines over my scatter plot. Now I want to draw a line parallel to the segmented regression line, both above and below (+ & -), which would include approximately 90-95% of the points.
Can anybody help me with this? thank you

採用された回答

Ahmet Cecen
Ahmet Cecen 2016 年 11 月 14 日
Find your residual vector.
Use prctile() on the residual vector to find the points at your upper and lower bounds.
Solve the equation BoundY = Slope*BoundX + Location, for Location.
Plot the lines with both the upper and lower bound Locations.
  3 件のコメント
Ahmet Cecen
Ahmet Cecen 2016 年 11 月 14 日
Well you in the end, you should have a function as a result of your regression in the form:
Yestimate = f(variables);
Residuals are simply:
Yactual - Ytraining
Then you can find the value at which the residuals are bigger than a certain value using prctile(Residuals,percentilevalue).
Now you can find the index of the yactual at which you observe that residual, then plot a line through it to achieve the desired effect.
Tushar Agarwal
Tushar Agarwal 2016 年 11 月 15 日
Thankyou I was able to solve this.

サインインしてコメントする。

その他の回答 (0 件)

カテゴリ

Help Center および File ExchangeLinear Regression についてさらに検索

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by