Functions > Design of Experiments > Regression Analysis > Multivariate Polynomial Regression
  
Multivariate Polynomial Regression
polyfit(X, Y, n/"terms"/M)—Defines a function that describes a multivariate polynomial regression surface fitting the results recorded in matrix Y to the data found in matrix X. You can define the polynomial regression equation by its polynomial order n or by its terms as specified in the string “terms” or in matrix M. Use matrix M when you do not want to include the intercept in the polynomial fit.
For example, consider the polynomial regression function p:
p := polyfit(X, Y ,1)
p(v) = 1.075
Function p takes a vector argument v specifying a value of each independent variable of p, as described by matrix X. Each variable in vector v must have compatible units with the corresponding column of matrix X. The units returned by the fitting function p are compatible with the units of matrix Y.
Arguments
X is a design matrix or a matrix in which each column represents an independent variable. Each column of X must have compatible units.
Y is a vector or a matrix of measured or simulated results with each row containing the results for each run or data point defined in X. When the rows do not all contain the same number of replicates, you must pad the empty elements of Y with NaNs. The elements of matrix Y must have compatible units.
n is an integer specifying the polynomial order. It must be smaller than the total number of data points: 1 ≤ n ≤ length(Y) − 1. Otherwise, the problem is under constrained with no unique solution.
“terms” is a string specifying the terms, or the factors and interactions, to include in the polynomial regression. “A B AB AA BB” means that the polynomial contains the following terms:
c0 + c1∙A + c2∙B + c3∙A∙B + c4∙A2 + c5∙B2
For the separators, you can use a space, a comma, a colon, or a semicolon.
M is a matrix specifying a polynomial with guess values for the coefficients in the first column and the power of the independent variables for each term in the remaining columns. For the polynomial described above, define M as follows:
Additional Information
The Deprecated Functions topic recommends using the polyfit function as an alternate to the deprecated regress function.
The output of the regress function is a matrix of coefficients which is passed to the interp function in order to get the fitting function.
The output of the polyfit function is itself a fitting function and thus there is no need for calling the interp function.