| File Information |
| Description |
Yes, I know. This is yet another in the long list of polynomial regression modeling tools. What does polyfitn do that the others don't? You can supply any list of terms, with any set of exponents: positive, negative, or real. It works in n-d as well as 1-d. And it has a simple, clean interface to specify your terms.
Simple statistics are generated, R^2, rmse, standard deviations and variances of the coefficients. I've supplied an evaluation tool to use the model.
x = -2:.1:2;
y = cos(x);
p = polyfitn(x,y,'constant x^2 x^4 x^6');
% Evaluation
polyvaln(p,[0 .5 1])
ans =
0.99996
0.8776
0.54031
% Conversion to a sympoly
polyn2sympoly(p)
A scalar sympoly object
0.99996 - 0.49968*x^2 + 0.041242*x^4 - 0.0012079*x^6
This last operation employs my own sympoly toolbox also found on the file exchange, although it is not necessary for use of polyfitn and polyvaln.
http://www.mathworks.com/matlabcentral/fileexchange/loadFile.do?objectId=9577&objectType=FILE
As another example, fit a complete 2-d model with all terms up to a second order model:
x = randn(100,2);
y = randn(100,1);
p = polyfitn(x,y,2);
% Display it as a sympoly, just makes it easy to read:
polyn2sympoly(p)
A scalar sympoly object
0.19175*X1^2 + 0.052769*X1*X2 + 0.093648*X1 + 0.039723*X2^2 - 0.04943*X2 - 0.19188
% Only want a linear model in 2-d, but with no constant term? Its easy to specify:
uv = rand(100,2);
w = sin(sum(uv,2));
p = polyfitn(uv,w,'u, v');
polyn2sympoly(p)
A scalar sympoly object
0.74604*u + 0.68452*v |
| Acknowledgements |
The author wishes to acknowledge the following in the creation of this submission:
Symbolic Polynomial Manipulation
|
| MATLAB release |
MATLAB 7.0.1 (R14SP1)
|
| Zip File Content |
|
| Published M Files |
polyfitn_demo
|
| Other Files |
PolyfitnTools/ReadMe.rtf, PolyfitnTools/test/test_main.m, PolyfitnTools/demo/html/polyfitn_demo.png, PolyfitnTools/demo/html/polyfitn_demo_01.png, PolyfitnTools/demo/html/polyfitn_demo_02.png, PolyfitnTools/polyvaln.m, PolyfitnTools/polyfitn.m, PolyfitnTools/polyn2sym.m, PolyfitnTools/polyn2sympoly.m, PolyfitnTools/demo/polyfitn_demo.m
|
|
Tags for This File
|
| Everyone's Tags |
|
| Tags I've Applied |
|
| Add New Tags |
Please login to tag files.
|
| Comments and Ratings (24) |
| 03 Mar 2006 |
Duane Hanselman
|
|
|
| 12 Apr 2006 |
Vassili Pastushenko
|
|
|
| 12 Apr 2006 |
Vassili Pastushenko
|
|
|
| 13 Apr 2006 |
Vassili Pastushenko
|
|
|
| 17 Apr 2006 |
Tony Flipper
|
|
|
| 06 Dec 2006 |
g hunter
|
|
|
| 27 Feb 2007 |
ye zhang
|
|
|
| 16 Mar 2007 |
Jean-Luc Dellis
|
|
|
| 11 May 2007 |
Oh-ig Kwoun
|
|
|
| 28 Sep 2007 |
Simon Ren
|
|
|
| 20 Nov 2007 |
guido spinola
|
|
|
| 14 Feb 2008 |
Rajneesh Kumar
|
|
|
| 29 Mar 2008 |
Vincent Morio
|
|
|
| 18 Apr 2008 |
Muhammad Ihsan Salim
|
|
|
| 24 Apr 2008 |
Rebecca Bendick
|
|
|
| 25 Apr 2008 |
John D'Errico
|
|
|
| 19 Nov 2008 |
Richard Crozier
|
|
|
| 21 Nov 2008 |
Richard Crozier
|
|
|
| 21 Nov 2008 |
John D'Errico
|
|
|
| 30 Jan 2009 |
Mohsen Nosratinia
|
|
|
| 17 Feb 2009 |
Gavrilo Bozovic
|
|
|
| 20 May 2009 |
Agustin Pimstein
|
|
|
| 20 May 2009 |
John D'Errico
|
|
|
| 09 Jun 2009 |
Michal Kvasnicka
|
|
|
| Updates |
| 24 Feb 2006 |
Fixed a bug for when depvar is a row vector. Also cleaned up the documentation some more, and the demos. Added HTML. |
| 01 Aug 2007 |
Trap for number of data points too few to estimate parameter variances. Also removed the .DS_store file from the zip. |
| 08 Aug 2007 |
Bug fixed - linear 1-d models with no intercept requested, could still try to estimate the intercept.
Doc fix - added a better description of the standard form for a linear polynomial regression. |
| 08 Aug 2007 |
Bug fixed - linear 1-d models with no intercept requested, could still try to estimate the intercept.
Doc fix - added a better description of the standard form for a linear polynomial regression. |
| 26 Sep 2007 |
Repair a bug in polyn2sympoly. The result was always "correct", but the Coefficients field was transposed in shape. This prevented some sympoly operations from working properly. |
| 20 Mar 2008 |
Repaired a problem with polyfitn, when a model with fewer independent variables than those supplied is estimated. Also repaired a glitch in the help for polyvaln. |
|