Multivariable Polynomial Regression
|
10-09-2014, 08:27 PM
(This post was last modified: 03-10-2017 09:22 PM by Han.)
Post: #1
|
|||
|
|||
Multivariable Polynomial Regression
Please see the second post and onward. This program below is obsoleted by the polynomial_regression() command. However, if you wish to do 3D surface regression, the program in post #2 and onward are relevant to you.
Edit #1: apparently there is also the built-in command: polynomial_regression() which I just now noticed Edit #2: for a polynomial regression in 3D, see the second post in this thread Here is a program that will create a polynomial regression based on an input matrix m (of dimension 2xn, for n data points) and d, the degree of the polynomial. The result is a list containing
\[ \mathrm{polyfit}\left(\left[ \begin{array}{cccc} x_1 & x_2 & \dotsm & x_n \\ y_1 & y_2 & \dotsm & y_n \end{array} \right], d\right) \rightarrow \left\{ \left[ \begin{array}{c} a_0 \\ a_1 \\ \vdots \\ a_d \end{array} \right] , \text{``}a_0*X^0 + a_1*X^1 + a_2*X^2 + \dotsm + a_d*X^d\text{''}\right\} \] If you have data from the the Stat2Var app, you can easily create the data matrix via: Code: L1:=concat(C1,C2); To use the string representation of the polynomial, simply type in the Home screen: Code: mylist:=polyfit(M1,d); Below is the short source code for polynomial fit: PHP Code: pferror:={"polyfit(m,d): Graph 3D | QPI | SolveSys |
|||
10-13-2014, 10:28 PM
(This post was last modified: 11-10-2014 08:18 PM by Han.)
Post: #2
|
|||
|
|||
RE: Polynomial Regression
Here is a program that is best used in conjunction with the Stat2Var app. Eventually this will evolve into a full-blown app that will enable users to create 3D surface regressions (using polynomials of a degree specified by the user).
Usage as follows: \[ \mathrm{multireg}(\text{list_of_data},\text{degree}) \rightarrow \left\{ a_0, a_1, \dotsm, a_{k(d)-1} \right\} \] where \( k(d) = (d+1)(d+2)/2 \) and the 2-variable polynomial is of the form \[ f(x,y) = a_0 + a_1 x + a_2 y + a_3 x^2 + a_4 xy + a_5 y^2 + \dotsm + a_{k(d)-2} xy^{d-1} + a_{k(d)-1} y^d \] and the list_of_data parameter is a list of three lists (for the \( x_i \), \(y_i\), and \( z_i \) values). Typically the data would be pulled from C0 through C9 in the Stat2Var app. So list_of_data may be something like: { C1, C2, C3 }. The algorithm is essentially the same as that for 1-variable polynomial regression. Both cases use an appropriate Vandermonde matrix to solve for the critical point in the least sum-of-squared-residuals equation. (Please note that error checking for valid input data is very minimal.) Code: mrerr:={ Graph 3D | QPI | SolveSys |
|||
11-07-2014, 09:43 PM
(This post was last modified: 11-10-2014 08:22 PM by Han.)
Post: #3
|
|||
|
|||
RE: Polynomial Regression
Updated: Nov. 10, 2014
Here's a preview of the next release: Points \( (x_i, y_i, z_i) \) were created in the Stat2Var app in columns C1, C2, and C3. The black lines show the distance from the regression surface to the points above the surface, and the red lines from the surface to the points below it. I've included a beta release of the program below. How to use the programs multireg( { list1, list2, list3 }, degree ); plotmreg( { list1, list2, list3 }, regression ); where list1, list2, and list3 are each lists (e.g. C1, C2, and C3 in the Stat2Var app), degree is the degree of the 2-variable polynomial, and regression is result from multireg(). In the Stat2Var app, create your columns of data. Let's say your data are in C1, C2, and C3. Run the multireg() program using: L1:=multireg({C1,C2,C3},deg); where deg is the degree of the polynomial \( f(X,Y) \). Then run the plotmreg() program. Currently, you will also need manually adjust the viewing window (top of the source code): plotmreg({C1,C2,C3},L1); Code: // viewing window Graph 3D | QPI | SolveSys |
|||
« Next Oldest | Next Newest »
|
User(s) browsing this thread: 1 Guest(s)