Non-Linear Regression Methods
14 views (last 30 days)
Show older comments
Ho Nam Ernest Yim
on 3 Apr 2018
Edited: Ho Nam Ernest Yim
on 3 Apr 2018
Hi everyone, currently I want to study different regression methods with the help of MATLAB built-in function and compare them according to how well the methods fit. Basically, I have got a set of Data which give me 3D cures (x,y,z) when I use lsqcurvefit and it works pretty well. I have also look into different methods for non-linear regressions such as fitnlm, glmfit and lsqnonlin (same as lsqcurvefit?). However in fitnlm, the input format can only be
nlm = fitnlm(x,y,@function,beta0)
like most of them do not have same format of input as lsqcurvefit allowing me to input x,y,z in the function. Therefore, can I have some suggestions which allow me to fit 3D nonlinear data other than the above options? And how do I know how well will the function fits? Or did I use fitnlm glmfit wrongly?
0 Comments
Accepted Answer
John D'Errico
on 3 Apr 2018
Edited: John D'Errico
on 3 Apr 2018
READ THE HELP.
For example, a fragment of the help for fitnlm:
NLM = fitnlm(X,Y,MODELFUN,BETA0) fits a nonlinear regression model
using the column vector Y as a response variable and the columns of the
matrix X as predictor variables.
So if you have TWO independent variables, they would be passed in as two columns of the ARRAY X.
As far as LSQNONLIN goes, it can handle any number of independent variables, because it only cares about the residual vector. You don't even pass in data to LSQNONLIN, just a function.
GLMFIT does not accept nonlinear models. But as long as the model is linear in the coefficients, there is no problem. It can still be nonlinear in the independent variable, since you pass in an array of data. And it does handle the case of multiple independent variables, since you must create the array X.
Of course, there is also NLINFIT, which is able to handle an array of multiple independent variables.
So basically, you need to read the help. Different tools handle a variety of problems.
4 Comments
John D'Errico
on 3 Apr 2018
Edited: John D'Errico
on 3 Apr 2018
You have not been clear about your problem.
Assuming that you are trying to model a surface, thus z(x,y)
X = [x(:),y(:)]
Y = z(:);
x and y are called independent variables, or predictor variables. z is the dependent variable, thus the response variable.
The idea is you can try to evaluate this unknown function for any combination of x and y, getting out z(x,y).
This presumes that the noise lies in z, as a "measured" value. It is the classic problem that tools like lsqcurvefit, lsqnonlin, fitglm, nlinfit, are all designed to solve.
Your questions seem to imply that your problem is not a classic one. But you have not said enough to know what it is that makes it non-classic.
If your problem has noise in each of x, y, and z, then this is called an errors in variables problems, or sometimes total least squares. It is much more difficult to handle. None of the codes that you mention handle that problem. Use of a standard tool that presumes error only in z will produce results with biased estimates of the parameters, so while it will provide a solution, the solution will be problematic under conditions of significant noise or large residuals.
Note that lack of fit of your model to the data will be interpreted as noise. Even though lack of fit will usually be seen as patterned noise, it is still residual error. Any such tool assume the model that you pose is the correct model, so any residuals must be in the form of "noise".
If your problem is not a surface, but some general curvilinear path through the 3-d space (x,y,z), then again, this is a case where you will have problems. Now, people seem to think they can just try to solve for the coefficients using nonlinear regression. In fact, this is again an errors in variables problem, because the equation of the path is usually an implicit function of all three variables.
So without more clarity on your part about the problem you may want to solve, I cannot say much more without writing at least several books on the subject.
More Answers (0)
See Also
Categories
Find more on Nonlinear Regression in Help Center and File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!