how to use cfit to get fitobject and gof from a separately provided line

2 ビュー (過去 30 日間)
Rory Staunton
Rory Staunton 2011 年 4 月 29 日
Hi all,
I have a basic general question:
I am using [fitobject,gof]=fit(x,y,'poly1') to fit line segments.
I want to provide my own fit coefficients and get the same type of output about the goodness of fit.
How can I generate fitobject and gof using my independently provided fit coefficients, so that they will be in the same structure format as those generated by the 'fit' function?
thanks,
Rory

回答 (1 件)

Richard Willey
Richard Willey 2011 年 4 月 29 日
The aren't any constructor options for the Fit Objects in Curve Fitting Toolbox.
The easiest way to accomplish your goal is to set upper and lower bounds for your coefficients that will constraint them to a precise value. For example, suppose that you wanted to force the regression coefficients to be "3" and "8"
X = 1:100
X = X'
Y = 5 + 10*X + randn(100,1)
[foo GoF] = fit(X,Y, 'poly1', 'Lower',[3 8], 'Upper',[3 8])
  2 件のコメント
Rory Staunton
Rory Staunton 2011 年 4 月 30 日
Thanks Richard,
The fit lines are being selected manually in a piecewise fashion from scatterplots of noisey experimental data. I have made algorithms for doing this automatically, which use regression to fit the lines, but the trouble lies in choosing the piecewise fitting regions. I want to do it manually so I can train my algorithm and have something trustworthy to check against. (Nothing is better than the eye!)
I think my best bet is to write some quick script that will calculate the sse, rsquare, dfe, adjrsquare, and rmse of my fit line with respect to the part of the raw data I am fitting. These are the parameters in the gof fields. I imagine looking up each of those functions in help will get me what I need.
Thanks again,
Rory
Rory Staunton
Rory Staunton 2011 年 5 月 2 日
It's not clear to me how MATLAB is calculating the number of degrees of freedom. Is this the degrees of freedom of the of the estimate of the population variance of the dependent variable, or the degrees of freedom of the estimate of the underlying population error variance?

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

Community Treasure Hunt

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

Start Hunting!

Translated by