| Description |
N = POLYDEG(X,Y) yields the optimal degree N for polynomial fitting of the data Y(X). The degree N is determined by minimizing the Akaike's information criterion.
[N,YI] = POLYDEG(X,Y) also returns the fitted data YI.
Least-square curve fitting using polynomials is the most basic way to perform a parametric regression analysis. Assume that you have some data points through which you want to pass a fitting polynomial. The obvious question for some to ask is which degree to choose. A linear approximation might represent your data very poorly. On the other side, a high-order olynomial, say 30, could result in an excessively complex model (overfitting). Clearly, a compromise must be made between the precision and the complexity of the polynomial model. Akaike's information criterion (AIC), developed by Hirotsugu Akaike, can be used as a measure of the goodness of fit.
The AIC describes the tradeoff between the accuracy and complexity of a model. For a polynomial of degree N the Akaike's information criterion is defined by:
AIC = 2*(N+1) + n*(log(2*pi*RSS/n)+1),
where n is the number of points and RSS is the residual sum of squares. The optimal degree is defined as the degree N which minimizes AIC.
------
Example:
x = linspace(0,10,1000);
y = sin(x.^3/100).^2 + 0.05*randn(size(x));
[n,yi] = polydeg(x,y);
plot(x,y,'.',x,yi,'r','LineWidth',2)
title(['Optimal degree: ' int2str(n)])
-----
www.biomecardio.com
----- |