diff --git a/DESCRIPTION b/DESCRIPTION index 7efb3ca..5db26cf 100644 --- a/DESCRIPTION +++ b/DESCRIPTION @@ -43,7 +43,7 @@ Imports: RANN, Rcpp (>= 1.0.12), nleqslv, - doSNOW, + doParallel, progress, foreach, parallel diff --git a/NAMESPACE b/NAMESPACE index f1667ba..6194a87 100644 --- a/NAMESPACE +++ b/NAMESPACE @@ -31,7 +31,7 @@ importFrom(Matrix,Matrix) importFrom(RANN,nn2) importFrom(Rcpp,evalCpp) importFrom(Rcpp,sourceCpp) -importFrom(doSNOW,registerDoSNOW) +importFrom(doParallel,registerDoParallel) importFrom(foreach,"%dopar%") importFrom(foreach,foreach) importFrom(maxLik,maxLik) diff --git a/R/boot_dr.R b/R/boot_dr.R index 5b40ff2..2edf457 100644 --- a/R/boot_dr.R +++ b/R/boot_dr.R @@ -260,7 +260,7 @@ bootDR <- function(outcome, #' @importFrom foreach foreach #' @importFrom parallel makeCluster #' @importFrom parallel stopCluster -#' @importFrom doSNOW registerDoSNOW +#' @importFrom doParallel registerDoParallel bootDR_multicore <- function(outcome, data, svydesign, @@ -340,15 +340,15 @@ bootDR_multicore <- function(outcome, rep_weights <- survey::as.svrepdesign(svydesign, type = rep_type, replicates = num_boot)$repweights$weights cl <- parallel::makeCluster(cores) - doSNOW::registerDoSNOW(cl) + doParallel::registerDoParallel(cl) on.exit(parallel::stopCluster(cl)) ## progress bar - if (verbose) { - pb <- progress::progress_bar$new(total = num_boot) - opts <- list(progress = \(n) pb$tick()) - } else { - opts <- NULL - } + # if (verbose) { + # pb <- progress::progress_bar$new(total = num_boot) + # opts <- list(progress = \(n) pb$tick()) + # } else { + # opts <- NULL + # } parallel::clusterExport(cl = cl, varlist = c( "internal_selection", "internal_outcome", "logit_model_nonprobsvy", "start_fit", "get_method", "controlSel", "theta_h_estimation", "mle", "mu_hatDR", "probit_model_nonprobsvy", "cloglog_model_nonprobsvy", "glm_nonprobsvy", "nn_nonprobsvy", "pmm_nonprobsvy", @@ -359,7 +359,7 @@ bootDR_multicore <- function(outcome, k <- 1:num_boot mu_hats <- foreach::`%dopar%`( - obj = foreach::foreach(k = k, .combine = c, .options.snow = opts), + obj = foreach::foreach(k = k, .combine = c), ex = { estimation_method <- get_method(est_method) strap_nons <- sample.int(replace = TRUE, n = n_nons, prob = 1 / weights) diff --git a/R/boot_dr_sel.R b/R/boot_dr_sel.R index 9da3bc0..962b0fe 100644 --- a/R/boot_dr_sel.R +++ b/R/boot_dr_sel.R @@ -113,7 +113,7 @@ bootDR_sel <- function(X, #' @importFrom foreach foreach #' @importFrom parallel makeCluster #' @importFrom parallel stopCluster -#' @importFrom doSNOW registerDoSNOW +#' @importFrom doParallel registerDoParallel bootDR_sel_multicore <- function(X, svydesign, R, @@ -142,15 +142,15 @@ bootDR_sel_multicore <- function(X, rep_weights <- survey::as.svrepdesign(svydesign, type = rep_type, replicates = num_boot)$repweights$weights cl <- parallel::makeCluster(cores) - doSNOW::registerDoSNOW(cl) + doParallel::registerDoParallel(cl) on.exit(parallel::stopCluster(cl)) ## progress bar - if (verbose) { - pb <- progress::progress_bar$new(total = num_boot) - opts <- list(progress = \(n) pb$tick()) - } else { - opts <- NULL - } + # if (verbose) { + # pb <- progress::progress_bar$new(total = num_boot) + # opts <- list(progress = \(n) pb$tick()) + # } else { + # opts <- NULL + # } parallel::clusterExport(cl = cl, varlist = c( "internal_selection", "logit_model_nonprobsvy", "start_fit", "get_method", "controlSel", "mle", "probit_model_nonprobsvy", "cloglog_model_nonprobsvy", "mm", "u_theta_beta_dr", @@ -159,7 +159,7 @@ bootDR_sel_multicore <- function(X, k <- 1:num_boot mu_hats <- foreach::`%dopar%`( - obj = foreach::foreach(k = k, .combine = c, .options.snow = opts), + obj = foreach::foreach(k = k, .combine = c), ex = { strap_nons <- sample.int(replace = TRUE, n = n_nons, prob = 1 / weights) # strap_rand <- sample.int(replace = TRUE, n = n_rand, prob = 1/weights_rand) diff --git a/R/boot_ipw.R b/R/boot_ipw.R index 8dfa6c2..715a43c 100644 --- a/R/boot_ipw.R +++ b/R/boot_ipw.R @@ -182,7 +182,7 @@ bootIPW <- function(X_rand, #' @importFrom foreach foreach #' @importFrom parallel makeCluster #' @importFrom parallel stopCluster -#' @importFrom doSNOW registerDoSNOW +#' @importFrom doParallel registerDoParallel bootIPW_multicore <- function(X_rand, X_nons, svydesign, @@ -220,15 +220,15 @@ bootIPW_multicore <- function(X_rand, boot_vars <- numeric(length = mu_len) cl <- parallel::makeCluster(cores) - doSNOW::registerDoSNOW(cl) + doParallel::registerDoParallel(cl) on.exit(parallel::stopCluster(cl)) ## progress bar - if (verbose) { - pb <- progress::progress_bar$new(total = num_boot) - opts <- list(progress = \(n) pb$tick()) - } else { - opts <- NULL - } + # if (verbose) { + # pb <- progress::progress_bar$new(total = num_boot) + # opts <- list(progress = \(n) pb$tick()) + # } else { + # opts <- NULL + # } ### parallel::clusterExport(cl = cl, varlist = c( "internal_selection", "logit_model_nonprobsvy", "start_fit", "get_method", "controlSel", @@ -239,7 +239,7 @@ bootIPW_multicore <- function(X_rand, k <- 1:num_boot mu_hats_boot <- foreach::`%dopar%`( - obj = foreach::foreach(k = k, .combine = c, .options.snow = opts), + obj = foreach::foreach(k = k, .combine = c), ex = { if (is.null(pop_totals)) { strap_nons <- sample.int(replace = TRUE, n = n_nons, prob = 1 / weights) diff --git a/R/boot_mi.R b/R/boot_mi.R index 6ab4a56..a277bf7 100644 --- a/R/boot_mi.R +++ b/R/boot_mi.R @@ -433,7 +433,7 @@ bootMI <- function(X_rand, #' @importFrom foreach foreach #' @importFrom parallel makeCluster #' @importFrom parallel stopCluster -#' @importFrom doSNOW registerDoSNOW +#' @importFrom doParallel registerDoParallel bootMI_multicore <- function(X_rand, X_nons, weights, @@ -469,16 +469,16 @@ bootMI_multicore <- function(X_rand, } cl <- parallel::makeCluster(cores) - doSNOW::registerDoSNOW(cl) + doParallel::registerDoParallel(cl) on.exit(parallel::stopCluster(cl)) ## progress bar - if (verbose) { - pb <- progress::progress_bar$new(total = num_boot) - opts <- list(progress = \(n) pb$tick()) - } else { - opts <- NULL - } + # if (verbose) { + # pb <- progress::progress_bar$new(total = num_boot) + # opts <- list(progress = \(n) pb$tick()) + # } else { + # opts <- NULL + # } ### parallel::clusterExport(cl = cl, varlist = c( "internal_selection", "logit_model_nonprobsvy", "start_fit", "get_method", "controlSel", @@ -496,7 +496,7 @@ bootMI_multicore <- function(X_rand, if (method == "glm") { k <- 1:num_boot mu_hats <- foreach::`%dopar%`( - obj = foreach::foreach(k = k, .combine = c, .options.snow = opts), + obj = foreach::foreach(k = k, .combine = c), ex = { strap <- sample.int(replace = TRUE, n = n_nons, prob = 1 / weights) weights_strap <- weights[strap]