Skip to content

Commit 9648cb0

Browse files
committed
Expose influence function SE for tr_sensitivity/tr_specificity/tr_fpr
- Add 'influence' to se_method options for tr_sens_spec functions - Influence function SE requires cross_fit = TRUE (validated with error) - The implementation was already complete but not accessible in API
1 parent a69036d commit 9648cb0

File tree

1 file changed

+15
-3
lines changed

1 file changed

+15
-3
lines changed

R/tr_sens_spec.R

Lines changed: 15 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -102,7 +102,7 @@ tr_sensitivity <- function(predictions,
102102
selection_model = NULL,
103103
propensity_model = NULL,
104104
outcome_model = NULL,
105-
se_method = c("none", "bootstrap"),
105+
se_method = c("none", "bootstrap", "influence"),
106106
n_boot = 200,
107107
conf_level = 0.95,
108108
stratified_boot = TRUE,
@@ -118,6 +118,11 @@ tr_sensitivity <- function(predictions,
118118
estimator <- match.arg(estimator)
119119
se_method <- match.arg(se_method)
120120

121+
# Influence function SE requires cross-fitting
122+
if (se_method == "influence" && !cross_fit) {
123+
stop("Influence function standard errors require cross_fit = TRUE")
124+
}
125+
121126
# Parse propensity score trimming specification
122127
ps_trim_spec <- .parse_ps_trim(ps_trim)
123128

@@ -408,7 +413,7 @@ tr_specificity <- function(predictions,
408413
selection_model = NULL,
409414
propensity_model = NULL,
410415
outcome_model = NULL,
411-
se_method = c("none", "bootstrap"),
416+
se_method = c("none", "bootstrap", "influence"),
412417
n_boot = 200,
413418
conf_level = 0.95,
414419
stratified_boot = TRUE,
@@ -424,6 +429,11 @@ tr_specificity <- function(predictions,
424429
estimator <- match.arg(estimator)
425430
se_method <- match.arg(se_method)
426431

432+
# Influence function SE requires cross-fitting
433+
if (se_method == "influence" && !cross_fit) {
434+
stop("Influence function standard errors require cross_fit = TRUE")
435+
}
436+
427437
# Parse ps_trim specification
428438
ps_trim_spec <- .parse_ps_trim(ps_trim)
429439

@@ -695,10 +705,12 @@ tr_fpr <- function(predictions,
695705
selection_model = NULL,
696706
propensity_model = NULL,
697707
outcome_model = NULL,
698-
se_method = c("none", "bootstrap"),
708+
se_method = c("none", "bootstrap", "influence"),
699709
n_boot = 200,
700710
conf_level = 0.95,
701711
stratified_boot = TRUE,
712+
cross_fit = FALSE,
713+
n_folds = 5,
702714
ps_trim = NULL,
703715
parallel = FALSE,
704716
ncores = NULL,

0 commit comments

Comments
 (0)