# How do I use nonlinear Regression to fit my data into a particular function?

I have a data set with three columns, say, $Y$, $X_1$ and $X_2$ of which $Y$ is the dependent variable (on $X_1$ and $X_2$). I need to know how to use any software (I have MATLAB) to develop a model in the form:

$$\hat Y=f(X_1,X_2)=\frac {1+aX_1+bX_2}{1+cX_1+dX_2}$$

where $a$,$b$,$c$,and $d$ are constant coefficients. Can someone help me with a step-by-step guide?

• (1) Please edit your title to make it more descriptive. (2) It looks like you mean to say that X1, X2, and Y are vectors, not entire datasets. Is this correct? (3) What do you mean by "develop a correlation for a model"? This is not a sensible use of the term "correlation". – Kodiologist Aug 12 '16 at 17:06
• @Kodiologist, many thanks for your response. Please what do you mean by vectors and datasets? By correlation, I basically mean, a function in that form shown above where a,b,c, and d are obtained statistically from the given data of (Y, X1, and X2). – Sean001 Aug 12 '16 at 17:30
• Do you have any idea what a,b,c,d should be? Are there any constraints (restrictions) on their values? If not, there are going to be local minima like crazy with this function. Depending on the underlying algorithm and starting values used for the nonlinear optimization, you could get very different values. You really ought to think about what constraints, if any, make sense. How did you arrive at this particular form of $f(X_1,X_2)$? If you just follow the standard "spiel" at the mathworls links provided to you in the answer by @Alex R, things may not go well, even if they appear to. – Mark L. Stone Aug 12 '16 at 18:12
• What is the purpose of your model fitting? Do you really want to know the values of a,b,c,d ? Or do you want to make accurate interpolations (predictions of Y for interpolated values of $X_1$ and $X_2$)? Or extrapolations? – Mark L. Stone Aug 12 '16 at 18:16
• I suspect a good survey of techniques and case studies could be had by searching our site on relevant keywords, such as nonlinear fit. – whuber Aug 12 '16 at 18:41

• @whuber, I think Alex R is proposing that the OP "plug and chug" his $f(X_1,X_2)$ into the MATLAB Statistics and Machine Learning Toolbox function NonLinearModel.fit described at mathworks.com/help/stats/nonlinearmodel.fit.html , presumably using default options. As hinted at in my comments to the question, I think that course of action is fraught with peril, especially for someone who's not already knowledgeable in nonlinear least squares and optimization, which based on the question, the OP does not appear to be. – Mark L. Stone Aug 12 '16 at 18:33