Skip to content
Prev 58662 / 398502 Next

Nonlinear weighted least squares estimation

This question has been asked before on the list, but I'm not sure if the
answer were posted.  Basically, the trick is to write the formula a bit
differently in nls() so that it does weighted least squares.  nls() tries to
minimize the sum of squared differences between the two sides of ~.  If you
write the formula as 

~ sqrt(w) * (y - modelfun)

where modelfun is the nonlinear function being fitted, you get the weighted
nonlinear least squares solution.  (Cf. page 241 of MASS4 and Section 10.3.3
of the White Book.)  However, you need to watch out for predict(), etc., as
their output corresponds to what you specify in the formula.

HTH,
Andy