Data fitting and slop

44 次查看(过去 30 天)
amberly hadden
amberly hadden 2014-6-14
编辑: dpb 2014-6-15
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

采纳的回答

dpb
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 个)

类别

Help CenterFile Exchange 中查找有关 Linear and Nonlinear Regression 的更多信息

Community Treasure Hunt

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

Start Hunting!

Translated by