Ran Gilad-Bachrach
Ran Gilad-Bachrach

Reputation: 110

R bootstrap continue execution

I would like to use bootstrapping using the boot library. Since calculating the statistics from each sample is a length process, it is going to take several days for the entire bootstrapping calculation to conclude. Since the computer I am using disconnects every several hours, I would like to use some checkpoint mechanism such that I will not have to start from scratch every time. Currently, I am running:

results <- boot(data=data, statistic=my_slow_function, R=10000, parallel='snow', ncpus=4, cl=cl)

but I would rather run it with R=100 multiple times such that I will be able to save the intermediate results and retrieve them if the connection hang-up. How can I achieve that?

Thank you in advance

Upvotes: 1

Views: 25

Answers (1)

Eric
Eric

Reputation: 1389

Maybe you can combine results for the bootstrap replicates:

#simulating R=10000
results_list <- lapply(1:00, function(x) {
  return(boot(data=data, statistic=my_slow_function, R=100, parallel='snow', ncpus=4)$t)
})

results_t <- unlist(results_list)
hist(results_t)
t0 = mean(results_t)

Upvotes: 1

Related Questions