[R] optim & .C / Crashing on run

2012-11-03 Thread Paul Browne
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

Re: [R] optim & .C / Crashing on run

2012-11-04 Thread Patrick Burns
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 Brow

Re: [R] optim & .C / Crashing on run

2012-11-04 Thread Paul Browne
It looks like my attached files didn't go through, so I'll put them in a public Dropbox folder instead; optim_rhelp.tar.gz Thanks, I'll run a compiled binary of the C++ code through Valgrind & see what it reports, then perhaps I'll try an Rscript

Re: [R] optim & .C / Crashing on run

2012-11-04 Thread Patrick Burns
When invoking R, you can add -d valgrind to run it under valgrind. On 04/11/2012 11:35, Paul Browne wrote: It looks like my attached files didn't go through, so I'll put them in a public Dropbox folder instead; optim_rhelp.tar.gz Thanks, I

Re: [R] optim & .C / Crashing on run

2012-11-04 Thread Paul Browne
Hi, Thanks for your help. Invoking valgrind under R for the test script I attached produces the following crash report; > Rscript optim_rhelp.R -d valgrind > Nelder-Mead direct search function minimizer > function value for initial parameters = 1267.562555 > Scaled convergence tolerance is 1

Re: [R] optim & .C / Crashing on run

2012-11-04 Thread Paul Browne
Running this valgrind command on the test optim_rhelp.R script R -d "valgrind --tool=memcheck --leak-check=full > --log-file=optim_rhelp.valgrind.log" --vanilla < optim_rhelp.R yields this report: optim_rhelp.valgrind.log Ignoring everyt

Re: [R] optim & .C / Crashing on run

2012-11-04 Thread paulfjbrowne
Playing around with alternate optimzers, I've found that both nlminb & the nls.lm Levenberg-Marquadt optimizer in minpack.lm both work with my objective function without crashing, and minimize the function as I'd expect them to. Using optim for amoeba sampling would be nice, but I think I'll just

Re: [R] optim & .C / Crashing on run

2012-11-05 Thread William Dunlap
On > Behalf > Of Paul Browne > Sent: Sunday, November 04, 2012 6:20 AM > To: Patrick Burns > Cc: r-help@r-project.org > Subject: Re: [R] optim & .C / Crashing on run > > Hi, > > Thanks for your help. Invoking valgrind under R for the test script I &g

Re: [R] optim & .C / Crashing on run

2012-11-05 Thread Ravi Varadhan
You might also want to try the Nelder-Mead algorithm, nmk(), in the "dfoptim" package. It is a better algorithm than the Nelder-Mead in optim. It is all R code, so you might be able to modify it to fit your needs. Ravi Ravi Varadhan, Ph.D. Assistant Professor The Center on Aging and Health Di

Re: [R] optim & .C / Crashing on run

2012-11-06 Thread Paul Browne
tibco.com > > > > -Original Message- > > From: r-help-boun...@r-project.org [mailto:r-help-boun...@r-project.org] > On Behalf > > Of Paul Browne > > Sent: Sunday, November 04, 2012 6:20 AM > > To: Patrick Burns > > Cc: r-help@r-project.org