R-alpha: R0.13 bugs

Ross Ihaka (ihaka@stat.auckland.ac.nz)
Thu, 14 Nov 1996 10:20:24 +1300 (NZDT)


From: Ross Ihaka <ihaka@stat.auckland.ac.nz>
Date: Thu, 14 Nov 1996 10:20:24 +1300 (NZDT)
Message-Id: <199611132120.KAA29578@stat13.stat.auckland.ac.nz>
To: Jim Lindsey <jlindsey@luc.ac.be>
Subject: R-alpha: R0.13 bugs
In-Reply-To: <9611130850.AA04330@alpha.luc.ac.be>

Jim Lindsey writes:
 > 1. First something from 0.12 that I forgot to report:
 >   update() for a formula works with lm() but not glm() for which it
 >   (still in 0.13) gives
 >   Error in update.formula(call$formula,formula) ...

I'm staggered that it works for lm :-)  It's now on the list

 > 2. 0.5^0 gives NA
 >   This is a deliberate programming choice with which I strongly 
 >   disagree: we can no longer even calculate a binomial probability!
 >   As well, pow() in C gives the right answer: 0.5^0=1!!  
 >   Thus, the tests in arithmetic.c for POWOP should be removed:
 >   integer -  || x2==0
 >   real    -  && x2!=0

Choice is a strong word.  I tend to think of R as having congealed
rather than as having been designed and implemented.

 > 3.Yesterday, I suspected problems with garbage collection in
 >   optimization. I was getting the message,
 >   Error: invalid function value in optimizer
 >   rather randomly and having to leave R to have things work
 >   again.  I have found at least one of the problems. In optimize.c, in
 >   F77_SYMBOL(fcn) there is a for loop using i. Further down, there is a
 >   switch with tests using INTEGER(s)[i] and REAL(s)[i] where i is only
 >   defined from the loop above. In both places, i should be 0.  However,
 >   this breaks a lot of my code. I think the function should only be
 >   tested for illegal values once, at the beginning of the call to nlm
 >   using the initial values. If they give a valid function value, any
 >   other calls to the function giving NAs should be set to INT_MAX or
 >   DBL_MAX in place of the tests above. We are doing minimization so that
 >   this will direct the optimizer away from an illegal area in the
 >   parameter space where a constraint should have been applied. (If it is
 >   really felt necessary, a warning could be printed, but this is not
 >   really needed because there will already be something like "NAs in
 >   log" printed.) Leaving this testing to the user in the function will
 >   make optimization too slow.  Testing and changing the value when the
 >   function returns eliminates the need to check in lnsrch as was done in
 >   the previous version. The NAs almost all occur either during
 >   line-search (lnsrch) or calculating the information matrix (fdhess),
 >   even although the correct minimum has been found in many cases. A
 >   simple example that will not work without this fix is a Poisson
 >   distribution with mean parameter instead of canonical parameter,
 >   because of the constraint, mu>0. One essential characteristic of an
 >   optimizer is speed! Do the checking in C, not in the R function.

Ok I will take a look.  This stuff is in a half finished state (I want
to add the facility to handle analytic gradients and hessians too).
I have an example from Thomas Lumley which he says breaks in a
repeatable fashion.  This should help me track down the GC problem.
Reading the code didn't reveal anything.

 > 4. The help for nlm is still called minimize although the contents
 >   have been updated. As well, when an illegal value is fed to nlm, the
 >   error message contains msg instead of print.level.

	Ross
=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-
r-testers mailing list -- To (un)subscribe, send
subscribe	or	unsubscribe
(in the "body", not the subject !)  To: r-testers-request@stat.math.ethz.ch
=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-