Understanding Polyfitn
Understanding Polyfitn
Understanding Polyfitn
John R. D'Errico
woodchips@rochester.rr.com
8/8/06
Regression modeling
Draper, N.R., Smith, H.; "Applied Regression Analysis"; John Wiley &
Sons
Care has been taken in the numerical methods of polyfitn, first by use
of a QR factorization with pivoting to solve the system. This is more
stable than the simple, unpivoted QR. I've also used automatic variable
scaling to deal with a simple cause of ill-conditioning.
A*x = y
- Backslash (\)
- PINV
- LSQR
- The normal equations, i.e., x = (A' * A)\(A' * y)
- QR decomposition
- Pivoted QR decomposition
Given the design matrix A in the above expression, the first task is to
scale it so that all columns have unit mean. While I'd like to introduce
a shift also for the best possible estimates, this is not possible for a
general multinomial model, as it may introduce additional terms into
the model. For example, suppose the polynomial model we must
estimate is
y = a1*x + a2*x^2
A*D*inv(D)*x = y
D = diag(1./mean(A,1));
If we write
z = inv(D)*x
(A*D)*z = y
n = 50;
X = randn(n,3);
X = X(:,[1 2 2 3]);
Note that the third column is actually just a copy of the second
column. Now, generate Y as the simple sum of columns [1 2 4] of X.
Y = X*[1;1;0;1] + randn(n,1)/100000;
Can we estimate
- A model specification