Calculate R^2 of two graphs
40 visualizzazioni (ultimi 30 giorni)
Mostra commenti meno recenti
Oliver Makan
il 12 Nov 2021
Commentato: Star Strider
il 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
0 Commenti
Risposta accettata
Star Strider
il 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 Commenti
Più risposte (1)
Vedere anche
Categorie
Scopri di più su Descriptive Statistics in Help Center e File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!