Save error R² of an interpolation curve in variable

1 vue (au cours des 30 derniers jours)
Mepe
Mepe le 12 Mar 2020
Modifié(e) : John D'Errico le 12 Mar 2020
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?

Réponse acceptée

John D'Errico
John D'Errico le 12 Mar 2020
Modifié(e) : John D'Errico le 12 Mar 2020
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.

Plus de réponses (0)

Catégories

En savoir plus sur Interpolation dans Help Center et File Exchange

Community Treasure Hunt

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

Start Hunting!

Translated by