[R] nlm recursion problem
j.logsdon at lancaster.ac.uk
Wed Sep 29 17:31:53 CEST 1999
Further thinking shows me that the easiest way round this problem is not
to spend time hacking the code but to write a simple Newton scheme for the
inner solution in R, since the derivatives are easy. This I am doing but
a thought arose:
How common is this problem with R? It was a little obscure - it only fell
over because the vectors were different lengths. What happens if the
vectors are the same length? It won't warn you. Does this also happen
with S+ (nlmin())? Can anyone test this - I don't have S?
Peter indicated that a number of Fortran routines had already been fixed.
To fix the Fortran is not *in principle* all that difficult - you need to
add working arrays and ensure that no data are retainded internally. NAG
showed the way a long time ago - a bit messy but I think it would work.
However, looking at the R coding where the Fortran is called from the C
and calls further routines, it is not a simple job. Which is why I
elected to practice my differentiation!
Thanks for the messages
On Wed, 29 Sep 1999, Bill Venables wrote:
> > John Logsdon <j.logsdon at lancaster.ac.uk> writes:
> > > nlm is called by many functions and packages so perhaps this is quite a
> > > common problem - what is the slickest way round it? The solution required
> > > is just the intercept and slope of a line where there may be censored data
> > > so lm() won't do and neither will optimise() (it is only for 1 dimension
> > > and I require 2).
> > There really is no way around this, except either to rewrite the
> > maximiser in a language that allows reentrancy ( = C in practice) or
> > wait for someone to write a Fortran compiler that does. We've
> > previously done this for the solvers, and nlm appears to be under
> > scrutiny at the moment anyway, so perhaps...
> Right, there is no way to make Fortran of this vintage recursive
> but, much as I hesitate to point it out, if you know in advance
> that all you need is two levels (as John appears to do) you could
> use another Fortran routine as the inner minimizer, and there is
> no reason why that one could not be the same one that sits behind
> nlm by another name. Ugly, I know, but in a jam I'd do it, and
> in an Open Source system the code is sitting there, waiting...
> "Fortran - just say `No'."
> Bill Venables, Statistician, CMIS Environmetrics Project.
> Physical address: Postal address:
> CSIRO Marine Laboratories, PO Box 120,
> 233 Middle St, Cleveland, Queensland Cleveland, Qld, 4163
> AUSTRALIA AUSTRALIA
> Telephone: +61 7 3826 7251 Email: Bill.Venables at cmis.csiro.au
> Fax: +61 7 3826 7304
> r-help mailing list -- Read http://www.ci.tuwien.ac.at/~hornik/R/R-FAQ.html
> Send "info", "help", or "[un]subscribe"
> (in the "body", not the subject !) To: r-help-request at stat.math.ethz.ch
r-help mailing list -- Read http://www.ci.tuwien.ac.at/~hornik/R/R-FAQ.html
Send "info", "help", or "[un]subscribe"
(in the "body", not the subject !) To: r-help-request at stat.math.ethz.ch
More information about the R-help