I am writing programming code to develop a polynomial equation from x,y data. I am using the least squares procedure to develop various sums to fill a matrix. Once the matrix is filled, computing poly coefficients is straight forward matrix algebra.
I have 29 reps of data that look like:
Rep x1 x2 x3 y
——————————————————————————————————————————
1
2
…
29
——————————————————————————————————————————
x2 and x3 have the form:
x2 = x1^2
x3 = x1^3
My problem is figuring out how to fill the 3x3 matrix cells that take the sum of products (SP).
The diagonal cells take the sum of squares (SS) which is:
SS = ∑X2 - (∑x)2/n This is for cells (1,1), (2,2) and (3,3), using x1, x2 and x3 respectively.
The non-diagonal cells take the sum of products (SP) which is:
SP = ∑(x1*x2) - ((∑x1)(∑x2))/n This is for cell (1,2)
The mirror cells are:
(2,1) = (1,2)
(3,1) = (1,3)
(3,2) = (2,3)
So the matrix I now have is:
∑X12 - (∑x1)2/n ∑(x1*x2)-((∑x1)(∑x2))/n ??? mirror of cell (1,2) ∑X22 - (∑x2)2/n ??? mirror of cell (1,3) mirror of cell (2,3) ∑X32 - (∑x3)2/n
The question marks are where I’m stumped. This procedure works great for a 2x2 matrix and a 2nd degree polynomial. But now I’m expanding to a 3x3 matrix for a 3rd degree polynomial. I’ve tried every combo of SP’s for cells (1,3) and (2,3), but to no avail.
I suspect this is simple, and aesthetically pleasing. I have not found the answer in the literature.
Any help is appreciated.
TJ


LinkBack URL
About LinkBacks