[R] Apparent discordant solution using NLS() vs Optim or Excel for IWLS problem

From: <rsposto_at_yahoo.com>
Date: Fri, 21 Dec 2007 19:36:18 -0500

I am writing a program for automated (i.e. no user intervention - for biologists) iteratively reweighted least-square fit to a function of the form "reading ~ exp(lm2)/(1 + (dose/exp(lm3))^exp(lm4)" using case weight proportional to the mean, e.g., E(reading). Because for some datasets the solution is sensitive to starting values, I first use OPTIM() with Nelder-Mead to locate the solution, and then plug the solution into NLS() (default algorithm) using the appropriate weights as a way to retrieve SEs, deviance, etc rather than computing these from OPTIM results.

The problem I have discovered is the following. OPTIM() arrives at the correct solution that minimizes the objective function, and I have confirmed this in numerous examples in Excel. When this solution is plugged into NLS(), the first evaluation yields the same value of the objective function as OPTIM(). NLS() then attempts steps, and apparently finds a slightly different solution with a smaller value for the objective function. However, this new solution actually does not give a smaller objective function value, but rather a larger one, when verifed against an independent computation. Hence, it appears that NLS is getting confused and taking a step based on erroneous computation of the objective function.

An example is below, with an abridged OPTIM output followed by NLS output:

[***NOTE - the correct solution parameters values are the line above on the absolute scale, which are the values below on the ln scale, representing the first evaluation by NLS. This gives the correct objective function value of 0.763370, and hence agrees with OPTIM at this point ***]

Note the objective function value of .750387 at parameter values 18.19934, -11.34795, 0.05435. However, objective function value at this solution is actually 0.776426587, by Excel computation.

Can anyone suggest what I might be doing wrong, or is this a bug or anomaly of the NLS algorithm?

Thanks in advance

Richard Sposto (Los Angeles).

This message was sent on behalf of rsposto_at_yahoo.com at openSubscriber.com

R-help_at_r-project.org mailing list
PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
and provide commented, minimal, self-contained, reproducible code.
Received on Sat 22 Dec 2007 - 00:41:59 GMT

Archive maintained by Robert King, hosted by the discipline of statistics at the University of Newcastle, Australia.
Archive generated by hypermail 2.2.0, at Sat 22 Dec 2007 - 03:30:20 GMT.

Mailing list information is available at https://stat.ethz.ch/mailman/listinfo/r-help. Please read the posting guide before posting to the list.