Calculate R^2 of two graphs

19 ビュー (過去 30 日間)
Oliver Makan
Oliver Makan 2021 年 11 月 12 日
コメント済み: Star Strider 2021 年 11 月 18 日
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

採用された回答

Star Strider
Star Strider 2021 年 11 月 12 日
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 件のコメント
Oliver Makan
Oliver Makan 2021 年 11 月 18 日
again thank you for your quick reply :)
Star Strider
Star Strider 2021 年 11 月 18 日
As always, my pleasure!
.

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

その他の回答 (1 件)

Oliver Makan
Oliver Makan 2021 年 11 月 18 日
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.

カテゴリ

Help Center および File ExchangeGet 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