Borrar filtros
Borrar filtros

Calculate R^2 of two graphs

16 visualizaciones (últimos 30 días)
Oliver Makan
Oliver Makan el 12 de Nov. de 2021
Comentada: Star Strider el 18 de Nov. de 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

Respuesta aceptada

Star Strider
Star Strider el 12 de Nov. de 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
X = 50×4
1.0e+05 * 0.0000 0.0000 0.0000 0.0000 0.0001 0.0000 0.0000 0.0000 0.0005 0.0001 0.0000 0.0000 0.0015 0.0003 0.0001 0.0000 0.0035 0.0005 0.0001 0.0000 0.0067 0.0008 0.0001 0.0000 0.0116 0.0011 0.0001 0.0000 0.0183 0.0015 0.0001 0.0000 0.0272 0.0019 0.0001 0.0000 0.0387 0.0025 0.0002 0.0000
[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'})
ParameterStats = 4×3 table
Lower 95% CI Parameter Value Upper 95% CI ____________ _______________ ____________ x^3 5.1529e-06 7.0396e-06 8.9263e-06 x^2 -0.0011438 -0.0008994 -0.00065504 x 0.031404 0.040307 0.049211 Const -0.21537 -0.12867 -0.041973
Rsq = Stats(1)
Rsq = 0.9192
F_p = [Stats(2:3)]
F_p = 1×2
174.3300 0.0000
ErrorVar_Est = Stats(4)
ErrorVar_Est = 0.0066
figure
plot(x, y, '+b')
hold on
plot(x, X*B, '-r')
hold off
grid
Experiment with the actual data.
.
  3 comentarios
Oliver Makan
Oliver Makan el 18 de Nov. de 2021
again thank you for your quick reply :)
Star Strider
Star Strider el 18 de Nov. de 2021
As always, my pleasure!
.

Iniciar sesión para comentar.

Más respuestas (1)

Oliver Makan
Oliver Makan el 18 de Nov. de 2021
Hi Star Strider,
thank you for the quick approach.
Just for a better understanding:
The regression is a polynomial x^3 regression with x&y graph tested on which data ?
additional, is it possible to get the goodness of fit of a function F=exp^(x/d) to the dataset x/y.
What does the matrix X stand for ?
again thank you very much.

Categorías

Más información sobre Descriptive Statistics en Help Center y File Exchange.

Community Treasure Hunt

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

Start Hunting!

Translated by