wauc | R Documentation |
Calculate the AUC of a logistic regression model considering sampling weights with complex survey data
wauc(
response.var,
phat.var,
weights.var = NULL,
tag.event = NULL,
tag.nonevent = NULL,
data = NULL,
design = NULL
)
response.var |
A character string with the name of the column indicating the response variable in the data set or a vector (either numeric or character string) with information of the response variable for all the units. |
phat.var |
A character string with the name of the column indicating the estimated probabilities in the data set or a numeric vector containing estimated probabilities for all the units. |
weights.var |
A character string indicating the name of the column with sampling weights or
a numeric vector containing information of the sampling weights.
It could be |
tag.event |
A character string indicating the label used to indicate the event of interest in |
tag.nonevent |
A character string indicating the label used for non-event in |
data |
A data frame which, at least, must incorporate information on the columns
|
design |
An object of class |
S
indicate a sample of n
observations of the vector of random variables (Y,\pmb X)
, and \forall i=1,\ldots,n,
y_i
indicate the i^{th}
observation of the response variable Y
,
and \pmb x_i
the observations of the vector covariates \pmb X
. Let w_i
indicate the sampling weight corresponding to the unit i
and \hat p_i
the estimated probability of event.
Let S_0
and S_1
be subsamples of S
, formed by the units without the event of interest (y_i=0
) and with the event of interest (y_i=1
), respectively.
Then, the AUC is estimated as follows:
\widehat{AUC}_w=\dfrac{\sum_{j\in S_0}\sum_{k\in S_1}w_jw_k \{I(\hat p_j < \hat p_k) + 0.5\cdot I(\hat p_j = \hat p_k)\}}{\sum_{j\in S_0}\sum_{k\in S_1}w_jw_k}.
See Iparragirre et al (2023) for more information.
The output object of this function is a list of 4 elements containing the following information:
AUCw
: the weighted estimate of the AUC.
tags
: a list containing two elements with the following information:
tag.event
: a character string indicating the event of interest.
tag.nonevent
: a character string indicating the non-event.
basics
: a list containing information of the following 4 elements:
n.event
: number of units with the event of interest in the data set.
n.nonevent
: number of units without the event of interest in the data set.
hatN.event
: number of units with the event of interest represented in the population by all the event units in the data set, i.e., the sum of the sampling weights of the units with the event of interest in the data set.
hatN.nonevent
: a numeric value indicating the number of non-event units in the population represented by means of the non-event units in the data set, i.e., the sum of the sampling weights of the non-event units in the data set.
call
: an object saving the information about the way in which the function has been run.
Iparragirre, A., Barrio, I. and Arostegui, I. (2023). Estimation of the ROC curve and the area under it with complex survey data. Stat 12(1), e635. (https://doi.org/10.1002/sta4.635)
data(example_data_wroc)
auc.obj <- wauc(response.var = "y",
phat.var = "phat",
weights.var = "weights",
tag.event = 1,
tag.nonevent = 0,
data = example_data_wroc)
# Or equivalently
auc.obj <- wauc(response.var = example_data_wroc$y,
phat.var = example_data_wroc$phat,
weights.var = example_data_wroc$weights,
tag.event = 1, tag.nonevent = 0)
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.