Calculate R^2 of two graphs
16 Ansichten (letzte 30 Tage)
Ältere Kommentare anzeigen
Oliver Makan
am 12 Nov. 2021
Kommentiert: Star Strider
am 18 Nov. 2021
Hi guys,
I wanted to know if it is possible to calculate the goodness of fit or R^2 to evaluate the performance of the fit.
I have two separate graphs which are separately calculated: the probability plot (brown) and the dataset (blue cross).
I know that it is able to fit a predefined graph ( e.g. quadratic, polynomial etc.) to a dataset with the toolbox but is it possible to fit my calculated graph to the dataset ?
Thank you
![](https://www.mathworks.com/matlabcentral/answers/uploaded_files/798089/image.png)
![](https://www.mathworks.com/matlabcentral/answers/uploaded_files/798094/image.png)
0 Kommentare
Akzeptierte Antwort
Star Strider
am 12 Nov. 2021
One approach —
x = linspace(0.1, 85, 50); % Create Data
y = atanh((x-mean(x))/max(x)*2)/4+0.5 + randn(size(x))*0.01; % Create Data
X = [x(:).^3 x(:).^2 x(:) ones(size(x(:)))]; % Design Matrix
[B,Bint,R,Rint,Stats] = regress(y(:), X);
ParameterStats = table(Bint(:,1), B, Bint(:,2), 'VariableNames',{'Lower 95% CI','Parameter Value','Upper 95% CI'}, 'RowNames',{'x^3','x^2','x','Const'})
Rsq = Stats(1)
F_p = [Stats(2:3)]
ErrorVar_Est = Stats(4)
figure
plot(x, y, '+b')
hold on
plot(x, X*B, '-r')
hold off
grid
Experiment with the actual data.
.
3 Kommentare
Weitere Antworten (1)
Siehe auch
Kategorien
Mehr zu Descriptive Statistics finden Sie in Help Center und File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!