[R] nlm recursion problem

John Logsdon j.logsdon at lancaster.ac.uk
Wed Sep 29 11:24:34 CEST 1999


Hi

I am trying to use nlm with an additional call to nlm within the function
but after the first pass, the parameters to the outer call are being
passed to the inner call.  The inner call is a very trivial problem.

ie:

test.outer<-function(param.outer){
  slope<-nlm(test.inner,param.inner)
 ...
  loglikelihood<-sum(...)
return(-loglikelihood)
}

and

nlm(test.outer,param.outer)

on the second call of test.outer by nlm, the inner calls to test.inner are
finding param.outer.

I have tried the obvious nlmx<-nlm and calling nlmx as the inner call but
this does not fix it.  Can I use recursion with nlm or is there an
alternative non-linear minimiser?  I suspect that it is the static memory
within the Fortran - is there any way of copying this to an object after
the outer call then restoring it after the inner calls?

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).

John

-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-
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 mailing list