Data fitting and slop
46 ビュー (過去 30 日間)
古いコメントを表示
Hi Im interested to plot XY which is a curve also Im interested to fit a best fit curve through data which should follow the data trend as is and then the point from where curve is changing or having maximum curvature, (X-value at that point) and a best fit line from the trend where values are straight to get intercept, After getting intercept I would like to use intercept and slop to draw another model on same graph. please see the attached figure for detailed idea.
Guide me please Thank you
0 件のコメント
採用された回答
dpb
2014 年 6 月 14 日
編集済み: dpb
2014 年 6 月 15 日
That's what is known as "piecewise" or "broken-stick" regression model. To incorporate the breakpoint into the model is often called a "change point" regression. It's relatively simple to do, but is a nonlinear problem.
The change point model starts with the broken-stick model, i.e.
Y=b0 + b1(X) + b2(X-C) + e
where
Y is the response variable,
X is the covariate, and
CP is the change point, i.e. where the break occurs.
e is the error term
To formulate a changepoint model into a functional form that can use to estimate the coefficients b and C, write something like
CP=b(4);
if (X < CP) then
Y = b(1) + b(2)*X;
else
Y = b(1) + b(2)*X + b(3)*(X-CP);
end
as the functional and use Matlab lsqnonlin
I left CP in as the changepoint to make the code read a little more easily while Matlab uses the array for all the coefficients.
ADDENDUM
That is, the "real" function would look more like--
if (X < b(4)) then % b4 is the estimated breakpoint value
Y = b(1) + b(2)*X;
else
Y = b(1) + b(2)*X + b(3)*(X-b(4));
end
0 件のコメント
その他の回答 (0 件)
参考
カテゴリ
Help Center および File Exchange で Linear and Nonlinear Regression についてさらに検索
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!