November 13th, 2013, 3:24 pm
Least squares can handle multiple parameters. You just need to turn the crank. Minimizing the sum of the residual errors (∑(eps_i)^2) means finding where the partial derivative of the sum of the errors with respect to the unknown parameters crosses zero. 1. start with your equation: y_i = a - 2*b*x1_i + c * x2_i - eps_i2. rewrite it as eps_i = something3. square both sides to get (eps_i)^2 = something messy but really not that hard4. form the sum across i: ∑(eps_i)^2 = messy equation #3 with a ∑ on each term5. factor the parameters out of each sum (e.g., rewrite ∑(c * x2_i) as c*∑(x2_i) )6. take the partial derivative of equation #5 with respect to a, b, and c to form 3 equations in the 3 unknowns7. set each equation from #6 to zero and solve for a, b, and c in terms of all those messy summations.It may seem daunting, but it's all pretty mechanical. You just need to work through all the fiddly terms carefully. At the end, you can feed some simulated data that has known a, b, & c to confirm there's not a mistake anywhere.