That is a symptom of the C/C++ code doing something like using memory beyond the proper range. It's entirely possible to have crashes in some contexts but not others.
If you can run the C code under valgrind, that would be the easiest way to find the problem. Pat On 03/11/2012 18:15, Paul Browne wrote:
Hello, I am attempting to use optim under the default Nelder-Mead algorithm for model fitting, minimizing a Chi^2 statistic whose value is determined by a .C call to an external shared library compiled from C & C++ code. My problem has been that the R session will immediately crash upon starting the simplex run, without it taking a single step. This is strange, as the .C call itself works, is error-free (as far as I can tell!) & does not return NAN or Inf under any initial starting parameters that I have tested it with in R. It only ever crashes the R session when the Chi^2 function to be minimized is called from optim, not under any other circumstances. In the interests of reproducibility, I attach R code that reads attached data files & attempts a N-M optim run. The required shared library containing the external code (compiled in Ubuntu 12.04 x64 with g++ 4.6.3) is also attached. Calculating an initial Chi^2 value for a starting set of model parameters works, then the R session crashes when the optim call is made. Is there something I'm perhaps doing wrong in the specification of the optim run? Is it inadvisable to use external code with optim? There doesn't seem to be a problem with the external code itself, so I'm very stumped as to the source of the crashes. ______________________________________________ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
-- Patrick Burns pbu...@pburns.seanet.com twitter: @portfolioprobe http://www.portfolioprobe.com/blog http://www.burns-stat.com (home of 'Some hints for the R beginner' and 'The R Inferno') ______________________________________________ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.