Goodness of Fit from Gaussian Fit

조회 수: 27 (최근 30일)
Benjamin Zaugg
Benjamin Zaugg 2013년 4월 24일
Hi there, I have to analyze data (specificly area under curve) from an table with 2 coloumns and abou 1700 rows. I have used a a fit on the data:
fit_1 = fit(table([x0:x1],[1]),table([x0:x1],[2]),'gauss4');
this gives me the CFIT file named 'fit_1'
However, I would like to find out the Goodness of the fit (R squared) of my fit_1 compared to my table data, without using the cftool but integrate it into my existing function which I wrote.
Can somebody tell me if there is the possibility to do so outside of cftool and where I could find Information of how to do so?
Thanks a lot! Sorry for any typos & lack of knowledge (first post)
Greetings

답변 (1개)

Eric
Eric 2013년 4월 24일
편집: Eric 2013년 4월 24일
I use the following:
ybar = mean(y); %Mean of the data
sst = sum( (y - ybar).^2 ); %Total sum of squares
gof.sse = sum( (y - fit_vec).^2 ); %Residual sum of squares
gof.rsquare = 1 - gof.sse/sst;
See http://en.wikipedia.org/wiki/Coefficient_of_determination as a reference for the equation for gof.rsquare.
In this code y is the data and fit_vec is the fitted data.
-Eric

카테고리

Help CenterFile Exchange에서 Get Started with Curve Fitting Toolbox에 대해 자세히 알아보기

Community Treasure Hunt

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

Start Hunting!

Translated by