You are here:

Probability & Statistics/How to do OLS when y is not linear?


Hi Clyde,

So far, all the questions I have done on Ordinary Least Squares (OLS) regression have assumed that the population can be modelled as:

y_i = a + bx_i + e_i

where a and b are constants and e_i is the error term with mean 0.

Now I am wondering how I would do OLS if y is not a linear function of x_i? For example:

y_i = a + sin(x_i) + e_i

a can be estimated as usual but it is 'b' that I do not know how to estimate using OLS. Do I differentiate the sum of the squared error terms with respect to sin (x)? I tried doing that I got some really complicated expression so I decided to seek help before going further.

Could you please provide to me some worked out examples on how to perform OLS estimate in such cases?

It might be useful if you included more parameters in your regression:

y_i = a + b sin(c x_i + d) + e_i

Regardless of your choice, you can compute the values of a, b, c, d or any other parameters that minimize the sum-of-squares of the e_i. The methodology is the same, but you will have more complicated numbers / expressions. There's no way to avoid that, since you are using the sine function. You can use a variety of numerical and symbolic methods to find the optimum values of (a,b,c,d). You haven't really explained what level of work you can do so I don't know how to give you any more information. If you are at the level of introductory statistics, the calculus or numeral analysis required to do this type of regression will be unknown to you.

For a population you should also consider an exponential or logistic model, which will give you solutions that are neither linear nor sinusoidal, like:

y_i = a e^(r x_i) + e_i


y_i = a / ( b + e^(r x_i) ) + e_i

There is a general methodology for finding this even without knowing that it is sine or any other function:

However that is more advanced than what you seem to be asking.

Probability & Statistics

All Answers

Answers by Expert:

Ask Experts


Clyde Oliver








Awards and Honors

Past/Present Clients

©2017 All rights reserved.