Skip to content

Commit 3f7981d

Browse files
committed
Fix predict() calls in cf_auc and cf_calibration for ml_fitted objects
1 parent 519de0e commit 3f7981d

4 files changed

Lines changed: 20 additions & 6 deletions

File tree

R/cf_auc.R

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -207,7 +207,7 @@ cf_auc <- function(predictions,
207207

208208
# Propensity scores
209209
if (!is.null(propensity_model)) {
210-
ps <- predict(propensity_model, type = "response")
210+
ps <- .predict_nuisance(propensity_model, as.data.frame(covariates), type = "response")
211211
if (treatment_level == 0) {
212212
ps <- 1 - ps
213213
}
@@ -219,7 +219,7 @@ cf_auc <- function(predictions,
219219
if (is.null(full_data)) {
220220
full_data <- cbind(Y = outcomes, as.data.frame(covariates))
221221
}
222-
q_hat <- predict(outcome_model, newdata = full_data, type = "response")
222+
q_hat <- .predict_nuisance(outcome_model, full_data, type = "response")
223223
}
224224

225225
# Indicator for treatment level

R/cf_calibration.R

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -86,7 +86,7 @@ cf_calibration <- function(predictions,
8686

8787
# Get propensity scores
8888
if (estimator == "ipw") {
89-
ps <- predict(propensity_model, type = "response")
89+
ps <- .predict_nuisance(propensity_model, as.data.frame(covariates), type = "response")
9090
if (treatment_level == 0) {
9191
ps <- 1 - ps
9292
}

README.md

Lines changed: 16 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@
1212

1313
- A prediction model will be deployed in settings where treatment policies differ from the training setting
1414
- Predictions are meant to support decisions about treatment initiation
15-
- You need valid performance estimates even when the prediction model is misspecified
15+
- You want to assess model performance after transporting from a source (e.g., RCT) to a target population
1616

1717
Based on Boyer, Dahabreh & Steingrimsson (2025). "Estimating and evaluating counterfactual prediction models." *Statistics in Medicine*, 44(23-24), e70287. [doi:10.1002/sim.70287](https://doi.org/10.1002/sim.70287)
1818

@@ -102,7 +102,7 @@ cf_compare(
102102

103103
## Transportability Analysis
104104

105-
The package also implements transportability estimators from Voter et al. (2025) for evaluating prediction model performance when transporting from a source population (typically an RCT) to a target population:
105+
The package also implements transportability estimators from Steingrimsson et al. (2022) and Voter et al. (2025) for evaluating prediction model performance when transporting from a source population (typically an RCT) to a target population:
106106

107107
```r
108108
# Load transportability example data
@@ -189,6 +189,8 @@ Boyer CB, Dahabreh IJ, Steingrimsson JA. Estimating and evaluating counterfactua
189189

190190
For transportability methods, also cite:
191191

192+
Steingrimsson JA, Gatsonis C, Li B, Dahabreh IJ. Transporting a Prediction Model for Use in a New Target Population. *American Journal of Epidemiology*. 2022; 192(2):296-304. doi:[10.1093/aje/kwac128](https://doi.org/10.1093/aje/kwac128)
193+
192194
Voter SR, et al. Transportability of machine learning-based counterfactual prediction models with application to CASS. *Diagnostic and Prognostic Research*. 2025; 9(4). doi:[10.1186/s41512-025-00201-y](https://doi.org/10.1186/s41512-025-00201-y)
193195

194196
```bibtex
@@ -203,9 +205,20 @@ Voter SR, et al. Transportability of machine learning-based counterfactual predi
203205
doi={10.1002/sim.70287}
204206
}
205207
208+
@article{10.1093/aje/kwac128,
209+
title = {Transporting a Prediction Model for Use in a New Target Population},
210+
author = {Steingrimsson, Jon A. and Gatsonis, Constantine and Li, Bing and Dahabreh, Issa J.},
211+
journal = {American Journal of Epidemiology},
212+
volume = {192},
213+
number = {2},
214+
pages = {296-304},
215+
year = {2022},
216+
doi = {10.1093/aje/kwac128}
217+
}
218+
206219
@article{voter2025transportability,
207220
title={Transportability of machine learning-based counterfactual prediction models with application to CASS},
208-
author={Voter, Sarah R. and others},
221+
author = {Voter, Sarah C. and Dahabreh, Issa J. and Boyer, Christopher B. and Rahbar, Habib and Kontos, Despina and Steingrimsson, Jon A.},
209222
journal={Diagnostic and Prognostic Research},
210223
volume={9},
211224
number={4},

vignettes/introduction.Rmd

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -55,6 +55,7 @@ head(cvd_sim)
5555
```
5656

5757
The `cvd_sim` dataset contains simulated cardiovascular data with:
58+
5859
- `age`, `bp`, `chol`: Patient covariates
5960
- `treatment`: Binary treatment indicator (confounded by covariates)
6061
- `event`: Binary outcome (cardiovascular event)

0 commit comments

Comments
 (0)