Skip to content

Commit

Permalink
fix the bug for RIR verification
Browse files Browse the repository at this point in the history
  • Loading branch information
qinyun-lin committed May 15, 2024
1 parent c36d44f commit 9cd4330
Showing 1 changed file with 15 additions and 5 deletions.
20 changes: 15 additions & 5 deletions R/test_sensitivity.R
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,15 @@ test_sensitivity <- function(est_eff,
warning("Cannot test statistical significance from nu and evaluate relative to a specific threshold. Using the specified threshold for calculations and ignoring nu.")
}

if (!is.na(eff_thr) & index == "RIR") {
warning("Interpreting the metric of the threshold in the metric of the estimated effect because you specified RIR.")
}

if (!is.na(eff_thr) & index == "IT") {
warning("Interpreting the effect threshold as a correlation because you specified ITCV. Future work will allow for thresholds in raw metric.")
}


## error message if input is inappropriate
if (!(std_err > 0)) {stop("Did not run! Standard error needs to be greater than zero.")}
if (!(n_obs > n_covariates + 3)) {stop("Did not run! There are too few observations relative to the number of observations and covariates. Please specify a less complex model to use KonFound-It.")}
Expand Down Expand Up @@ -116,7 +125,12 @@ test_sensitivity <- function(est_eff,
}

## verify results
beta_threshold_verify = perc_to_change / 100 * 0 + (1 - perc_to_change / 100) * est_eff
if (abs(est_eff) > abs(beta_threshold)) {
beta_threshold_verify = perc_to_change / 100 * 0 + (1 - perc_to_change / 100) * est_eff
}
if (abs(est_eff) < abs(beta_threshold)) {
beta_threshold_verify = est_eff / (1 - perc_to_change / 100)
}
## compare beta_threshold_verify with beta_threshold

## later when we introduce non-zero replacement
Expand Down Expand Up @@ -156,10 +170,6 @@ test_sensitivity <- function(est_eff,
}
}

if (!is.na(eff_thr) & index == "IT") {
warning("Interpreting the effect threshold as a correlation because you specified ITCV. Future work will allow for thresholds in raw metric.")
}

if (!is.na(eff_thr)) {
critical_r <- eff_thr
}
Expand Down

0 comments on commit 9cd4330

Please sign in to comment.