Parallel Execution for Confidence Intervals

Justin Kamerman

2024-08-27

To leverage multicore processors to speed up calcualtion of confidence intervals, use the parallel package to create a cluster and attach the qfasa.parallel.cluster option.

The cluster can be used for multiple invocations of beta.meths.CI() but should be shut down when work is complete to free up resources.

Set Number of Cores

For maximum speedup, set the qfasa.parallel.numcores option to the total number of cores on your computer. The number of cores can be determined using the detectCores() function.

parallel::detectCores()
## [1] 20

Create Cluster

options(qfasa.parallel.numcores = 8)
options(qfasa.parallel.cluster = parallel::makeCluster(getOption('qfasa.parallel.numcores'),
                                                       type='FORK'))
#
# Note that if using windows, do not include type='FORK'.

Confidence Intervals

No change is required to the conf.meth() call. The implementation will automatically detect the cluster and use it to parallelize the bootstrap iterations.

Shut Down Cluster

parallel::stopCluster(getOption('qfasa.parallel.cluster'))

Portability

Parallel execution has been tested on Ubuntu Linux, AWS Linux, and MacOS platforms only.