Code covered by the BSD License  

Highlights from
Optimal polynomial fitting

4.0

4.0 | 2 ratings Rate this file 11 Downloads (last 30 days) File Size: 2.95 KB File ID: #29865

Optimal polynomial fitting

by Damien Garcia

 

30 Dec 2010

Optimal polynomial fitting according to the Akaike's information criterion.

| Watch this File

File Information
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
-----

MATLAB release MATLAB 7.7 (R2008b)
Tags for This File  
Everyone's Tags
Tags I've Applied
Add New Tags Please login to tag files.
Comments and Ratings (2)
14 Jan 2011 Zacharias Voulgaris

Very intriguing program, brilliant in its simplicity. It tackles very effectively the over-fitting issue that often appears in various regression scenarios. Also, very easy to use and well documented.

It would be much more practical though if it actually yielded the coefficients of this polynomial (at least have the option to do so). This way the user won't have to run polyfit.m to find them.

23 Feb 2012 Erdal Bizkevelci  
Please login to add a comment or rating.
Tag Activity for this File
Tag Applied By Date/Time
polynomial fitting Damien Garcia 03 Jan 2011 12:20:33
akaikes information criterion Damien Garcia 03 Jan 2011 12:20:33
akaikes information criterion Vitaly 31 May 2011 19:43:20

Contact us at files@mathworks.com