If you have a set of data points (x1,y1), (x2,y2),...,(xn,yn)
And you know it fits a trend y=f(x) where f(x) is a known function,
Say for example: f(x)=A*x*sin(B*x)
Providing f(x) is known, is it possible to fit a regression line to this data and get values for A and B (and any other coefficients involved) for any f(x)?
If it is possible, could you give me some insight into how I would find the regression coefficients of the curve example given above?
Here's some MATLAB code that implements the idea in Claude Leibovici's answer.
First we generate some data
which look like this
Now you define your objective function, which will be a function of
bonly (since we will chooseaby least squares)Say you suspect that the true value of
bis in the interval [0, 5]. Then you can create some values in that interval, and compute the mean-square error on each value.The mean-square error as a function of
blooks like thisSo you can see that there is an obvious minimum near to 2.5. You can find out exactly where it is, and from that find out the optimal values of
banda.which results in
which are reasonably close to the true values of
a = 10.0andb = 2.5.