MATLAB: Non-Linear Regression Methods

3d plotscurve fittingdatabasefitnlmfitting dataglmfitlsqcurvefitnonlinearnonlinear regressionregression

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?

Best Answer

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.