diff --git a/R/arp-nuisance.R b/R/arp-nuisance.R index 782ec5c..3040bd3 100644 --- a/R/arp-nuisance.R +++ b/R/arp-nuisance.R @@ -349,7 +349,7 @@ # HYBRID HELPER FUNCTIONS --------------------------------------------- .compute_least_favorable_cv <- function(X_T, sigma, hybrid_kappa, sims = 1000, - rowsForARP = NULL) { + rowsForARP = NULL, seed = 0) { # Computes the least favorable critical value following the algorithm in # Section 6.2 of Andrews, Roth, Pakes (2019). # @@ -383,7 +383,7 @@ base::return(if (error_flag) NA else lpSolveAPI::get.objective(linprog)) } - base::set.seed(0) + base::set.seed(seed) if (base::is.null(X_T)) { # no nuisance parameter case xi.draws = t( t(mvtnorm::rmvnorm(n = sims, sigma = sigma)) /base::sqrt(base::diag(sigma)) ) eta_vec = matrixStats::rowMaxs(xi.draws) diff --git a/R/deltarm.R b/R/deltarm.R index f5d3a57..70152b8 100644 --- a/R/deltarm.R +++ b/R/deltarm.R @@ -184,7 +184,7 @@ .computeConditionalCS_DeltaRM_fixedS <- function(s, max_positive, Mbar, betahat, sigma, numPrePeriods, numPostPeriods, l_vec, alpha, hybrid_flag, hybrid_kappa, - postPeriodMomentsOnly, gridPoints, grid.ub, grid.lb) { + postPeriodMomentsOnly, gridPoints, grid.ub, grid.lb, seed = 0) { # This function computes the ARP CI that includes nuisance parameters # for Delta^{RM}(Mbar) for a fixed s and (+),(-). This functions uses ARP_computeCI for all # of its computations. It is used as a helper function in computeConditionalCS_DeltaRM below. @@ -223,7 +223,7 @@ if (numPostPeriods == 1) { if (hybrid_flag == "LF") { # Compute LF CV and store it in hybrid_list - lf_cv = .compute_least_favorable_cv(X_T = NULL, sigma = A_RM_s %*% sigma %*% base::t(A_RM_s), hybrid_kappa = hybrid_kappa) + lf_cv = .compute_least_favorable_cv(X_T = NULL, sigma = A_RM_s %*% sigma %*% base::t(A_RM_s), hybrid_kappa = hybrid_kappa, seed = seed) hybrid_list$lf_cv = lf_cv } # Compute confidence set @@ -250,7 +250,7 @@ computeConditionalCS_DeltaRM <- function(betahat, sigma, numPrePeriods, numPostP l_vec = .basisVector(index = 1, size = numPostPeriods), Mbar = 0, alpha = 0.05, hybrid_flag = "LF", hybrid_kappa = alpha/10, returnLength = FALSE, postPeriodMomentsOnly = TRUE, - gridPoints = 10^3, grid.ub = NA, grid.lb = NA) { + gridPoints = 10^3, grid.ub = NA, grid.lb = NA, seed = 0) { # This function computes the ARP CI that includes nuisance parameters # for Delta^{RM}(Mbar). This functions uses ARP_computeCI for all # of its computations. @@ -292,7 +292,7 @@ computeConditionalCS_DeltaRM <- function(betahat, sigma, numPrePeriods, numPostP numPostPeriods = numPostPeriods, l_vec = l_vec, alpha = alpha, hybrid_flag = hybrid_flag, hybrid_kappa = hybrid_kappa, postPeriodMomentsOnly = postPeriodMomentsOnly, - gridPoints = gridPoints, grid.ub = grid.ub, grid.lb = grid.lb) + gridPoints = gridPoints, grid.ub = grid.ub, grid.lb = grid.lb, seed = seed) CIs_RM_plus_allS[,s_i] = CI_s_plus$accept # Compute CI for s, (-) and bind it to all CI's for (-) @@ -301,7 +301,7 @@ computeConditionalCS_DeltaRM <- function(betahat, sigma, numPrePeriods, numPostP numPostPeriods = numPostPeriods, l_vec = l_vec, alpha = alpha, hybrid_flag = hybrid_flag, hybrid_kappa = hybrid_kappa, postPeriodMomentsOnly = postPeriodMomentsOnly, - gridPoints = gridPoints, grid.ub = grid.ub, grid.lb = grid.lb) + gridPoints = gridPoints, grid.ub = grid.ub, grid.lb = grid.lb, seed = seed) CIs_RM_minus_allS[,s_i] = CI_s_minus$accept } diff --git a/R/deltarmb.R b/R/deltarmb.R index ae6a8e2..c467e43 100644 --- a/R/deltarmb.R +++ b/R/deltarmb.R @@ -200,7 +200,7 @@ .computeConditionalCS_DeltaRMB_fixedS <- function(s, max_positive, Mbar, betahat, sigma, numPrePeriods, numPostPeriods, l_vec, alpha, hybrid_flag, hybrid_kappa, biasDirection, - postPeriodMomentsOnly, gridPoints, grid.ub, grid.lb) { + postPeriodMomentsOnly, gridPoints, grid.ub, grid.lb, seed = 0) { # This function computes the ARP CI that includes nuisance parameters # for Delta^{MB}(Mbar) for a fixed s and (+),(-). This functions uses ARP_computeCI for all # of its computations. It is used as a helper function in computeConditionalCS_DeltaMB below. @@ -238,7 +238,7 @@ if (numPostPeriods == 1) { if (hybrid_flag == "LF") { # Compute LF CV and store it in hybrid_list - lf_cv = .compute_least_favorable_cv(X_T = NULL, sigma = A_RMB_s %*% sigma %*% base::t(A_RMB_s), hybrid_kappa = hybrid_kappa) + lf_cv = .compute_least_favorable_cv(X_T = NULL, sigma = A_RMB_s %*% sigma %*% base::t(A_RMB_s), hybrid_kappa = hybrid_kappa, seed = seed) hybrid_list$lf_cv = lf_cv } # Compute confidence set @@ -267,7 +267,7 @@ computeConditionalCS_DeltaRMB <- function(betahat, sigma, numPrePeriods, numPost alpha = 0.05, hybrid_flag = "LF", hybrid_kappa = alpha/10, returnLength = FALSE, biasDirection = "positive", postPeriodMomentsOnly = TRUE, - gridPoints = 10^3, grid.ub = NA, grid.lb = NA) { + gridPoints = 10^3, grid.ub = NA, grid.lb = NA, seed = 0) { # This function computes the ARP CI that includes nuisance parameters # for Delta^{MB}(Mbar). This functions uses ARP_computeCI for all # of its computations. @@ -310,7 +310,7 @@ computeConditionalCS_DeltaRMB <- function(betahat, sigma, numPrePeriods, numPost numPostPeriods = numPostPeriods, l_vec = l_vec, alpha = alpha, hybrid_flag = hybrid_flag, hybrid_kappa = hybrid_kappa, postPeriodMomentsOnly = postPeriodMomentsOnly, biasDirection = biasDirection, - gridPoints = gridPoints, grid.ub = grid.ub, grid.lb = grid.lb) + gridPoints = gridPoints, grid.ub = grid.ub, grid.lb = grid.lb, seed = seed) CIs_RMB_plus_allS[,s_i] = CI_s_plus$accept # Compute CI for s, (-) and bind it to all CI's for (-) @@ -319,7 +319,7 @@ computeConditionalCS_DeltaRMB <- function(betahat, sigma, numPrePeriods, numPost numPostPeriods = numPostPeriods, l_vec = l_vec, alpha = alpha, hybrid_flag = hybrid_flag, hybrid_kappa = hybrid_kappa, postPeriodMomentsOnly = postPeriodMomentsOnly, biasDirection = biasDirection, - gridPoints = gridPoints, grid.ub = grid.ub, grid.lb = grid.lb) + gridPoints = gridPoints, grid.ub = grid.ub, grid.lb = grid.lb, seed = seed) CIs_RMB_minus_allS[,s_i] = CI_s_minus$accept } diff --git a/R/deltarmm.R b/R/deltarmm.R index 826372c..876cb47 100644 --- a/R/deltarmm.R +++ b/R/deltarmm.R @@ -200,7 +200,7 @@ betahat, sigma, numPrePeriods, numPostPeriods, l_vec, alpha, hybrid_flag, hybrid_kappa, postPeriodMomentsOnly, monotonicityDirection, - gridPoints, grid.ub, grid.lb) { + gridPoints, grid.ub, grid.lb, seed = 0) { # This function computes the ARP CI that includes nuisance parameters # for Delta^{RMM}(Mbar) for a fixed s and (+),(-). This functions uses ARP_computeCI for all # of its computations. It is used as a helper function in computeConditionalCS_DeltaRM below. @@ -239,7 +239,7 @@ if (numPostPeriods == 1) { if (hybrid_flag == "LF") { # Compute LF CV and store it in hybrid_list - lf_cv = .compute_least_favorable_cv(X_T = NULL, sigma = A_RMM_s %*% sigma %*% base::t(A_RMM_s), hybrid_kappa = hybrid_kappa) + lf_cv = .compute_least_favorable_cv(X_T = NULL, sigma = A_RMM_s %*% sigma %*% base::t(A_RMM_s), hybrid_kappa = hybrid_kappa, seed = seed) hybrid_list$lf_cv = lf_cv } # Compute confidence set @@ -266,7 +266,7 @@ computeConditionalCS_DeltaRMM <- function(betahat, sigma, numPrePeriods, numPost l_vec = .basisVector(index = 1, size = numPostPeriods), Mbar = 0, alpha = 0.05, hybrid_flag = "LF", hybrid_kappa = alpha/10, returnLength = FALSE, postPeriodMomentsOnly = TRUE, monotonicityDirection = "increasing", - gridPoints = 10^3, grid.ub = NA, grid.lb = NA) { + gridPoints = 10^3, grid.ub = NA, grid.lb = NA, seed = 0) { # This function computes the ARP CI that includes nuisance parameters # for Delta^{RMM}(Mbar). This functions uses ARP_computeCI for all # of its computations. @@ -308,7 +308,7 @@ computeConditionalCS_DeltaRMM <- function(betahat, sigma, numPrePeriods, numPost numPostPeriods = numPostPeriods, l_vec = l_vec, alpha = alpha, hybrid_flag = hybrid_flag, hybrid_kappa = hybrid_kappa, postPeriodMomentsOnly = postPeriodMomentsOnly, monotonicityDirection = monotonicityDirection, - gridPoints = gridPoints, grid.ub = grid.ub, grid.lb = grid.lb) + gridPoints = gridPoints, grid.ub = grid.ub, grid.lb = grid.lb, seed = seed) CIs_RMM_plus_allS[,s_i] = CI_s_plus$accept # Compute CI for s, (-) and bind it to all CI's for (-) @@ -317,7 +317,7 @@ computeConditionalCS_DeltaRMM <- function(betahat, sigma, numPrePeriods, numPost numPostPeriods = numPostPeriods, l_vec = l_vec, alpha = alpha, hybrid_flag = hybrid_flag, hybrid_kappa = hybrid_kappa, postPeriodMomentsOnly = postPeriodMomentsOnly, monotonicityDirection = monotonicityDirection, - gridPoints = gridPoints, grid.ub = grid.ub, grid.lb = grid.lb) + gridPoints = gridPoints, grid.ub = grid.ub, grid.lb = grid.lb, seed = seed) CIs_RMM_minus_allS[,s_i] = CI_s_minus$accept } diff --git a/R/deltasd.R b/R/deltasd.R index 0efa145..16bde1f 100644 --- a/R/deltasd.R +++ b/R/deltasd.R @@ -131,7 +131,7 @@ computeConditionalCS_DeltaSD <- function(betahat, sigma, numPrePeriods, numPostP M = 0, alpha = 0.05, hybrid_flag = "FLCI", hybrid_kappa = alpha/10, returnLength = FALSE, postPeriodMomentsOnly = TRUE, - gridPoints =10^3, grid.ub = NA, grid.lb = NA) { + gridPoints =10^3, grid.ub = NA, grid.lb = NA, seed = 0) { # This function computes the ARP CI that includes nuisance parameters # for Delta^{SD}(M). This functions uses ARP_computeCI for all # of its computations. @@ -191,7 +191,7 @@ computeConditionalCS_DeltaSD <- function(betahat, sigma, numPrePeriods, numPostP } } else if (hybrid_flag == "LF") { # Compute LF CV - lf_cv = .compute_least_favorable_cv(X_T = NULL, sigma = A_SD %*% sigma %*% base::t(A_SD), hybrid_kappa = hybrid_kappa) + lf_cv = .compute_least_favorable_cv(X_T = NULL, sigma = A_SD %*% sigma %*% base::t(A_SD), hybrid_kappa = hybrid_kappa, seed = seed) # Store lf cv hybrid_list$lf_cv = lf_cv diff --git a/R/deltasdb.R b/R/deltasdb.R index a9f2bc4..7aa6cf3 100644 --- a/R/deltasdb.R +++ b/R/deltasdb.R @@ -114,7 +114,7 @@ computeConditionalCS_DeltaSDB <- function(betahat, sigma, numPrePeriods, numPost alpha = 0.05, hybrid_flag = "FLCI", hybrid_kappa = alpha/10, returnLength = FALSE, biasDirection = "positive", postPeriodMomentsOnly = TRUE, - gridPoints = 10^3, grid.lb = NA, grid.ub = NA) { + gridPoints = 10^3, grid.lb = NA, grid.ub = NA, seed = 0) { # This function computes the ARP CI that includes nuisance parameters # for Delta^{SDPB}(M). This functions uses ARP_computeCI for all # of its computations. @@ -177,7 +177,7 @@ computeConditionalCS_DeltaSDB <- function(betahat, sigma, numPrePeriods, numPost } } else if (hybrid_flag == "LF") { # Compute LF CV - lf_cv = .compute_least_favorable_cv(X_T = NULL, sigma = A_SDB %*% sigma %*% base::t(A_SDB), hybrid_kappa = hybrid_kappa) + lf_cv = .compute_least_favorable_cv(X_T = NULL, sigma = A_SDB %*% sigma %*% base::t(A_SDB), hybrid_kappa = hybrid_kappa, seed = seed) # Store lf cv hybrid_list$lf_cv = lf_cv diff --git a/R/deltasdm.R b/R/deltasdm.R index 9d8a2c1..90e671d 100644 --- a/R/deltasdm.R +++ b/R/deltasdm.R @@ -103,7 +103,7 @@ computeConditionalCS_DeltaSDM <- function(betahat, sigma, numPrePeriods, numPost alpha = 0.05, monotonicityDirection = "increasing", hybrid_flag = "FLCI", hybrid_kappa = alpha/10, returnLength = FALSE, postPeriodMomentsOnly = TRUE, - gridPoints=10^3, grid.lb = NA, grid.ub = NA) { + gridPoints=10^3, grid.lb = NA, grid.ub = NA, seed = 0) { # This function computes the ARP CI that includes nuisance parameters # for Delta^{SDI}(M). This functions uses ARP_computeCI for all # of its computations. @@ -164,7 +164,7 @@ computeConditionalCS_DeltaSDM <- function(betahat, sigma, numPrePeriods, numPost } } else if (hybrid_flag == "LF") { # Compute LF CV - lf_cv = .compute_least_favorable_cv(X_T = NULL, sigma = A_SDM %*% sigma %*% t(A_SDM), hybrid_kappa = hybrid_kappa) + lf_cv = .compute_least_favorable_cv(X_T = NULL, sigma = A_SDM %*% sigma %*% t(A_SDM), hybrid_kappa = hybrid_kappa, seed = seed) # Store lf cv hybrid_list$lf_cv = lf_cv diff --git a/R/deltasdrm.R b/R/deltasdrm.R index 01f125d..5e0f812 100644 --- a/R/deltasdrm.R +++ b/R/deltasdrm.R @@ -180,7 +180,7 @@ .computeConditionalCS_DeltaSDRM_fixedS <- function(s, max_positive, Mbar, betahat, sigma, numPrePeriods, numPostPeriods, l_vec, alpha, hybrid_flag, hybrid_kappa, - postPeriodMomentsOnly, gridPoints, grid.ub, grid.lb) { + postPeriodMomentsOnly, gridPoints, grid.ub, grid.lb, seed = seed) { # This function computes the ARP CI that includes nuisance parameters # for Delta^{SDRM}(Mbar) for a fixed s and (+),(-). This functions uses ARP_computeCI for all # of its computations. It is used as a helper function in computeConditionalCS_DeltaSDRM below. @@ -220,7 +220,7 @@ if (numPostPeriods == 1) { if (hybrid_flag == "LF") { # Compute LF CV and store it in hybrid_list - lf_cv = .compute_least_favorable_cv(X_T = NULL, sigma = A_SDRM_s %*% sigma %*% base::t(A_SDRM_s), hybrid_kappa = hybrid_kappa) + lf_cv = .compute_least_favorable_cv(X_T = NULL, sigma = A_SDRM_s %*% sigma %*% base::t(A_SDRM_s), hybrid_kappa = hybrid_kappa, seed = 0) hybrid_list$lf_cv = lf_cv } # Compute confidence set @@ -248,7 +248,7 @@ computeConditionalCS_DeltaSDRM <- function(betahat, sigma, numPrePeriods, numPos l_vec = .basisVector(index = 1, size = numPostPeriods), Mbar = 0, alpha = 0.05, hybrid_flag = "LF", hybrid_kappa = alpha/10, returnLength = FALSE, postPeriodMomentsOnly = TRUE, - gridPoints = 10^3, grid.ub = NA, grid.lb = NA) { + gridPoints = 10^3, grid.ub = NA, grid.lb = NA, seed = 0) { # This function computes the ARP CI that includes nuisance parameters # for Delta^{SDRM}(Mbar). This functions uses ARP_computeCI for all # of its computations. @@ -297,7 +297,7 @@ computeConditionalCS_DeltaSDRM <- function(betahat, sigma, numPrePeriods, numPos numPostPeriods = numPostPeriods, l_vec = l_vec, alpha = alpha, hybrid_flag = hybrid_flag, hybrid_kappa = hybrid_kappa, postPeriodMomentsOnly = postPeriodMomentsOnly, - gridPoints = gridPoints, grid.ub = grid.ub, grid.lb = grid.lb) + gridPoints = gridPoints, grid.ub = grid.ub, grid.lb = grid.lb, seed = seed) CIs_SDRM_plus_allS[,s_i] = CI_s_plus$accept # Compute CI for s, (-) and bind it to all CI's for (-) @@ -306,7 +306,7 @@ computeConditionalCS_DeltaSDRM <- function(betahat, sigma, numPrePeriods, numPos numPostPeriods = numPostPeriods, l_vec = l_vec, alpha = alpha, hybrid_flag = hybrid_flag, hybrid_kappa = hybrid_kappa, postPeriodMomentsOnly = postPeriodMomentsOnly, - gridPoints = gridPoints, grid.ub = grid.ub, grid.lb = grid.lb) + gridPoints = gridPoints, grid.ub = grid.ub, grid.lb = grid.lb, seed = seed) CIs_SDRM_minus_allS[,s_i] = CI_s_minus$accept } CIs_SDRM_plus_maxS = base::apply(CIs_SDRM_plus_allS, MARGIN = 1, FUN = max) diff --git a/R/deltasdrmb.R b/R/deltasdrmb.R index c1653e9..f05fd57 100644 --- a/R/deltasdrmb.R +++ b/R/deltasdrmb.R @@ -194,7 +194,7 @@ .computeConditionalCS_DeltaSDRMB_fixedS <- function(s, max_positive, Mbar, betahat, sigma, numPrePeriods, numPostPeriods, l_vec, alpha, hybrid_flag, hybrid_kappa, biasDirection, - postPeriodMomentsOnly, gridPoints, grid.ub, grid.lb) { + postPeriodMomentsOnly, gridPoints, grid.ub, grid.lb, seed = 0) { # This function computes the ARP CI that includes nuisance parameters # for Delta^{SDRMB}(Mbar) for a fixed s and (+),(-). This functions uses ARP_computeCI for all # of its computations. It is used as a helper function in computeConditionalCS_DeltaSDRMB below. @@ -233,7 +233,7 @@ if (numPostPeriods == 1) { if (hybrid_flag == "LF") { # Compute LF CV and store it in hybrid_list - lf_cv = .compute_least_favorable_cv(X_T = NULL, sigma = A_SDRMB_s %*% sigma %*% base::t(A_SDRMB_s), hybrid_kappa = hybrid_kappa) + lf_cv = .compute_least_favorable_cv(X_T = NULL, sigma = A_SDRMB_s %*% sigma %*% base::t(A_SDRMB_s), hybrid_kappa = hybrid_kappa, seed = seed) hybrid_list$lf_cv = lf_cv } # Compute confidence set @@ -262,7 +262,7 @@ computeConditionalCS_DeltaSDRMB <- function(betahat, sigma, numPrePeriods, numPo Mbar = 0, alpha = 0.05, hybrid_flag = "LF", hybrid_kappa = alpha/10, returnLength = FALSE, postPeriodMomentsOnly = TRUE, biasDirection = "positive", - gridPoints = 10^3, grid.ub = NA, grid.lb = NA) { + gridPoints = 10^3, grid.ub = NA, grid.lb = NA, seed = 0) { # This function computes the ARP CI that includes nuisance parameters # for Delta^{SDRMB}(Mbar). This functions uses ARP_computeCI for all # of its computations. @@ -311,7 +311,7 @@ computeConditionalCS_DeltaSDRMB <- function(betahat, sigma, numPrePeriods, numPo numPostPeriods = numPostPeriods, l_vec = l_vec, alpha = alpha, hybrid_flag = hybrid_flag, hybrid_kappa = hybrid_kappa, postPeriodMomentsOnly = postPeriodMomentsOnly, biasDirection = biasDirection, - gridPoints = gridPoints, grid.ub = grid.ub, grid.lb = grid.lb) + gridPoints = gridPoints, grid.ub = grid.ub, grid.lb = grid.lb, seed = seed) CIs_SDRMB_plus_allS[,s_i] = CI_s_plus$accept # Compute CI for s, (-) and bind it to all CI's for (-) @@ -320,7 +320,7 @@ computeConditionalCS_DeltaSDRMB <- function(betahat, sigma, numPrePeriods, numPo numPostPeriods = numPostPeriods, l_vec = l_vec, alpha = alpha, hybrid_flag = hybrid_flag, hybrid_kappa = hybrid_kappa, postPeriodMomentsOnly = postPeriodMomentsOnly, biasDirection = biasDirection, - gridPoints = gridPoints, grid.ub = grid.ub, grid.lb = grid.lb) + gridPoints = gridPoints, grid.ub = grid.ub, grid.lb = grid.lb, seed = seed) CIs_SDRMB_minus_allS[,s_i] = CI_s_minus$accept } CIs_SDRMB_plus_maxS = base::apply(CIs_SDRMB_plus_allS, MARGIN = 1, FUN = base::max) diff --git a/R/deltasdrmm.R b/R/deltasdrmm.R index 53608df..78459f2 100644 --- a/R/deltasdrmm.R +++ b/R/deltasdrmm.R @@ -195,7 +195,7 @@ betahat, sigma, numPrePeriods, numPostPeriods, l_vec, alpha, hybrid_flag, hybrid_kappa, postPeriodMomentsOnly, monotonicityDirection, - gridPoints, grid.ub, grid.lb) { + gridPoints, grid.ub, grid.lb, seed = 0) { # This function computes the ARP CI that includes nuisance parameters # for Delta^{SDRMM}(Mbar) for a fixed s and (+),(-). This functions uses ARP_computeCI for all # of its computations. It is used as a helper function in computeConditionalCS_DeltaSDRMM below. @@ -236,7 +236,7 @@ if (numPostPeriods == 1) { if (hybrid_flag == "LF") { # Compute LF CV and store it in hybrid_list - lf_cv = .compute_least_favorable_cv(X_T = NULL, sigma = A_SDRMM_s %*% sigma %*% base::t(A_SDRMM_s), hybrid_kappa = hybrid_kappa) + lf_cv = .compute_least_favorable_cv(X_T = NULL, sigma = A_SDRMM_s %*% sigma %*% base::t(A_SDRMM_s), hybrid_kappa = hybrid_kappa, seed = seed) hybrid_list$lf_cv = lf_cv } # Compute confidence set @@ -266,7 +266,7 @@ computeConditionalCS_DeltaSDRMM <- function(betahat, sigma, numPrePeriods, numPo hybrid_kappa = alpha/10, returnLength = FALSE, postPeriodMomentsOnly = TRUE, monotonicityDirection = "increasing", - gridPoints = 10^3, grid.ub = NA, grid.lb = NA) { + gridPoints = 10^3, grid.ub = NA, grid.lb = NA, seed = 0) { # This function computes the ARP CI that includes nuisance parameters # for Delta^{SDRMM}(Mbar). This functions uses ARP_computeCI for all # of its computations. @@ -315,7 +315,7 @@ computeConditionalCS_DeltaSDRMM <- function(betahat, sigma, numPrePeriods, numPo numPostPeriods = numPostPeriods, l_vec = l_vec, alpha = alpha, hybrid_flag = hybrid_flag, hybrid_kappa = hybrid_kappa, postPeriodMomentsOnly = postPeriodMomentsOnly, monotonicityDirection = monotonicityDirection, - gridPoints = gridPoints, grid.ub = grid.ub, grid.lb = grid.lb) + gridPoints = gridPoints, grid.ub = grid.ub, grid.lb = grid.lb, seed = seed) CIs_SDRMM_plus_allS[,s_i] = CI_s_plus$accept # Compute CI for s, (-) and bind it to all CI's for (-) @@ -324,7 +324,7 @@ computeConditionalCS_DeltaSDRMM <- function(betahat, sigma, numPrePeriods, numPo numPostPeriods = numPostPeriods, l_vec = l_vec, alpha = alpha, hybrid_flag = hybrid_flag, hybrid_kappa = hybrid_kappa, postPeriodMomentsOnly = postPeriodMomentsOnly, monotonicityDirection = monotonicityDirection, - gridPoints = gridPoints, grid.ub = grid.ub, grid.lb = grid.lb) + gridPoints = gridPoints, grid.ub = grid.ub, grid.lb = grid.lb, seed = seed) CIs_SDRMM_minus_allS[,s_i] = CI_s_minus$accept } CIs_SDRMM_plus_maxS = base::apply(CIs_SDRMM_plus_allS, MARGIN = 1, FUN = base::max) diff --git a/R/flci.R b/R/flci.R index 3150b46..2a507e0 100644 --- a/R/flci.R +++ b/R/flci.R @@ -215,10 +215,10 @@ .findOptimalFLCI_helper <- function(sigma, M, numPrePeriods, numPostPeriods, - l_vec, numPoints = 100, alpha){ + l_vec, numPoints = 100, alpha, seed = 0){ h0 <- .findHForMinimumBias(sigma = sigma, numPrePeriods = numPrePeriods, numPostPeriods = numPostPeriods, l_vec = l_vec) hMin <- .findLowestH(sigma = sigma, numPrePeriods = numPrePeriods, numPostPeriods = numPostPeriods, l_vec = l_vec) - hstar <- .findOptimalCIDerivativeBisection(hMin, h0, M, numPoints, alpha, sigma, numPrePeriods, numPostPeriods, l_vec, TRUE) + hstar <- .findOptimalCIDerivativeBisection(hMin, h0, M, numPoints, alpha, sigma, numPrePeriods, numPostPeriods, l_vec, TRUE, seed=seed) if ( base::is.na(hstar) ) { # Numerical derivatives will occasionally fail; fall back into grid @@ -260,14 +260,14 @@ } .findOptimalCIDerivativeBisection <- function(a, b, M, numPoints, alpha, sigma, - numPrePeriods, numPostPeriods, l_vec, returnDF) { + numPrePeriods, numPostPeriods, l_vec, returnDF, seed=0) { # Function of h, which is convex (returns CI half length) .f <- function(h, ...) { biasDF <- .findWorstCaseBiasGivenH(h, sigma, numPrePeriods, numPostPeriods, l_vec, returnDF) maxBias <- M * biasDF$value if (biasDF$value < Inf) { - base::return(.qfoldednormal(p = 1-alpha, mu = maxBias/h) * h) + base::return(.qfoldednormal(p = 1-alpha, mu = maxBias/h, seed=seed) * h) } else { base::return(NaN) } @@ -319,14 +319,15 @@ findOptimalFLCI <- function(betahat, sigma, M = 0, numPrePeriods, numPostPeriods, l_vec = .basisVector(index = 1, size = numPostPeriods), - numPoints = 100, alpha = 0.05) { + numPoints = 100, alpha = 0.05, seed = 0) { FLCI_Results = .findOptimalFLCI_helper(sigma = sigma, M = M, numPrePeriods = numPrePeriods, numPostPeriods = numPostPeriods, l_vec = l_vec, numPoints = numPoints, - alpha = alpha) + alpha = alpha, + seed = seed) FLCI = base::c(base::t(FLCI_Results$optimalVec) %*% betahat - FLCI_Results$optimalHalfLength, base::t(FLCI_Results$optimalVec) %*% betahat + FLCI_Results$optimalHalfLength) diff --git a/R/sensitivityresults.R b/R/sensitivityresults.R index e6cb97b..4b079d8 100644 --- a/R/sensitivityresults.R +++ b/R/sensitivityresults.R @@ -17,7 +17,8 @@ createSensitivityResults <- function(betahat, sigma, monotonicityDirection = NULL, biasDirection = NULL, alpha = 0.05, - parallel = FALSE) { + parallel = FALSE, + seed = 0) { .stopIfNotConformable(betahat, sigma, numPrePeriods, numPostPeriods, l_vec) .warnIfNotSymmPSD(sigma) @@ -44,7 +45,7 @@ createSensitivityResults <- function(betahat, sigma, Results = foreach::foreach(m = 1:base::length(Mvec), .combine = 'rbind') %do% { temp = findOptimalFLCI(betahat = betahat, sigma = sigma, numPrePeriods = numPrePeriods, numPostPeriods = numPostPeriods, - l_vec = l_vec, M = Mvec[m], alpha = alpha) + l_vec = l_vec, M = Mvec[m], alpha = alpha, seed = seed) tibble::tibble(lb = temp$FLCI[1], ub = temp$FLCI[2], method = "FLCI", Delta = "DeltaSD", M = Mvec[m]) } @@ -52,7 +53,7 @@ createSensitivityResults <- function(betahat, sigma, Results = foreach::foreach(m = 1:base::length(Mvec), .combine = 'rbind') %dopar% { temp = findOptimalFLCI(betahat = betahat, sigma = sigma, numPrePeriods = numPrePeriods, numPostPeriods = numPostPeriods, - l_vec = l_vec, M = Mvec[m], alpha = alpha) + l_vec = l_vec, M = Mvec[m], alpha = alpha, seed = seed) tibble::tibble(lb = temp$FLCI[1], ub = temp$FLCI[2], method = "FLCI", Delta = "DeltaSD", M = Mvec[m]) } @@ -64,7 +65,7 @@ createSensitivityResults <- function(betahat, sigma, numPrePeriods = numPrePeriods, numPostPeriods = numPostPeriods, l_vec = l_vec, alpha = alpha, M = Mvec[m], - hybrid_flag = "ARP") + hybrid_flag = "ARP", seed = seed) tibble::tibble(lb = base::min(temp$grid[temp$accept == 1]), ub = base::max(temp$grid[temp$accept == 1]), method = "Conditional", @@ -76,7 +77,7 @@ createSensitivityResults <- function(betahat, sigma, numPrePeriods = numPrePeriods, numPostPeriods = numPostPeriods, l_vec = l_vec, alpha = alpha, M = Mvec[m], - hybrid_flag = "ARP") + hybrid_flag = "ARP", seed = seed) tibble::tibble(lb = base::min(temp$grid[temp$accept == 1]), ub = base::max(temp$grid[temp$accept == 1]), method = "Conditional", @@ -90,7 +91,7 @@ createSensitivityResults <- function(betahat, sigma, numPrePeriods = numPrePeriods, numPostPeriods = numPostPeriods, l_vec = l_vec, alpha = alpha, M = Mvec[m], - hybrid_flag = "FLCI") + hybrid_flag = "FLCI", seed = seed) tibble::tibble(lb = base::min(temp$grid[temp$accept == 1]), ub = base::max(temp$grid[temp$accept == 1]), method = "C-F", @@ -102,7 +103,7 @@ createSensitivityResults <- function(betahat, sigma, numPrePeriods = numPrePeriods, numPostPeriods = numPostPeriods, l_vec = l_vec, alpha = alpha, M = Mvec[m], - hybrid_flag = "FLCI") + hybrid_flag = "FLCI", seed = seed) tibble::tibble(lb = base::min(temp$grid[temp$accept == 1]), ub = base::max(temp$grid[temp$accept == 1]), method = "C-F", @@ -116,7 +117,7 @@ createSensitivityResults <- function(betahat, sigma, numPrePeriods = numPrePeriods, numPostPeriods = numPostPeriods, l_vec = l_vec, alpha = alpha, M = Mvec[m], - hybrid_flag = "LF") + hybrid_flag = "LF", seed = seed) tibble::tibble(lb = base::min(temp$grid[temp$accept == 1]), ub = base::max(temp$grid[temp$accept == 1]), method = "C-LF", @@ -128,7 +129,7 @@ createSensitivityResults <- function(betahat, sigma, numPrePeriods = numPrePeriods, numPostPeriods = numPostPeriods, l_vec = l_vec, alpha = alpha, M = Mvec[m], - hybrid_flag = "LF") + hybrid_flag = "LF", seed = seed) tibble::tibble(lb = base::min(temp$grid[temp$accept == 1]), ub = base::max(temp$grid[temp$accept == 1]), method = "C-LF", @@ -155,7 +156,7 @@ createSensitivityResults <- function(betahat, sigma, Results = foreach::foreach(m = 1:base::length(Mvec), .combine = 'rbind') %do% { temp = findOptimalFLCI(betahat = betahat, sigma = sigma, numPrePeriods = numPrePeriods, numPostPeriods = numPostPeriods, - l_vec = l_vec, M = Mvec[m], alpha = alpha) + l_vec = l_vec, M = Mvec[m], alpha = alpha, seed = seed) tibble::tibble(lb = temp$FLCI[1], ub = temp$FLCI[2], method = "FLCI", Delta = Delta, M = Mvec[m]) } @@ -163,7 +164,7 @@ createSensitivityResults <- function(betahat, sigma, Results = foreach::foreach(m = 1:base::length(Mvec), .combine = 'rbind') %dopar% { temp = findOptimalFLCI(betahat = betahat, sigma = sigma, numPrePeriods = numPrePeriods, numPostPeriods = numPostPeriods, - l_vec = l_vec, M = Mvec[m], alpha = alpha) + l_vec = l_vec, M = Mvec[m], alpha = alpha, seed = seed) tibble::tibble(lb = temp$FLCI[1], ub = temp$FLCI[2], method = "FLCI", Delta = Delta, M = Mvec[m]) } @@ -176,7 +177,7 @@ createSensitivityResults <- function(betahat, sigma, numPostPeriods = numPostPeriods, l_vec = l_vec, alpha = alpha, M = Mvec[m], biasDirection = biasDirection, - hybrid_flag = "ARP") + hybrid_flag = "ARP", seed = seed) tibble::tibble(lb = base::min(temp$grid[temp$accept == 1]), ub = base::max(temp$grid[temp$accept == 1]), method = "Conditional", @@ -189,7 +190,7 @@ createSensitivityResults <- function(betahat, sigma, numPostPeriods = numPostPeriods, l_vec = l_vec, alpha = alpha, M = Mvec[m], biasDirection = biasDirection, - hybrid_flag = "ARP") + hybrid_flag = "ARP", seed = seed) tibble::tibble(lb = base::min(temp$grid[temp$accept == 1]), ub = base::max(temp$grid[temp$accept == 1]), method = "Conditional", @@ -204,7 +205,7 @@ createSensitivityResults <- function(betahat, sigma, numPostPeriods = numPostPeriods, l_vec = l_vec, alpha = alpha, M = Mvec[m], biasDirection = biasDirection, - hybrid_flag = "FLCI") + hybrid_flag = "FLCI", seed = seed) tibble::tibble(lb = base::min(temp$grid[temp$accept == 1]), ub = base::max(temp$grid[temp$accept == 1]), method = "C-F", @@ -217,7 +218,7 @@ createSensitivityResults <- function(betahat, sigma, numPostPeriods = numPostPeriods, l_vec = l_vec, alpha = alpha, M = Mvec[m], biasDirection = biasDirection, - hybrid_flag = "FLCI") + hybrid_flag = "FLCI", seed = seed) tibble::tibble(lb = base::min(temp$grid[temp$accept == 1]), ub = base::max(temp$grid[temp$accept == 1]), method = "C-F", @@ -232,7 +233,7 @@ createSensitivityResults <- function(betahat, sigma, numPostPeriods = numPostPeriods, l_vec = l_vec, alpha = alpha, M = Mvec[m], biasDirection = biasDirection, - hybrid_flag = "LF") + hybrid_flag = "LF", seed = seed) tibble::tibble(lb = base::min(temp$grid[temp$accept == 1]), ub = base::max(temp$grid[temp$accept == 1]), method = "C-LF", @@ -245,7 +246,7 @@ createSensitivityResults <- function(betahat, sigma, numPostPeriods = numPostPeriods, l_vec = l_vec, alpha = alpha, M = Mvec[m], biasDirection = biasDirection, - hybrid_flag = "LF") + hybrid_flag = "LF", seed = seed) tibble::tibble(lb = base::min(temp$grid[temp$accept == 1]), ub = base::max(temp$grid[temp$accept == 1]), method = "C-LF", @@ -272,7 +273,7 @@ createSensitivityResults <- function(betahat, sigma, Results = foreach::foreach(m = 1:base::length(Mvec), .combine = 'rbind') %do% { temp = findOptimalFLCI(betahat = betahat, sigma = sigma, numPrePeriods = numPrePeriods, numPostPeriods = numPostPeriods, - l_vec = l_vec, M = Mvec[m], alpha = alpha) + l_vec = l_vec, M = Mvec[m], alpha = alpha, seed = seed) tibble::tibble(lb = temp$FLCI[1], ub = temp$FLCI[2], method = "FLCI", Delta = Delta, M = Mvec[m]) } @@ -280,7 +281,7 @@ createSensitivityResults <- function(betahat, sigma, Results = foreach::foreach(m = 1:base::length(Mvec), .combine = 'rbind') %dopar% { temp = findOptimalFLCI(betahat = betahat, sigma = sigma, numPrePeriods = numPrePeriods, numPostPeriods = numPostPeriods, - l_vec = l_vec, M = Mvec[m], alpha = alpha) + l_vec = l_vec, M = Mvec[m], alpha = alpha, seed = seed) tibble::tibble(lb = temp$FLCI[1], ub = temp$FLCI[2], method = "FLCI", Delta = Delta, M = Mvec[m]) } @@ -293,7 +294,7 @@ createSensitivityResults <- function(betahat, sigma, numPostPeriods = numPostPeriods, l_vec = l_vec, alpha = alpha, M = Mvec[m], monotonicityDirection = monotonicityDirection, - hybrid_flag = "ARP") + hybrid_flag = "ARP", seed = seed) tibble::tibble(lb = base::min(temp$grid[temp$accept == 1]), ub = base::max(temp$grid[temp$accept == 1]), method = "Conditional", @@ -306,7 +307,7 @@ createSensitivityResults <- function(betahat, sigma, numPostPeriods = numPostPeriods, l_vec = l_vec, alpha = alpha, M = Mvec[m], monotonicityDirection = monotonicityDirection, - hybrid_flag = "ARP") + hybrid_flag = "ARP", seed = seed) tibble::tibble(lb = base::min(temp$grid[temp$accept == 1]), ub = base::max(temp$grid[temp$accept == 1]), method = "Conditional", @@ -321,7 +322,7 @@ createSensitivityResults <- function(betahat, sigma, numPostPeriods = numPostPeriods, l_vec = l_vec, alpha = alpha, M = Mvec[m], monotonicityDirection = monotonicityDirection, - hybrid_flag = "FLCI") + hybrid_flag = "FLCI", seed = seed) tibble::tibble(lb = base::min(temp$grid[temp$accept == 1]), ub = base::max(temp$grid[temp$accept == 1]), method = "C-F", @@ -335,7 +336,7 @@ createSensitivityResults <- function(betahat, sigma, numPostPeriods = numPostPeriods, l_vec = l_vec, alpha = alpha, M = Mvec[m], monotonicityDirection = monotonicityDirection, - hybrid_flag = "FLCI") + hybrid_flag = "FLCI", seed = seed) tibble::tibble(lb = base::min(temp$grid[temp$accept == 1]), ub = base::max(temp$grid[temp$accept == 1]), method = "C-F", @@ -351,7 +352,7 @@ createSensitivityResults <- function(betahat, sigma, numPostPeriods = numPostPeriods, l_vec = l_vec, alpha = alpha, M = Mvec[m], monotonicityDirection = monotonicityDirection, - hybrid_flag = "LF") + hybrid_flag = "LF", seed = seed) tibble::tibble(lb = base::min(temp$grid[temp$accept == 1]), ub = base::max(temp$grid[temp$accept == 1]), method = "C-LF", @@ -364,7 +365,7 @@ createSensitivityResults <- function(betahat, sigma, numPostPeriods = numPostPeriods, l_vec = l_vec, alpha = alpha, M = Mvec[m], monotonicityDirection = monotonicityDirection, - hybrid_flag = "LF") + hybrid_flag = "LF", seed = seed) tibble::tibble(lb = base::min(temp$grid[temp$accept == 1]), ub = base::max(temp$grid[temp$accept == 1]), method = "C-LF", @@ -418,7 +419,8 @@ createSensitivityResults_relativeMagnitudes <- function(betahat, sigma, gridPoints = 10^3, grid.ub = NA, grid.lb = NA, - parallel = FALSE) { + parallel = FALSE, + seed = 0) { .stopIfNotConformable(betahat, sigma, numPrePeriods, numPostPeriods, l_vec) .warnIfNotSymmPSD(sigma) @@ -463,7 +465,7 @@ createSensitivityResults_relativeMagnitudes <- function(betahat, sigma, numPostPeriods = numPostPeriods, l_vec = l_vec, alpha = alpha, Mbar = Mbarvec[m], hybrid_flag = hybrid_flag, - gridPoints = gridPoints, grid.ub = grid.ub, grid.lb = grid.lb) + gridPoints = gridPoints, grid.ub = grid.ub, grid.lb = grid.lb, seed = seed) tibble::tibble(lb = base::min(temp$grid[temp$accept == 1]), ub = base::max(temp$grid[temp$accept == 1]), method = method_named, @@ -476,7 +478,7 @@ createSensitivityResults_relativeMagnitudes <- function(betahat, sigma, numPostPeriods = numPostPeriods, l_vec = l_vec, alpha = alpha, Mbar = Mbarvec[m], hybrid_flag = hybrid_flag, - gridPoints = gridPoints, grid.ub = grid.ub, grid.lb = grid.lb) + gridPoints = gridPoints, grid.ub = grid.ub, grid.lb = grid.lb, seed = seed) tibble::tibble(lb = base::min(temp$grid[temp$accept == 1]), ub = base::max(temp$grid[temp$accept == 1]), method = method_named, @@ -500,7 +502,7 @@ createSensitivityResults_relativeMagnitudes <- function(betahat, sigma, l_vec = l_vec, alpha = alpha, Mbar = Mbarvec[m], monotonicityDirection = monotonicityDirection, hybrid_flag = hybrid_flag, - gridPoints = gridPoints, grid.ub = grid.ub, grid.lb = grid.lb) + gridPoints = gridPoints, grid.ub = grid.ub, grid.lb = grid.lb, seed = seed) tibble::tibble(lb = base::min(temp$grid[temp$accept == 1]), ub = base::max(temp$grid[temp$accept == 1]), method = method_named, @@ -514,7 +516,7 @@ createSensitivityResults_relativeMagnitudes <- function(betahat, sigma, l_vec = l_vec, alpha = alpha, Mbar = Mbarvec[m], monotonicityDirection = monotonicityDirection, hybrid_flag = hybrid_flag, - gridPoints = gridPoints, grid.ub = grid.ub, grid.lb = grid.lb) + gridPoints = gridPoints, grid.ub = grid.ub, grid.lb = grid.lb, seed = seed) tibble::tibble(lb = base::min(temp$grid[temp$accept == 1]), ub = base::max(temp$grid[temp$accept == 1]), method = method_named, @@ -538,7 +540,7 @@ createSensitivityResults_relativeMagnitudes <- function(betahat, sigma, l_vec = l_vec, alpha = alpha, Mbar = Mbarvec[m], biasDirection = biasDirection, hybrid_flag = hybrid_flag, - gridPoints = gridPoints, grid.ub = grid.ub, grid.lb = grid.lb) + gridPoints = gridPoints, grid.ub = grid.ub, grid.lb = grid.lb, seed = seed) tibble::tibble(lb = base::min(temp$grid[temp$accept == 1]), ub = base::max(temp$grid[temp$accept == 1]), method = method_named, @@ -552,7 +554,7 @@ createSensitivityResults_relativeMagnitudes <- function(betahat, sigma, l_vec = l_vec, alpha = alpha, Mbar = Mbarvec[m], biasDirection = biasDirection, hybrid_flag = hybrid_flag, - gridPoints = gridPoints, grid.ub = grid.ub, grid.lb = grid.lb) + gridPoints = gridPoints, grid.ub = grid.ub, grid.lb = grid.lb, seed = seed) tibble::tibble(lb = base::min(temp$grid[temp$accept == 1]), ub = base::max(temp$grid[temp$accept == 1]), method = method_named, @@ -580,7 +582,7 @@ createSensitivityResults_relativeMagnitudes <- function(betahat, sigma, numPostPeriods = numPostPeriods, l_vec = l_vec, alpha = alpha, Mbar = Mbarvec[m], hybrid_flag = hybrid_flag, - gridPoints = gridPoints, grid.ub = grid.ub, grid.lb = grid.lb) + gridPoints = gridPoints, grid.ub = grid.ub, grid.lb = grid.lb, seed = seed) tibble::tibble(lb = base::min(temp$grid[temp$accept == 1]), ub = base::max(temp$grid[temp$accept == 1]), method = method_named, @@ -593,7 +595,7 @@ createSensitivityResults_relativeMagnitudes <- function(betahat, sigma, numPostPeriods = numPostPeriods, l_vec = l_vec, alpha = alpha, Mbar = Mbarvec[m], hybrid_flag = hybrid_flag, - gridPoints = gridPoints, grid.ub = grid.ub, grid.lb = grid.lb) + gridPoints = gridPoints, grid.ub = grid.ub, grid.lb = grid.lb, seed = seed) tibble::tibble(lb = base::min(temp$grid[temp$accept == 1]), ub = base::max(temp$grid[temp$accept == 1]), method = method_named, @@ -617,7 +619,7 @@ createSensitivityResults_relativeMagnitudes <- function(betahat, sigma, l_vec = l_vec, alpha = alpha, Mbar = Mbarvec[m], monotonicityDirection = monotonicityDirection, hybrid_flag = hybrid_flag, - gridPoints = gridPoints, grid.ub = grid.ub, grid.lb = grid.lb) + gridPoints = gridPoints, grid.ub = grid.ub, grid.lb = grid.lb, seed = seed) tibble::tibble(lb = base::min(temp$grid[temp$accept == 1]), ub = base::max(temp$grid[temp$accept == 1]), method = method_named, @@ -631,7 +633,7 @@ createSensitivityResults_relativeMagnitudes <- function(betahat, sigma, l_vec = l_vec, alpha = alpha, Mbar = Mbarvec[m], monotonicityDirection = monotonicityDirection, hybrid_flag = hybrid_flag, - gridPoints = gridPoints, grid.ub = grid.ub, grid.lb = grid.lb) + gridPoints = gridPoints, grid.ub = grid.ub, grid.lb = grid.lb, seed = seed) tibble::tibble(lb = base::min(temp$grid[temp$accept == 1]), ub = base::max(temp$grid[temp$accept == 1]), method = method_named, @@ -655,7 +657,7 @@ createSensitivityResults_relativeMagnitudes <- function(betahat, sigma, l_vec = l_vec, alpha = alpha, Mbar = Mbarvec[m], biasDirection = biasDirection, hybrid_flag = hybrid_flag, - gridPoints = gridPoints, grid.ub = grid.ub, grid.lb = grid.lb) + gridPoints = gridPoints, grid.ub = grid.ub, grid.lb = grid.lb, seed = seed) tibble::tibble(lb = base::min(temp$grid[temp$accept == 1]), ub = base::max(temp$grid[temp$accept == 1]), method = method_named, @@ -669,7 +671,7 @@ createSensitivityResults_relativeMagnitudes <- function(betahat, sigma, l_vec = l_vec, alpha = alpha, Mbar = Mbarvec[m], biasDirection = biasDirection, hybrid_flag = hybrid_flag, - gridPoints = gridPoints, grid.ub = grid.ub, grid.lb = grid.lb) + gridPoints = gridPoints, grid.ub = grid.ub, grid.lb = grid.lb, seed = seed) tibble::tibble(lb = base::min(temp$grid[temp$accept == 1]), ub = base::max(temp$grid[temp$accept == 1]), method = method_named, diff --git a/man/computeConditionalCS_DeltaRM.Rd b/man/computeConditionalCS_DeltaRM.Rd index 42753ca..fbc7051 100644 --- a/man/computeConditionalCS_DeltaRM.Rd +++ b/man/computeConditionalCS_DeltaRM.Rd @@ -12,7 +12,7 @@ computeConditionalCS_DeltaRM(betahat, sigma, numPrePeriods, numPostPeriods, l_vec = .basisVector(index = 1, size = numPostPeriods), Mbar = 0, alpha = 0.05, hybrid_flag = "LF", hybrid_kappa = alpha/10, returnLength = FALSE, postPeriodMomentsOnly = TRUE, - gridPoints=10^3, grid.ub = NA, grid.lb = NA) + gridPoints=10^3, grid.ub = NA, grid.lb = NA, seed = 0) } %- maybe also 'usage' for other objects documented here. \arguments{ @@ -58,6 +58,9 @@ Logical value. If TRUE, function only returns the length of the robust confidenc \item{grid.lb}{ Lower bound of grid for test inversion. The user should only specify this if she wishes to manually specify the upper bound of the grid. Default equals NA sets grid lower bound to equal the lower bound of the identified set under parallel trends minus 20*standard deviation of the point estimate, l_vec'betahat. } + \item{seed}{ + Random seed for internal computations; included for reproducibility. + } } \value{ If returnLength equals TRUE, function returns a scalar that equals the length of the confidence interval. If returnLength equals FALSE, function returns a dataframe with columns diff --git a/man/computeConditionalCS_DeltaRMB.Rd b/man/computeConditionalCS_DeltaRMB.Rd index 6c15ba7..966b030 100644 --- a/man/computeConditionalCS_DeltaRMB.Rd +++ b/man/computeConditionalCS_DeltaRMB.Rd @@ -14,7 +14,7 @@ computeConditionalCS_DeltaRMB(betahat, sigma, numPrePeriods, numPostPeriods, Mbar = 0, alpha = 0.05, hybrid_flag = "LF", hybrid_kappa = alpha/10, returnLength = FALSE, biasDirection = "positive", postPeriodMomentsOnly = TRUE, - gridPoints=10^3, grid.ub = NA, grid.lb = NA) + gridPoints=10^3, grid.ub = NA, grid.lb = NA, seed = 0) } %- maybe also 'usage' for other objects documented here. \arguments{ @@ -63,6 +63,9 @@ Logical value. If TRUE, function only returns the length of the robust confidenc \item{grid.lb}{ Lower bound of grid for test inversion. The user should only specify this if she wishes to manually specify the upper bound of the grid. Default equals NA sets grid lower bound to equal the lower bound of the identified set under parallel trends minus 20*standard deviation of the point estimate, l_vec'betahat. } + \item{seed}{ + Random seed for internal computations; included for reproducibility. + } } \value{ If returnLength equals TRUE, function returns a scalar that equals the length of the confidence interval. If returnLength equals FALSE, function returns a dataframe with columns diff --git a/man/computeConditionalCS_DeltaRMM.Rd b/man/computeConditionalCS_DeltaRMM.Rd index 40647fb..132a4df 100644 --- a/man/computeConditionalCS_DeltaRMM.Rd +++ b/man/computeConditionalCS_DeltaRMM.Rd @@ -15,7 +15,7 @@ computeConditionalCS_DeltaRMM(betahat, sigma, numPrePeriods, numPostPeriods, alpha = 0.05, hybrid_flag = "LF", hybrid_kappa = alpha/10, returnLength = FALSE, postPeriodMomentsOnly = TRUE, monotonicityDirection = "increasing", - gridPoints=10^3, grid.ub = NA, grid.lb = NA) + gridPoints=10^3, grid.ub = NA, grid.lb = NA, seed = 0) } %- maybe also 'usage' for other objects documented here. \arguments{ @@ -64,6 +64,9 @@ Specifies direction of monotonicity restriction. If "increasing", underlying tre \item{grid.lb}{ Lower bound of grid for test inversion. The user should only specify this if she wishes to manually specify the upper bound of the grid. Default equals NA sets grid lower bound to equal the lower bound of the identified set under parallel trends minus 20*standard deviation of the point estimate, l_vec'betahat. } + \item{seed}{ + Random seed for internal computations; included for reproducibility. + } } \value{ If returnLength equals TRUE, function returns a scalar that equals the length of the confidence interval. If returnLength equals FALSE, function returns a dataframe with columns diff --git a/man/computeConditionalCS_DeltaSD.Rd b/man/computeConditionalCS_DeltaSD.Rd index ab5563f..3e2a43d 100644 --- a/man/computeConditionalCS_DeltaSD.Rd +++ b/man/computeConditionalCS_DeltaSD.Rd @@ -13,7 +13,7 @@ computeConditionalCS_DeltaSD(betahat, sigma, numPrePeriods, numPostPeriods, M = 0, alpha = 0.05, hybrid_flag = "FLCI", hybrid_kappa = alpha/10, returnLength = FALSE, postPeriodMomentsOnly = TRUE, - gridPoints =10^3, grid.ub = NA, grid.lb = NA) + gridPoints =10^3, grid.ub = NA, grid.lb = NA, seed = 0) } %- maybe also 'usage' for other objects documented here. \arguments{ @@ -59,6 +59,9 @@ Logical value. If TRUE, function only returns the length of the robust confidenc \item{grid.lb}{ Lower bound of grid for test inversion. The user should only specify this if she wishes to manually specify the upper bound of the grid. Default equals NA sets grid lower bound to equal the lower bound of the identified set under parallel trends minus 20*standard deviation of the point estimate, l_vec'betahat. } + \item{seed}{ + Random seed for internal computations; included for reproducibility. + } } \value{ If returnLength equals TRUE, function returns a scalar that equals the length of the confidence interval. If returnLength equals FALSE, function returns a dataframe with columns diff --git a/man/computeConditionalCS_DeltaSDB.Rd b/man/computeConditionalCS_DeltaSDB.Rd index 234adcc..4708fff 100644 --- a/man/computeConditionalCS_DeltaSDB.Rd +++ b/man/computeConditionalCS_DeltaSDB.Rd @@ -13,7 +13,7 @@ computeConditionalCS_DeltaSDB(betahat, sigma, numPrePeriods, numPostPeriods, alpha = 0.05, hybrid_flag = "FLCI", hybrid_kappa = alpha/10, returnLength = FALSE, biasDirection = "positive", postPeriodMomentsOnly = TRUE, - gridPoints = 10^3, grid.lb = NA, grid.ub = NA) + gridPoints = 10^3, grid.lb = NA, grid.ub = NA, seed = 0) } %- maybe also 'usage' for other objects documented here. \arguments{ @@ -62,6 +62,9 @@ Logical value. If TRUE, function only returns the length of the robust confidenc \item{grid.lb}{ Lower bound of grid for test inversion. The user should only specify this if she wishes to manually specify the upper bound of the grid. Default equals NA sets grid lower bound to equal the lower bound of the identified set under parallel trends minus 20*standard deviation of the point estimate, l_vec'betahat. } + \item{seed}{ + Random seed for internal computations; included for reproducibility. + } } \value{ If returnLength equals TRUE, function returns a scalar that equals the length of the confidence interval. If returnLength equals FALSE, function returns a dataframe with columns diff --git a/man/computeConditionalCS_DeltaSDM.Rd b/man/computeConditionalCS_DeltaSDM.Rd index a07270f..fa81c4d 100644 --- a/man/computeConditionalCS_DeltaSDM.Rd +++ b/man/computeConditionalCS_DeltaSDM.Rd @@ -13,7 +13,7 @@ computeConditionalCS_DeltaSDM(betahat, sigma, numPrePeriods, numPostPeriods, alpha = 0.05, monotonicityDirection = "increasing", hybrid_flag = "FLCI", hybrid_kappa = alpha/10, returnLength = FALSE, postPeriodMomentsOnly = TRUE, - gridPoints = 10^3, grid.lb = NA, grid.ub = NA) + gridPoints = 10^3, grid.lb = NA, grid.ub = NA, seed = 0) } %- maybe also 'usage' for other objects documented here. \arguments{ @@ -62,6 +62,9 @@ Specifies direction of monotonicity restriction. If "increasing", underlying tre \item{grid.lb}{ Lower bound of grid for test inversion. The user should only specify this if she wishes to manually specify the upper bound of the grid. Default equals NA sets grid lower bound to equal the lower bound of the identified set under parallel trends minus 20*standard deviation of the point estimate, l_vec'betahat. } + \item{seed}{ + Random seed for internal computations; included for reproducibility. + } } \value{ If returnLength equals TRUE, function returns a scalar that equals the length of the confidence interval. If returnLength equals FALSE, function returns a dataframe with columns diff --git a/man/computeConditionalCS_DeltaSDRM.Rd b/man/computeConditionalCS_DeltaSDRM.Rd index bd0dcea..83fa4b6 100644 --- a/man/computeConditionalCS_DeltaSDRM.Rd +++ b/man/computeConditionalCS_DeltaSDRM.Rd @@ -12,7 +12,7 @@ computeConditionalCS_DeltaSDRM(betahat, sigma, numPrePeriods, numPostPeriods, l_vec = .basisVector(index = 1, size = numPostPeriods), Mbar = 0, alpha = 0.05, hybrid_flag = "LF", hybrid_kappa = alpha/10, returnLength = FALSE, postPeriodMomentsOnly = TRUE, - gridPoints=10^3, grid.ub = NA, grid.lb = NA) + gridPoints=10^3, grid.ub = NA, grid.lb = NA, seed = 0) } %- maybe also 'usage' for other objects documented here. \arguments{ @@ -58,6 +58,9 @@ Logical value. If \code{TRUE}, function only returns the length of the robust co \item{grid.lb}{ Lower bound of grid for test inversion. The user should only specify this if she wishes to manually specify the upper bound of the grid. Default equals \code{NA} sets grid lower bound to equal the lower bound of the identified set under parallel trends minus 20*standard deviation of the point estimate, l_vec'betahat. } + \item{seed}{ + Random seed for internal computations; included for reproducibility. + } } \details{ For the choice \eqn{\Delta^{SDRM}}, \code{numPrePeriods} must be greater than one. As discussed in Section 2.3.2 of Rambachan & Roth (2021), \eqn{\Delta^{SDRM}} uses observed non-linearities in the pre-treatment difference in trends to bound the possible non-linearities in the post-treatment difference in trends. This is only possible if there are multiple pre-treatment periods (i.e., \code{numPrePeriods} > 1). diff --git a/man/computeConditionalCS_DeltaSDRMB.Rd b/man/computeConditionalCS_DeltaSDRMB.Rd index 3f64a04..fcd9d58 100644 --- a/man/computeConditionalCS_DeltaSDRMB.Rd +++ b/man/computeConditionalCS_DeltaSDRMB.Rd @@ -13,7 +13,7 @@ computeConditionalCS_DeltaSDRMB(betahat, sigma, numPrePeriods, numPostPeriods, Mbar = 0, alpha = 0.05, hybrid_flag = "LF", hybrid_kappa = alpha/10, returnLength = FALSE, postPeriodMomentsOnly = TRUE, biasDirection = "positive", - gridPoints=10^3, grid.ub = NA, grid.lb = NA) + gridPoints=10^3, grid.ub = NA, grid.lb = NA, seed = 0) } %- maybe also 'usage' for other objects documented here. \arguments{ @@ -62,6 +62,9 @@ Logical value. If \code{TRUE}, function only returns the length of the robust co \item{grid.lb}{ Lower bound of grid for test inversion. The user should only specify this if she wishes to manually specify the upper bound of the grid. Default equals \code{NA} sets grid lower bound to equal the lower bound of the identified set under parallel trends minus 20*standard deviation of the point estimate, l_vec'betahat. } + \item{seed}{ + Random seed for internal computations; included for reproducibility. + } } \details{ The choice \eqn{\Delta^{SDRMB}} adds an additional sign restriction to \eqn{\Delta^{SDRM}(Mbar)} that restricts the sign of the bias to be either positive (\eqn{\delta \ge 0}) or negative (\eqn{\delta \le 0}). For this choice \eqn{\Delta^{SDRMB}}, \code{numPrePeriods} must be greater than one. As discussed in Section 2.3.2 of Rambachan & Roth (2021), \eqn{\Delta^{SDRM}} uses observed non-linearities in the pre-treatment difference in trends to bound the possible non-linearities in the post-treatment difference in trends. This is only possible if there are multiple pre-treatment periods (i.e., \code{numPrePeriods} > 1). diff --git a/man/computeConditionalCS_DeltaSDRMM.Rd b/man/computeConditionalCS_DeltaSDRMM.Rd index 8203f9b..7715a5f 100644 --- a/man/computeConditionalCS_DeltaSDRMM.Rd +++ b/man/computeConditionalCS_DeltaSDRMM.Rd @@ -14,7 +14,7 @@ computeConditionalCS_DeltaSDRMM(betahat, sigma, numPrePeriods, numPostPeriods, hybrid_kappa = alpha/10, returnLength = FALSE, postPeriodMomentsOnly = TRUE, monotonicityDirection = "increasing", - gridPoints=10^3, grid.ub = NA, grid.lb = NA) + gridPoints=10^3, grid.ub = NA, grid.lb = NA, seed = 0) } %- maybe also 'usage' for other objects documented here. \arguments{ @@ -63,6 +63,9 @@ Specifies direction of monotonicity restriction. If "increasing", underlying tre \item{grid.lb}{ Lower bound of grid for test inversion. The user should only specify this if she wishes to manually specify the upper bound of the grid. Default equals NA sets grid lower bound to equal the lower bound of the identified set under parallel trends minus 20*standard deviation of the point estimate, l_vec'betahat. } + \item{seed}{ + Random seed for internal computations; included for reproducibility. + } } \details{ The choice \eqn{\Delta^{SDRMM}} adds an additional shape restriction to \eqn{\Delta^{SDRM}(Mbar)} that restricts the underlying trend to be monotone. For this choice \eqn{\Delta^{SDRMM}}, \code{numPrePeriods} must be greater than one. As discussed in Section 2.3.2 of Rambachan & Roth (2021), \eqn{\Delta^{SDRM}} uses observed non-linearities in the pre-treatment difference in trends to bound the possible non-linearities in the post-treatment difference in trends. This is only possible if there are multiple pre-treatment periods (i.e., \code{numPrePeriods} > 1). diff --git a/man/createSensitivityResults.Rd b/man/createSensitivityResults.Rd index 427fc32..508fbb6 100644 --- a/man/createSensitivityResults.Rd +++ b/man/createSensitivityResults.Rd @@ -8,11 +8,16 @@ Constructs robust confidence intervals for a choice \eqn{\Delta = \Delta^{SD}(M)}, \eqn{\Delta^{SDB}(M)} and \eqn{\Delta^{SDM}(M)} for vector of possible M values. By default, the function constructs robust confidence intervals for \eqn{\Delta^{SD}(M)}. } \usage{ -createSensitivityResults(betahat, sigma, numPrePeriods, numPostPeriods, - method = NULL, Mvec = NULL, - l_vec = .basisVector(index = 1, size = numPostPeriods), - monotonicityDirection = NULL, - biasDirection = NULL, alpha = 0.05, parallel = FALSE) +createSensitivityResults(betahat, sigma, + numPrePeriods, numPostPeriods, + method = NULL, + Mvec = NULL, + l_vec = .basisVector(index = 1, size = numPostPeriods), + monotonicityDirection = NULL, + biasDirection = NULL, + alpha = 0.05, + parallel = FALSE, + seed = 0) } %- maybe also 'usage' for other objects documented here. \arguments{ @@ -49,6 +54,9 @@ createSensitivityResults(betahat, sigma, numPrePeriods, numPostPeriods, \item{parallel}{ Logical to indicate whether the user would like to construct the robust confidence intervals in parallel. This uses the Foreach package and doParallel package. Default equals FALSE. } + \item{seed}{ + Random seed for internal computations; included for reproducibility. + } } \value{ Returns a dataframe with columns diff --git a/man/createSensitivityResults_relativeMagnitudes.Rd b/man/createSensitivityResults_relativeMagnitudes.Rd index 238451b..5c314fa 100644 --- a/man/createSensitivityResults_relativeMagnitudes.Rd +++ b/man/createSensitivityResults_relativeMagnitudes.Rd @@ -21,7 +21,8 @@ createSensitivityResults_relativeMagnitudes(betahat, sigma, gridPoints = 10^3, grid.ub = NA, grid.lb = NA, - parallel = FALSE) + parallel = FALSE, + seed = 0) } %- maybe also 'usage' for other objects documented here. \arguments{ @@ -70,6 +71,9 @@ createSensitivityResults_relativeMagnitudes(betahat, sigma, \item{grid.lb}{ Lower bound of grid used for underlying test inversion. Default sets grid.lb to be equal to negative twenty times the standard deviation of the estimated target parameter, l_vec * betahat. User may wish to change the lower bound of the grid to suit their application. } + \item{seed}{ + Random seed for internal computations; included for reproducibility. + } } \details{ Note: If the user specifies bound = "deviation from linear trends", then numPrePeriods must be greater than one. By specifying bound = "deviation from linear trends", then the function selects \eqn{\Delta^{SDRM}} as the base choice of \eqn{\Delta}. As discussed in Section 2.3.2 of Rambachan & Roth (2021), \eqn{\Delta^{SDRM}} uses observed non-linearities in the pre-treatment difference in trends to bound the possible non-linearities in the post-treatment difference in trends. This is only possible if there are multiple pre-treatment periods (i.e., numPrePeriods > 1). diff --git a/man/findOptimalFLCI.Rd b/man/findOptimalFLCI.Rd index a4f6980..dfa2cd2 100644 --- a/man/findOptimalFLCI.Rd +++ b/man/findOptimalFLCI.Rd @@ -11,7 +11,7 @@ Constructs optimal fixed length confidence interval for \eqn{\Delta = \Delta^{SD findOptimalFLCI(betahat, sigma, M = 0, numPrePeriods, numPostPeriods, l_vec = .basisVector(index = 1, size = numPostPeriods), - numPoints = 100, alpha = 0.05) + numPoints = 100, alpha = 0.05, seed = 0) } %- maybe also 'usage' for other objects documented here. \arguments{ @@ -39,6 +39,9 @@ findOptimalFLCI(betahat, sigma, M = 0, \item{alpha}{ Desired size of the FLCI. Default equals 0.05 (corresponding to 95\% confidence interval) } + \item{seed}{ + Random seed for internal computations; included for reproducibility. + } } \value{ Returns a list containing items