Save error R² of an interpolation curve in variable

1 回表示 (過去 30 日間)
Mepe
Mepe 2020 年 3 月 12 日
編集済み: John D'Errico 2020 年 3 月 12 日
A polynomial compensation curve with its coefficients is determined at various measuring points.
myfit=fit(x,y,'poly2');
A=myfit.p1
B=myfit.p2
C_=myfit.p3
Now i still need the error of this interpolation (R²). Can it also be read and stored in a variable?

採用された回答

John D'Errico
John D'Errico 2020 年 3 月 12 日
編集済み: John D'Errico 2020 年 3 月 12 日
You misunderstand the idea of interpolation, confusing it with approximation.
R^2 is identically 1 for an interpolation, since interpolation is defined so that it always predicts the original data. So an interpolating spline has always zero residuals in theory, therefore, R^2 == 1.
Anyway, just read the help for fit!!!!!!!
x = rand(10,1);
y = randn(size(x));
[mdl,G] = fit(x,y,'poly2')
y = randn(size(x));
[mdl,G] = fit(x,y,'poly2')
mdl =
Linear model Poly2:
mdl(x) = p1*x^2 + p2*x + p3
Coefficients (with 95% confidence bounds):
p1 = 1.399 (-3.992, 6.791)
p2 = -0.1758 (-5.699, 5.347)
p3 = -0.4521 (-1.34, 0.4359)
G =
struct with fields:
sse: 2.72060725180258
rsquare: 0.468192584870819
dfe: 7
adjrsquare: 0.316247609119625
rmse: 0.623424557447764
As you can see, G has fields that answer your question: G.rsquare, and G.adjrsquare.

その他の回答 (0 件)

カテゴリ

Help Center および File ExchangeInterpolation についてさらに検索

Community Treasure Hunt

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

Start Hunting!

Translated by