Page 1 of 1

simulations failed

PostPosted: Sat Jan 28, 2012 12:15 am
by ndusit
Hi Murray
I tried simulation with 50 replicates, which set up parameters, D=8, g0 = 0.2, sigma = 2000 m. I want to try the sigma vary from 3000, 4000, 5000, 6000m, and occasion vary from 4, 6, 8, 10. I set priority below normal in Task Manager as well.

After 46 replicates (15 hr) the computer shown massage "R for windows gui front-end has stopped working" and "A problem caused the program to stop working correctly"

Is this limitation of my computer? or something else.

I used Fujitsu laptop Window 7 professional 64-bit with ram 4GB CPU Intel-Corei5@2.30GHz and ran with R v2.13.0. I used "secr" v 2.3.2.

Thanks,
Dusit

Re: simulations failed

PostPosted: Sat Jan 28, 2012 1:09 am
by murray.efford
Hi Dusit

So close! I have no idea what went wrong. It is possible some memory limit was exceeded. Sorry I can't be specific, but can only offer general suggestions. The buffer bias check in secr.fit() can be a weak point, so it's a good idea to set verify = FALSE.

For big simulations like this I always save results to a disk file after each replicate (e.g. save(output, file='output.Rdata') if the output are accumulating in object 'output'). That way if there is a problem I can restart for the remaining simulations rather than going back to the beginning.

I also like to try generating a lot of datasets (fast) and saving only a summary of each (e.g., number of capture histories) without actually fitting a model (slow), just to check that part of the system is working. You can even split the process into two steps: (1) generate all the capthist objects and save them as a list (2) fit a model to each component of the list.

That's quite large range of sigma values, especially as you have held g0 constant (expected number of captures varies roughly with the square of sigma). You need to ensure the buffer size is appropriate for each sigma.

I guess you mean density 8 per 100km^2?

Hope you can crack this.
Murray

Re: simulations failed

PostPosted: Sat Jan 28, 2012 12:10 pm
by ndusit
Hi Murray
Thanks. I applied and used your simulation code from KL workshop. I set verify = FALSE, and save my output = outputfile. How can restart for the remaining simulations? It's above of my head. :shock:

Best,
Dusit

Re: simulations failed

PostPosted: Sat Jan 28, 2012 4:50 pm
by murray.efford
I think you need to modify the simulation function something like this:

Code: Select all
runsim.restart <- function(nrepl = 50, outputfile = 'sim.output.RData', startfrom = 1) {
    ...
    ## optionally reload partial output
    if (startfrom > 1)
        load('sim.output.RData')
    ## loop over replicates
    for (r in startfrom:nrepl) {
        ## simulate replicate r for all parameter combinations
        ...
        save(output, file = outputfile)
    }
    ...
}


and then run with 'startfrom' set to wherever it finished (46?). For example
runsim.restart(nrepl = 50, startfrom = 46).

The dots represent all the code to set up the parameter combinations and output array and to perform the simulations. As written this could also be used for any new batch of simulations, because with the default startfrom = 1 it won't try and load an output file.

Murray

Re: simulations failed

PostPosted: Sun Jan 29, 2012 11:14 am
by ndusit
Hi Murray
Thank you very much. :D

Best regards,
Dusit

Re: simulations failed

PostPosted: Sun Jan 29, 2012 4:01 pm
by murray.efford
I rushed that reply - the code will only work if your original call used the default name for the output file. It would be better to replace load('sim.output.RData') with load(outputfile).