| ci_wauc | R Documentation |
A function to estimate a confidence interval (CI) for wAUC implemented by wROC::wauc() with replicate weights by survey::as.svrepdesign(); bootstrap is Canty and Davison's bootstrap,
subbootstrap is Rao and Wu's (n-1) bootstrap, and JK1 and JKn are jackknife methods.
ci_wauc(
y,
yhat,
tag.event = "1",
tag.nonevent = "0",
weights = NULL,
cluster = NULL,
strata = NULL,
design = NULL,
data = NULL,
type = c("JK1", "JKn", "bootstrap", "subbootstrap"),
B = 2000,
conf.level = 0.95,
fpc = NULL,
fpctype = NULL,
...,
compress = TRUE,
mse = getOption("survey.replicates.mse")
)
y |
A vector of response variable or a string of its name (requires |
yhat |
A vector of predicted probabilities of |
tag.event |
A character of the event of interest in |
tag.nonevent |
A character of the non-event in |
weights |
A character string of a sampling weights' identifier. |
cluster |
A character string of a cluster identifier. It could be |
strata |
A character string of a strata identifier. It could be |
design |
An object of class |
data |
A data frame including vectors of |
type |
Type of replicate weights. Choose one of |
B |
The number of bootstrap replicates. Default is 2000. |
conf.level |
The width of confidence interval. Default is 0.95. |
fpc, fpctype |
Passed to |
... |
optional parameters to be passed to the low level function |
compress |
Use a compressed representation of the replicate weights matrix. |
mse |
if TRUE, compute variances from sums of squares around the point estimate, rather than the mean of the replicates. |
confidence interval (CI) estimates
svyROC::wauc() for detailed information on the implementation.
survey::as.svrepdesign() for detailed information on replicate weights methods.
data(nhanes2013_sbc)
# For ad hoc adjustment for a single PSU stratum not to contribute to the variance
options(survey.lonely.psu='remove')
# yhat would typically come from a fitted model (e.g. wElnet(), wXGBoost(),
# wRandomforest(), or any other classifier). Here we generate one directly
# from a simple weighted logistic regression for a self-contained example.
fit <- glm(HBP ~ INDFMPIR + BMXBMI + BMXARML + BMXLEG + BPXPLS,
data = nhanes2013_sbc,
family = binomial(), weights = nhanes2013_sbc$WTSAF2YR)
yhat <- predict(fit, type = "response")
# Conveniently, update a dataset including yhat (a vector) estimated
# from any machine learning methods. HBP, SDMVPSU, SDMVSTRA, and WTSAF2YR
# are referenced by name (not position) to avoid any risk of selecting
# the wrong columns.
data1 <- data.frame(
nhanes2013_sbc[, c("HBP", "SDMVPSU", "SDMVSTRA", "WTSAF2YR")],
yhat
)
# For estimating bootstrap 95\% CI for a model selected by dCV
wAUC.ci<- ci_wauc("HBP", "yhat",weights="WTSAF2YR",cluster="SDMVPSU",strata="SDMVSTRA",
data=data1,type="subbootstrap",B=2000)
#Or equivalently,
des <- survey::svydesign(ids=~SDMVPSU, strata = ~SDMVSTRA, weights = ~WTSAF2YR,
nest = TRUE, data = nhanes2013_sbc)
wAUC.ci<- ci_wauc(des$variables$HBP,data1$yhat,design = des,type = "subbootstrap",B=2000)
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.