| Title: | Empirical Likelihood Inference for Diagnostic Test Accuracy |
|---|---|
| Description: | Estimates diagnostic accuracy for continuous markers in two or three independent ordered groups. Provides empirical receiver operating characteristic (ROC) curves and surfaces, empirical likelihood inference for the area under the curve and the volume under the surface, and kernel-based selection of diagnostic thresholds. Three-class empirical likelihood methods are described in To, Adimari, and Chiogna (2024) <doi:10.1177/09622802241238998>. |
| Authors: | Duc-Khanh To [aut, cre] (ORCID: <https://orcid.org/0000-0002-4641-0764>), Gianfranco Adimari [ctb], Monica Chiogna [ctb] |
| Maintainer: | Duc-Khanh To <[email protected]> |
| License: | GPL (>= 2) |
| Version: | 0.1.0 |
| Built: | 2026-11-24 02:46:39 UTC |
| Source: | https://github.com/cran/emplikDTA |
Estimation and empirical likelihood inference for continuous markers in two or three independent ordered diagnostic groups.
Use auc and ROC_emp_curve for two groups;
vus, tcf2 and ROC_emp_surface for
three groups. threshold2 and threshold3 select
thresholds using kernel CDFs. Formula interfaces use marker ~ group.
Larger marker values indicate higher diagnostic classes. Set diag_levels
explicitly when the factor order is not the intended diagnostic order.
These interfaces do not accept cluster identifiers or covariate models.
Maintainer: Duc-Khanh To [email protected] (ORCID)
Authors:
Duc-Khanh To [email protected] (ORCID)
Other contributors:
Gianfranco Adimari [contributor]
Monica Chiogna [contributor]
Useful links:
Report bugs at https://github.com/toduckhanh/emplikDTA/issues
A subset of the longitudinal cohort from the Washington University (WU) Alzheimer's Disease Research Center (ADRC). The dataset contains measurements of 14 neuropsychological markers collected from 118 independent individuals aged 75 years. Individuals were classified into three diagnostic groups according to the published Clinical Dementia Rating (CDR).
A data frame with 118 observations on 15 variables:
groupA factor with levels , , and
. The group has CDR = 0 (no dementia),
the group has CDR = 0.5 (very mild dementia),
and the group has CDR = 1 (Alzheimer's disease).
FACTOR1Global factor score.
ktempTemporal factor score.
kparParietal factor score.
kfrontFrontal factor score.
zpsy004Logical memory score.
zpsy005Digit span forward score.
zpsy006Digit span backward score.
zinfoInformation score.
zbentcVisual retention (10 seconds) score.
zbentdVisual retention (copy) score.
zbostonBoston Naming Test score.
zmentconMental control score.
zworfluWord fluency score.
zasscAssociate learning score.
See the references for detailed descriptions of the 14 neuropsychological markers and their scoring procedures.
The dataset is reproduced from the DiagTest3Grp package (version 1.6).
Originally published in:
Xiong, C., van Belle, G., Miller, J. P., & Morris, J. C. (2006). Measuring and Estimating Diagnostic Accuracy When There Are Three Ordinal Diagnostic Groups. Statistics in Medicine, 25(7), 1251-1273.
Sorandt, M., & Hill, R. D. (1989). Very Mild Senile Dementia of the Alzheimer Type. II. Psychometric Test Performance. Archives of Neurology, 46, 383-386.
data(ADNeuro) str(ADNeuro) summary(ADNeuro)data(ADNeuro) str(ADNeuro) summary(ADNeuro)
Serum IgG titers against the receptor-binding domain (RBD) of SARS-CoV-2 in 100 healthcare workers. Samples were collected approximately two weeks after the second dose of the Pfizer–BioNTech BNT162b2 mRNA vaccine.
data(antib2)data(antib2)
A data frame named data_antib2 with 100 rows and two columns.
antib2Numeric RBD-specific IgG titer in arbitrary units per milliliter (AU/mL).
statusNumeric indicator of prior SARS-CoV-2 infection.
0 denotes infection-negative (58 workers) and 1 denotes
infection-positive (42 workers).
COVID-19 antibody data from the Supporting Information of Bantis et al. (2024).
Bantis, L. E., Brewer, B., Nakas, C. T., and Reiser, B. (2024). Statistical Inference for Box–Cox based Receiver Operating Characteristic Curves. Statistics in Medicine, 43(30), 6099–6122. doi:10.1002/sim.10252.
data(antib2) summary(data_antib2$antib2) table(data_antib2$status)data(antib2) summary(data_antib2$antib2) table(data_antib2$status)
This function estimates the AUC of a continuous diagnostic test (biomarker) in two-class setting, together with a confidence interval.
auc(x, ...) ## Default S3 method: auc( x, y, auc0 = 1/2, ci_level = 0.95, B = 500, seed, plot = FALSE, alternative = c("greater", "less", "two.sided"), ... ) ## S3 method for class 'formula' auc(formula, data, diag_levels = NULL, subset, na.action, ...) ## S3 method for class 'auc' print(x, ...) ## S3 method for class 'auc' summary(object, ...)auc(x, ...) ## Default S3 method: auc( x, y, auc0 = 1/2, ci_level = 0.95, B = 500, seed, plot = FALSE, alternative = c("greater", "less", "two.sided"), ... ) ## S3 method for class 'formula' auc(formula, data, diag_levels = NULL, subset, na.action, ...) ## S3 method for class 'auc' print(x, ...) ## S3 method for class 'auc' summary(object, ...)
x, y
|
numeric vectors (default method) contains values of diagnostic test (biomarker) corresponding to the first and second class of disease. The ordering is intended to be “increasing” with respect to the disease severity. |
... |
for formula method: additional arguments to be passed to the |
auc0 |
the null-hypothesis value of the AUC, defaulting to |
ci_level |
a confidence level to be used for constructing the confidence interval; default is 0.95. |
B |
the number of bootstrap replicates (default: 500). |
seed |
Integer passed to |
plot |
a logical indicating whether you want to plot empirical likelihood ratio and confidence interval for AUC. |
alternative |
The alternative hypothesis. Use |
formula |
an object of class " |
data |
a data frame containing the variables in the formula. |
diag_levels |
a vector (of strings) containing the ordered name chosen for
the disease classes. The ordering is intended to be “increasing” with respect to the
disease severity. If |
subset |
an optional expression indicating the subset of the rows of data that should be used in the fit. This can be a logical vector, or a numeric vector indicating which observation numbers are to be included, or a character vector of the row names to be included. All observations are included by default. |
na.action |
a function which indicates what should happen when the data contain |
object |
An object of class |
Supply independent samples ordered by increasing marker values,
with missing values handled before calling the default method. The formula
interface uses marker ~ group with exactly two groups.
The empirical estimate accounts for ties. Bootstrap resampling is performed
independently within groups. The likelihood statistic is scaled by
qchisq(0.5, 1) / median(r.bts), and the confidence limits are found
by inversion using a chi-squared cutoff with one degree of freedom.
If the empirical estimate is zero or one, the function returns early without
inference; an estimate of one is adjusted to 1 / (1 + 0.5 / n1 / n2).
An unbracketed confidence limit is returned as NA.
auc returns an object of class "auc" which is a list
containing the following components:
call |
the matched call. |
estimate |
the estimated AUC. |
n |
Named vector of group sizes, |
alternative |
the alternative hypothesis used for the test. |
For interior estimates, the list also contains:
conf.int |
a two-sided confidence interval for the AUC. |
p.value |
the p-value for testing AUC equal to |
ll.value |
Unadjusted empirical likelihood statistic at |
r.bts |
Bootstrap empirical likelihood statistics. |
r.adj |
the value of bootstrap adjustment factor. |
ci_level |
confidence level of the interval. |
Inference components are absent for boundary estimates. The formula method additionally returns:
formula |
The supplied formula. |
Group-label metadata are currently not retained. The print method
displays the results and returns the object invisibly.
Let be the AUC,
its empirical estimate, and the null value
(auc0). For total sample size , the empirical likelihood (EL)
statistic at the null is returned as ll.value and equals
The test uses the signed root of the bootstrap-adjusted EL statistic
where is the bootstrap scale factor returned as r.adj.
The function sets at equality and truncates negative
values of caused by rounding to zero before taking the
square root.
Under , the test uses
the standard normal approximation for the signed root (DiCiccio and
Romano, 1989). With denoting the standard normal
cumulative distribution function, p.value is computed as follows.
alternative = "greater"
for .
alternative = "less"
for .
alternative = "two.sided"
for . This equals the upper
tail probability of a chi-squared distribution with one degree of
freedom evaluated at .
DiCiccio, T. J., & Romano, J. P. (1989). On adjustments based on the signed root of the empirical likelihood ratio statistic. Biometrika, 76(3), 447–456. doi:10.1093/biomet/76.3.447.
To, D. K., Adimari, G., & Chiogna, M. (2024). Interval estimation in three-class receiver operating characteristic analysis: A fairly general approach based on the empirical likelihood. Statistical Methods in Medical Research, 33, 5, 875-893.
set.seed(123) x <- rnorm(60) y <- rnorm(60, 1) fit <- auc(x, y, B = 100, seed = 34) summary(fit)set.seed(123) x <- rnorm(60) y <- rnorm(60, 1) fit <- auc(x, y, B = 100, seed = 34) summary(fit)
Add a fixed-threshold empirical likelihood confidence region and empirical operating point to an existing ROC surface scene.
CR_tcfs(x, ...) ## S3 method for class 'ROC_emp_surface' CR_tcfs( x, cpts = NULL, ci_level = 0.95, color1 = "red", color2 = "blue", smooth = 0, alpha = 0.5, fill = FALSE, ... )CR_tcfs(x, ...) ## S3 method for class 'ROC_emp_surface' CR_tcfs( x, cpts = NULL, ci_level = 0.95, color1 = "red", color2 = "blue", smooth = 0, alpha = 0.5, fill = FALSE, ... )
x |
An object of class |
... |
Arguments forwarded to the method. |
cpts |
Numeric pair of ordered thresholds; must be supplied. |
ci_level |
Confidence level in (0, 1). |
color1 |
Colour of the empirical point. |
color2 |
Colour requested for the confidence boundary. |
smooth |
Smoothing argument passed to |
alpha |
Opacity of the confidence region. |
fill |
Whether to fill the contour surface. |
The region uses a chi-squared cutoff with three degrees of freedom on a 51-by-51-by-51 grid. Axes are TCF1, TCF3, TCF2.
The input object, invisibly, if plotting succeeds.
Low-level calculation of a two-sample minus twice log empirical likelihood ratio at a fixed threshold.
empi_llike_proj( X1, X2, n1, n2, tcf1, tcf2, tau, type_F = c("empi", "Adi", "Adi_ties") )empi_llike_proj( X1, X2, n1, n2, tcf1, tcf2, tau, type_F = c("empi", "Adi", "Adi_ties") )
X1, X2
|
Numeric observations from two independent ordered groups. |
n1, n2
|
Sample sizes associated with X1 and X2. |
tcf1, tcf2
|
Proposed probabilities P(X1 <= tau) and P(X2 > tau). Use interior probabilities for finite calculations. |
tau |
Single threshold in the overlap of the observed group ranges. |
type_F |
CDF estimator: "empi" uses empirical proportions; "Adi_ties" uses the interpolated tie-aware CDF. "Adi" requires an Fs helper that is not currently defined in the package and is unsupported. |
This helper does not validate sample sizes or handle zero log terms by limits. Boundary probabilities can produce NaN. Prefer the high-level inference functions for ordinary analyses.
Numeric likelihood statistic, Inf outside overlapping ranges, or NaN for undefined boundary arithmetic.
empi_llike_proj(1:5, 2:6, 5, 5, tcf1 = 0.5, tcf2 = 0.5, tau = 3)empi_llike_proj(1:5, 2:6, 5, 5, tcf1 = 0.5, tcf2 = 0.5, tau = 3)
Add a Confidence Region to an Empirical ROC Curve
Functions for adding graphical layers to an empirical ROC curve produced by
plot.ROC_emp_curve. These functions return standard
ggplot2 layers and
are intended to be combined with the output of 'plot()' using the '+' operator.
geom_confidence_region adds the confidence region for the pair of
specificity and sensitivity corresponding to a specified cut-point.
geom_operating_point() adds the empirical operating point
(false positive rate, true positive rate) corresponding to a specified
cut-point.
geom_confidence_region( object, cpt_type = c("fixed", "optimal"), cpt = NULL, ci_level = 0.95, colour = "blue", linewidth = 0.8 ) geom_operating_point( object, cpt_type = c("fixed", "optimal"), cpt = NULL, colour = "red", size = 2.5 )geom_confidence_region( object, cpt_type = c("fixed", "optimal"), cpt = NULL, ci_level = 0.95, colour = "blue", linewidth = 0.8 ) geom_operating_point( object, cpt_type = c("fixed", "optimal"), cpt = NULL, colour = "red", size = 2.5 )
object |
A ROC_emp_curve object for fixed thresholds, or a threshold2 object fitted with ci = TRUE for optimal thresholds. |
cpt_type |
Use a fixed threshold or a fitted optimal threshold. |
cpt |
a numeric value specifying the cut-point at which the operating point and confidence region are computed. |
ci_level |
the confidence level of the confidence region. |
colour |
a character string specifying the colour of the graphical element. |
linewidth |
a numeric value specifying the line width of the confidence region boundary. |
size |
a numeric value specifying the point size. |
Both branches currently use a chi-squared cutoff with two degrees
of freedom. For the bootstrap-calibrated optimal-threshold region, use
plot on the threshold2 fit. The cpt argument is ignored for optimal
thresholds.
geom_confidence_region() returns a ggplot2::geom_contour() layer.
geom_operating_point() returns a ggplot2::geom_point() layer.
ROC_emp_curve and plot.ROC_emp_curve
Plot a point estimate and, when available, the boundary of the joint empirical likelihood (EL) confidence region. Plotting uses the stored results and does not repeat estimation or bootstrap sampling.
## S3 method for class 'threshold2' plot( x, ci = NULL, point = c("auto", "empirical", "kernel"), point_colour = "black", point_size = 1.5, ci_colour = "blue", ci_linewidth = 0.8, xlab = "Specificity", ylab = "Sensitivity", ... ) ## S3 method for class 'threshold2_all' plot( x, method = c("all", "YI", "CtP", "MA"), ci = NULL, point = c("auto", "empirical", "kernel"), point_colour = "black", point_size = 1.5, ci_colour = "blue", ci_linewidth = 0.8, xlab = "Specificity", ylab = "Sensitivity", ... )## S3 method for class 'threshold2' plot( x, ci = NULL, point = c("auto", "empirical", "kernel"), point_colour = "black", point_size = 1.5, ci_colour = "blue", ci_linewidth = 0.8, xlab = "Specificity", ylab = "Sensitivity", ... ) ## S3 method for class 'threshold2_all' plot( x, method = c("all", "YI", "CtP", "MA"), ci = NULL, point = c("auto", "empirical", "kernel"), point_colour = "black", point_size = 1.5, ci_colour = "blue", ci_linewidth = 0.8, xlab = "Specificity", ylab = "Sensitivity", ... )
x |
An object of class |
ci |
Logical; whether to draw the EL confidence boundary. If
|
point |
Which point estimate to display. |
point_colour |
Colour of the point estimate. |
point_size |
Size of the point estimate. |
ci_colour |
Colour of the EL confidence boundary. |
ci_linewidth |
Line width of the EL confidence boundary. |
xlab, ylab
|
Axis labels. |
... |
Reserved for additional arguments. |
method |
For the all-methods plot, |
The contour at x$c_alp is the boundary of a joint
confidence region for specificity and sensitivity, rather than two
separate marginal confidence intervals. Changing point changes
only the displayed point; the stored EL region remains the same.
A ggplot object that can be printed or further customised.
Print a comparison of the three threshold-selection methods
## S3 method for class 'threshold2_all' print(x, ...)## S3 method for class 'threshold2_all' print(x, ...)
x |
An object of class |
... |
Additional arguments passed to |
The input object, invisibly.
This function estimates the ROC curve of a continuous diagnostic test (biomarker) in two-class setting.
ROC_emp_curve(x, ...) ## Default S3 method: ROC_emp_curve(x, y, ncp = 150, main, color = "steelblue", plot = TRUE, ...) ## S3 method for class 'formula' ROC_emp_curve(formula, data, diag_levels = NULL, subset, na.action, ...) ## S3 method for class 'ROC_emp_curve' plot(x, color = "steelblue", linewidth = 1, ...)ROC_emp_curve(x, ...) ## Default S3 method: ROC_emp_curve(x, y, ncp = 150, main, color = "steelblue", plot = TRUE, ...) ## S3 method for class 'formula' ROC_emp_curve(formula, data, diag_levels = NULL, subset, na.action, ...) ## S3 method for class 'ROC_emp_curve' plot(x, color = "steelblue", linewidth = 1, ...)
x, y
|
numeric vectors (default method) contains values of diagnostic test (biomarker) corresponding to the first and second class of disease. The ordering is intended to be “increasing” with respect to the disease severity. |
... |
for formula method: additional arguments to be passed to the
|
ncp |
an integer specifying the number of cut-points used to construct the empirical ROC curve. Larger values produce a smoother approximation at the expense of additional computation. |
main |
a character string giving the title of the plot. |
color |
a character string specifying the color of the ROC curve. |
plot |
a logical indicating whether the empirical ROC curve should be plotted. If 'FALSE', the computed ROC curve object is returned without producing a graphical display. |
formula |
an object of class " |
data |
a data frame containing the variables in the formula. |
diag_levels |
a vector (of strings) containing the ordered name chosen for
the disease classes. The ordering is intended to be “increasing” with respect to the
disease severity. If |
subset |
an optional expression indicating the subset of the rows of data that should be used in the fit. This can be a logical vector, or a numeric vector indicating which observation numbers are to be included, or a character vector of the row names to be included. All observations are included by default. |
na.action |
a function which indicates what should happen when the data contain |
linewidth |
Line width for the curve plot. |
Specificity is and sensitivity is .
The plot uses false positive rate (1 - specificity) on the horizontal axis.
Use geom_confidence_region for a fixed-threshold EL region.
The grid contains minus and plus infinity and ncp - 2 equally spaced
points over the pooled range. The formula is marker ~ group.
The default methods return the fitted object invisibly.
ROC_emp_curve returns an object of class "ROC_emp_curve" which
is a list containing at least the following components:
call |
the matched call. |
n, ncp
|
Group sizes and number of grid thresholds. |
x, y
|
Original group samples. |
vals |
Matrix with columns Spe (specificity) and Sen (sensitivity). |
cutpoints |
Vector of thresholds. |
Generic functions such as plot is also used to make a plot of ROC curve
with ggplot2 style.
The plot method returns a ggplot object.
To, D. K., Adimari, G., & Chiogna, M. (2024). Interval estimation in three-class receiver operating characteristic analysis: A fairly general approach based on the empirical likelihood. Statistical Methods in Medical Research, 33, 5, 875-893.
set.seed(123) x <- rnorm(40, 0, 1) y <- rnorm(40, 1, 1) fit <- ROC_emp_curve(x, y, ncp = 30, plot = FALSE) head(fit$vals) plot(fit) + geom_operating_point(fit, cpt = 0.5)set.seed(123) x <- rnorm(40, 0, 1) y <- rnorm(40, 1, 1) fit <- ROC_emp_curve(x, y, ncp = 30, plot = FALSE) head(fit$vals) plot(fit) + geom_operating_point(fit, cpt = 0.5)
This function estimates the ROC surface of a continuous diagnostic test (biomarker) in three-class setting.
ROC_emp_surface(x, ...) ## Default S3 method: ROC_emp_surface( x, y, z, ncp = 150, main, color = "steelblue", alpha = 0.5, plot = TRUE, ... ) ## S3 method for class 'formula' ROC_emp_surface(formula, data, diag_levels = NULL, subset, na.action, ...) ## S3 method for class 'ROC_emp_surface' plot( x, main = "Empirical ROC surface", color = "steelblue", alpha = 0.5, new_window = TRUE, add = FALSE, ... ) ## S3 method for class 'ROC_emp_surface' print(x, ...)ROC_emp_surface(x, ...) ## Default S3 method: ROC_emp_surface( x, y, z, ncp = 150, main, color = "steelblue", alpha = 0.5, plot = TRUE, ... ) ## S3 method for class 'formula' ROC_emp_surface(formula, data, diag_levels = NULL, subset, na.action, ...) ## S3 method for class 'ROC_emp_surface' plot( x, main = "Empirical ROC surface", color = "steelblue", alpha = 0.5, new_window = TRUE, add = FALSE, ... ) ## S3 method for class 'ROC_emp_surface' print(x, ...)
x, y, z
|
numeric vectors (default method) contains values of diagnostic tests (biomarkers) corresponding to the first, second and third class of disease. The ordering is intended to be “increasing” with respect to the disease severity. |
... |
for formula method: additional arguments to be passed to the
|
ncp |
an integer specifying the number of cut-points used to construct the empirical ROC surface. Larger values produce a smoother approximation at the expense of additional computation. |
main |
Requested plot title; currently accepted but not drawn. |
color |
a character string specifying the color of the ROC surface. |
alpha |
vector of alpha values between 0.0 (fully transparent) and 1.0 (opaque). |
plot |
a logical indicating whether the empirical ROC surface should be plotted. If 'FALSE', the computed ROC surface object is returned without producing a graphical display. |
formula |
an object of class " |
data |
a data frame containing the variables in the formula. |
diag_levels |
a vector (of strings) containing the ordered name chosen for
the disease classes. The ordering is intended to be “increasing” with respect to the
disease severity. If |
subset |
an optional expression indicating the subset of the rows of data that should be used in the fit. This can be a logical vector, or a numeric vector indicating which observation numbers are to be included, or a character vector of the row names to be included. All observations are included by default. |
na.action |
a function which indicates what should happen when the data contain |
new_window |
Open a new rgl window when not adding to a scene. |
add |
Add the surface to the current scene. |
For ordered thresholds and , ,
, and .
The plot axes are , and . Plotting uses an rgl device.
The grid contains minus and plus infinity and ncp - 2 equally spaced
points over the pooled range. The formula is marker ~ group.
The default methods return the fitted object invisibly.
ROC_emp_surface returns an object of class "ROC_emp_surface" which
is a list containing at least the following components:
call |
the matched call. |
n, ncp
|
Group sizes and number of grid thresholds. |
x, y, z
|
Original group samples. |
vals |
Matrix with columns TCF1, TCF2 and TCF3. |
cpoint |
Matrix of threshold pairs. |
cutpoints |
Vector of grid thresholds. |
tcf1, tcf2, tcf3
|
Matrices used to draw the surface. |
Generic functions such as plot is also used to make a 3D plot of ROC surface
with rgl style.
Plot and print methods return the input invisibly.
To, D. K., Adimari, G., & Chiogna, M. (2024). Interval estimation in three-class receiver operating characteristic analysis: A fairly general approach based on the empirical likelihood. Statistical Methods in Medical Research, 33, 5, 875-893.
set.seed(123) x <- rnorm(40, 0, 1) y <- rnorm(40, 1, 1) z <- rnorm(40, 2, 1) fit <- ROC_emp_surface(x, y, z, ncp = 15, plot = FALSE) head(fit$vals) print(fit)set.seed(123) x <- rnorm(40, 0, 1) y <- rnorm(40, 1, 1) z <- rnorm(40, 2, 1) fit <- ROC_emp_surface(x, y, z, ncp = 15, plot = FALSE) head(fit$vals) print(fit)
Estimate TCF2 at specified TCF1 and TCF3 using sample quantiles, with bootstrap-calibrated empirical likelihood inference.
tcf2(x, ...) ## Default S3 method: tcf2( x, y, z, tcf10, tcf30, tcf20 = NULL, ci_level = 0.95, B = 500, seed, plot = FALSE, ... ) ## S3 method for class 'formula' tcf2( formula, data, diag_levels = NULL, subset, na.action, tcf10, tcf30, tcf20 = NULL, ... ) ## S3 method for class 'tcf2' print(x, digits = max(3L, getOption("digits") - 3L), ...) ## S3 method for class 'tcf2' summary(object, ...)tcf2(x, ...) ## Default S3 method: tcf2( x, y, z, tcf10, tcf30, tcf20 = NULL, ci_level = 0.95, B = 500, seed, plot = FALSE, ... ) ## S3 method for class 'formula' tcf2( formula, data, diag_levels = NULL, subset, na.action, tcf10, tcf30, tcf20 = NULL, ... ) ## S3 method for class 'tcf2' print(x, digits = max(3L, getOption("digits") - 3L), ...) ## S3 method for class 'tcf2' summary(object, ...)
x, y, z
|
Numeric vectors for three independent groups, in increasing
marker order. Supply finite observations with missing values already handled.
For the generic, |
... |
Arguments forwarded to the default method; unused by print/summary. |
tcf10, tcf30
|
Target first- and third-class fractions in (0, 1). |
tcf20 |
Optional null-hypothesis value for TCF2; NULL skips the test. |
ci_level |
Confidence level in (0, 1). |
B |
Positive integer number of bootstrap replicates. |
seed |
Integer passed to |
plot |
Whether to print the likelihood-ratio plot. |
formula |
Formula |
data |
Data frame containing the formula variables. |
diag_levels |
Three group labels in increasing disease order. If NULL, the factor levels are used; sample means do not reorder the groups. |
subset |
Optional rows selected through |
na.action |
Missing-value action passed to |
digits |
Retained by the print method; currently not used. |
object |
An object of class |
The lower threshold is quantile(x, tcf10, type = 8) and the
upper threshold is quantile(z, 1 - tcf30, type = 8). TCF2 is the
empirical CDF difference in group two. Choose targets giving an ordered pair
of thresholds; the default method does not check this condition.
Bootstrap samples are augmented by each original group's range. Confidence
limits invert the adjusted statistic using a chi-squared cutoff with one
degree of freedom. An unbracketed limit is NA.
tcf2 returns an object of class "tcf2" which is a list
containing the following components:
call |
The matched call. |
estimate |
The estimated middle-class true class fraction. |
tau_est |
Vector of estimated lower and upper thresholds. |
tcf1, tcf3
|
The supplied target first- and third-class fractions. |
n |
Named vector of group sizes, |
For interior estimates, the list also contains:
conf.int |
A two-sided confidence interval for TCF2. |
r.bts |
Bootstrap empirical likelihood statistics. |
r.adj |
The bootstrap adjustment factor. |
ci_level |
Confidence level of the interval. |
When inference is computed and tcf20 is supplied, the list also contains:
p.value |
The p-value for testing TCF2 equal to |
ll.value |
The adjusted empirical likelihood statistic at |
An estimate of zero returns immediately; one is replaced by
1 / (1 + 0.5 / length(y)), also without inference.
The formula method additionally returns:
formula |
The supplied formula. |
The print method returns the object invisibly. The summary
method returns a list with components estimate, conf.int,
p.value, and n, as described above.
set.seed(12) x <- rnorm(60) y <- rnorm(60, 1) z <- rnorm(60, 2) fit <- tcf2(x, y, z, tcf10 = 0.6, tcf30 = 0.6, B = 50) summary(fit)set.seed(12) x <- rnorm(60) y <- rnorm(60, 1) z <- rnorm(60, 2) fit <- tcf2(x, y, z, tcf10 = 0.6, tcf30 = 0.6, B = 50) summary(fit)
Estimate an optimal threshold for a continuous diagnostic marker in two independent groups using kernel-smoothed distribution functions. Optionally compute a bootstrap percentile confidence interval for the threshold and a bootstrap-calibrated joint empirical likelihood (EL) confidence region for specificity and sensitivity.
threshold2(x, ...) ## Default S3 method: threshold2( x, y, method = c("YI", "CtP", "MA", "all"), kernel_type = c("gauss", "epan"), bwd = NULL, bwd_type = c("RT", "AZZ", "CV"), ci = TRUE, ci_level = 0.95, B = 500, seed, plot = FALSE, ... ) ## S3 method for class 'formula' threshold2(formula, data, diag_levels = NULL, subset, na.action, ...)threshold2(x, ...) ## Default S3 method: threshold2( x, y, method = c("YI", "CtP", "MA", "all"), kernel_type = c("gauss", "epan"), bwd = NULL, bwd_type = c("RT", "AZZ", "CV"), ci = TRUE, ci_level = 0.95, B = 500, seed, plot = FALSE, ... ) ## S3 method for class 'formula' threshold2(formula, data, diag_levels = NULL, subset, na.action, ...)
x |
Numeric vector of marker measurements in the reference-negative group (class 0), or a formula supplied as the first argument to the generic. Larger marker values are assumed to indicate the reference-positive group. |
... |
Arguments passed from the generic or formula method to
|
y |
Numeric vector of marker measurements in the reference-positive group (class 1). Used by the default method. |
method |
Threshold-selection criterion: |
kernel_type |
Kernel used for CDF estimation: |
bwd |
Numeric vector of two positive bandwidths, in the order
|
bwd_type |
Bandwidth-selection method when |
ci |
Logical; whether to perform bootstrap and EL inference.
Defaults to |
ci_level |
Nominal confidence level, strictly between 0 and 1.
Defaults to |
B |
Positive integer giving the number of bootstrap replicates.
Defaults to |
seed |
Random seed for the bootstrap. If omitted, |
plot |
Logical; whether to print |
formula |
A two-sided formula of the form |
data |
Data frame containing the variables used in |
diag_levels |
Optional vector specifying the two reference-group
labels, in reference-negative then reference-positive order. If
|
subset |
Optional expression specifying the subset of observations to use in the formula method; passed to the formula-data extraction helper. |
na.action |
Missing-value handling for the formula method; passed to the formula-data extraction helper. For the default method, supply finite observations with missing values already handled. |
Let and denote the distribution functions in the
reference-negative and reference-positive groups. An observation is
classified as positive when its marker value exceeds the threshold
. Thus,
The two CDFs are estimated using cdf_kernel. The threshold is
optimised over the range of the pooled observations. For "YI",
a grid search locates candidate peaks and bounded one-dimensional
optimisation refines them. This search is also used in each bootstrap
replicate. For "CtP" and "MA", optimisation uses bounded
optim with method "L-BFGS-B".
The available criteria are:
"YI"Maximise
.
"CtP"Minimise
, the distance to
.
"MA"Maximise
by maximising
.
With method = "all", bandwidth selection and bootstrap resampling
are performed only once. The three criteria are fitted to the same original
observations and the same bootstrap replicates. Each criterion retains
its own threshold, threshold interval and bootstrap EL cutoff. EL grid
coordinates are constructed once; grid statistics are reused only when
two fitted thresholds are exactly identical.
Shared resamples do not make the three confidence regions jointly
calibrated across criteria: each region has nominal level
ci_level separately.
When ci = TRUE, observations are resampled independently within
each group. The original minimum and maximum of each group are appended
to its resampled observations. The threshold is re-estimated in every
replicate, keeping the original bandwidths and optimisation bounds fixed.
The threshold interval uses bootstrap quantiles at
and
, with quantile(type = 8).
This interval is a bootstrap percentile interval, not an EL interval.
The bootstrap EL statistic is evaluated at the original kernel estimates
of specificity and sensitivity, using each replicate's estimated threshold
and empirical CDFs. Its ci_level quantile, computed using the default
quantile type, is stored as c_alp. For the original samples,
the empirical-CDF EL statistic at the estimated threshold is evaluated on
a grid over . The contour
gives the plotted joint confidence boundary.
This is not a pair of separate marginal confidence intervals.
The default plot displays the empirical point stored in
spe_sen_emp when available, matching the original plotting behaviour.
The returned spe_opt and sen_opt, by contrast, are
kernel-based estimates. Use plot(result, point = "kernel") to
display those estimates. Changing the displayed point does not recompute
the stored EL region. With ci = FALSE, the plot shows only the
kernel-based point.
For a single criterion, threshold2 returns an object of class
"threshold2" which is a list containing the following components:
opt_thresh |
Estimated optimal threshold. |
spe_opt |
Kernel-based specificity at |
sen_opt |
Kernel-based sensitivity at |
n |
Named vector of original group sizes, |
call |
Matched function call. |
method |
The fitted criterion: |
bwd |
Bandwidths used for the two groups. |
kernel_type |
Kernel used for CDF estimation. |
ci_level |
The requested confidence level when inference is
computed, or |
When ci = TRUE, the object additionally contains:
out_bts |
A two-row bootstrap matrix: row |
c_alp |
Bootstrap-calibrated cutoff for the joint EL region. |
ci_tau |
Lower and upper bootstrap percentile confidence limits for the threshold. |
grid_sen_spe |
Data frame with columns |
spe_sen_emp |
Empirical specificity and sensitivity at the
estimated threshold, with components |
The formula method additionally returns:
formula |
The supplied formula. |
Group-label metadata are currently absent because the wrapper reads a field name not returned by the formula-data helper.
For method = "all", an object of class "threshold2_all"
is returned. This is a list containing the following components:
results |
Named list with elements |
summary |
Three-row data frame with columns |
method |
The value |
n, bwd, kernel_type, call, ci_level
|
Shared metadata as described above. |
formula |
The supplied formula, for the formula interface only. |
For the formula interface, the formula and matched call are stored both in the parent object and in each fit. Printing the all-methods object displays its summary table.
The two groups may have different sample sizes. Bootstrap samples are
stored as pairs of vectors rather than as equal-length data-frame columns.
EL grid evaluation may be computationally expensive, particularly for
method = "all" when all three fitted thresholds differ.
A non-finite bootstrap EL cutoff causes an error rather than a plot with
an undefined confidence boundary.
set.seed(123) negative <- rnorm(60, 0, 1) positive <- rnorm(60, 1.5, 1) # Point estimation without bootstrap or EL grid evaluation fit <- threshold2(negative, positive, method = "YI", bwd = c(0.4, 0.4), ci = FALSE) fit$opt_thresh c(Specificity = fit$spe_opt, Sensitivity = fit$sen_opt) # All criteria, without inference fits <- threshold2(negative, positive, method = "all", bwd = c(0.4, 0.4), ci = FALSE) fits$summary fits$results$MA$opt_thresh # Formula interface with explicit reference-group ordering dat <- data.frame( marker = c(negative, positive), group = factor(rep(c("negative", "positive"), each = 60), levels = c("negative", "positive")) ) fit_formula <- threshold2(marker ~ group, data = dat, diag_levels = c("negative", "positive"), method = "CtP", bwd = c(0.4, 0.4), ci = FALSE) ## Not run: # Full inference; the EL grid can take time to compute fit_el <- threshold2(negative, positive, method = "YI", bwd = c(0.4, 0.4), ci = TRUE, ci_level = 0.95, B = 500, seed = 34) fit_el$ci_tau plot(fit_el) plot(fit_el, point = "kernel", ci_colour = "red") fits_el <- threshold2(negative, positive, method = "all", bwd = c(0.4, 0.4), ci = TRUE, B = 500, seed = 34) fits_el$summary plot(fits_el) # One panel per criterion plot(fits_el, method = "YI") # Only the YI result plot(fits_el$results$CtP) # A child fit behaves like any threshold2 object ## End(Not run)set.seed(123) negative <- rnorm(60, 0, 1) positive <- rnorm(60, 1.5, 1) # Point estimation without bootstrap or EL grid evaluation fit <- threshold2(negative, positive, method = "YI", bwd = c(0.4, 0.4), ci = FALSE) fit$opt_thresh c(Specificity = fit$spe_opt, Sensitivity = fit$sen_opt) # All criteria, without inference fits <- threshold2(negative, positive, method = "all", bwd = c(0.4, 0.4), ci = FALSE) fits$summary fits$results$MA$opt_thresh # Formula interface with explicit reference-group ordering dat <- data.frame( marker = c(negative, positive), group = factor(rep(c("negative", "positive"), each = 60), levels = c("negative", "positive")) ) fit_formula <- threshold2(marker ~ group, data = dat, diag_levels = c("negative", "positive"), method = "CtP", bwd = c(0.4, 0.4), ci = FALSE) ## Not run: # Full inference; the EL grid can take time to compute fit_el <- threshold2(negative, positive, method = "YI", bwd = c(0.4, 0.4), ci = TRUE, ci_level = 0.95, B = 500, seed = 34) fit_el$ci_tau plot(fit_el) plot(fit_el, point = "kernel", ci_colour = "red") fits_el <- threshold2(negative, positive, method = "all", bwd = c(0.4, 0.4), ci = TRUE, B = 500, seed = 34) fits_el$summary plot(fits_el) # One panel per criterion plot(fits_el, method = "YI") # Only the YI result plot(fits_el$results$CtP) # A child fit behaves like any threshold2 object ## End(Not run)
Estimate two thresholds for three independent ordered groups using kernel CDFs, optionally with bootstrap inference.
threshold3(x, ...) ## Default S3 method: threshold3( x, y, z, method = c("GYI", "CtP", "MV", "all"), kernel_type = c("gauss", "epan"), bwd = NULL, bwd_type = c("RT", "AZZ", "CV"), ci = TRUE, ci_level = 0.95, B = 500, seed, plot = FALSE, ... ) ## S3 method for class 'formula' threshold3(formula, data, diag_levels = NULL, subset, na.action, ...)threshold3(x, ...) ## Default S3 method: threshold3( x, y, z, method = c("GYI", "CtP", "MV", "all"), kernel_type = c("gauss", "epan"), bwd = NULL, bwd_type = c("RT", "AZZ", "CV"), ci = TRUE, ci_level = 0.95, B = 500, seed, plot = FALSE, ... ) ## S3 method for class 'formula' threshold3(formula, data, diag_levels = NULL, subset, na.action, ...)
x, y, z
|
Numeric marker vectors for the three groups in increasing order. Use finite data with missing values already handled. |
... |
Arguments passed to the default method. |
method |
Criterion: |
kernel_type |
Gaussian ("gauss") or Epanechnikov ("epan") kernel. |
bwd |
Three positive bandwidths in group order, or NULL to estimate them. |
bwd_type |
RT or AZZ plug-in bandwidth, or CV cross-validation. |
ci |
Whether to compute bootstrap inference. |
ci_level |
Confidence level in (0, 1). |
B |
Positive integer number of bootstrap replicates. |
seed |
Seed passed to set.seed; default 34. Changes the global RNG state. |
plot |
Add the joint EL region to an empirical ROC surface when
|
formula |
Formula |
data |
Data frame containing formula variables. |
diag_levels |
Group labels in increasing order; NULL uses factor levels. |
subset |
Optional rows passed to model.frame. |
na.action |
Missing-value action passed to model.frame. |
At ordered thresholds a and b, the fractions are ,
, and . Optimisation uses L-BFGS-B with bounds based on
adjacent groups. Bootstrap resampling appends the original group extrema,
keeps bandwidths fixed and re-estimates both thresholds. Threshold intervals
use quantile type 8; the EL cutoff uses the default quantile type.
For method = "all", bandwidth selection and bootstrap resampling
are performed once; each criterion then estimates its own thresholds,
TCFs, confidence intervals and EL cutoff. Bootstrap samples are stored
as lists, allowing unequal group sizes.
The optimiser does not guarantee ordered returned
thresholds; inspect opt_thresh before using the result.
For a single criterion, threshold3 returns an object of class
"threshold3" which is a list containing the following components:
opt_thresh |
Vector of two estimated optimal thresholds. |
tcf1_opt, tcf2_opt, tcf3_opt
|
Kernel-based estimates of the three true
class fractions at |
n |
Named vector of original group sizes, |
call |
The matched call. |
When ci = TRUE, the object additionally contains:
out_bts |
A three-row bootstrap matrix containing two estimated thresholds and an EL statistic per replicate. Columns correspond to bootstrap replicates. |
c_alp |
Bootstrap-calibrated cutoff for the joint EL region. |
ci_tau |
A two-by-two matrix with thresholds in rows and lower/upper bootstrap percentile confidence limits in columns. |
For method = "all", an object of class "threshold3_all"
is returned. This is a list containing the following components:
results |
Named list of |
summary |
Data frame with one row per criterion and columns
|
method |
The value |
n |
Named vector of original group sizes. |
bwd |
Bandwidths used for the three groups. |
kernel_type |
Kernel used for CDF estimation. |
call |
The matched call. |
ci_level |
The requested confidence level when inference is computed,
or |
The formula method additionally returns the following components in the
returned object and in each component of results, when present:
formula |
The supplied formula. |
group.levels |
Group labels in increasing disease order. |
set.seed(21) x <- rnorm(40, 0, 1) y <- rnorm(40, 1, 1) z <- rnorm(40, 2, 1) fit <- threshold3(x, y, z, method = "CtP", bwd = rep(0.4, 3), ci = FALSE) fit$opt_thresh fit_all <- threshold3(rnorm(40), rnorm(50, 1), rnorm(60, 2), method = "all", bwd = rep(0.4, 3), ci = FALSE) fit_all$summary fit_all$results$GYI$opt_threshset.seed(21) x <- rnorm(40, 0, 1) y <- rnorm(40, 1, 1) z <- rnorm(40, 2, 1) fit <- threshold3(x, y, z, method = "CtP", bwd = rep(0.4, 3), ci = FALSE) fit$opt_thresh fit_all <- threshold3(rnorm(40), rnorm(50, 1), rnorm(60, 2), method = "all", bwd = rep(0.4, 3), ci = FALSE) fit_all$summary fit_all$results$GYI$opt_thresh
This function estimates the VUS of a continuous diagnostic test (biomarker) in three-class setting, together with a confidence interval.
vus(x, ...) ## Default S3 method: vus( x, y, z, vus0 = 1/6, ci_level = 0.95, B = 500, seed, plot = FALSE, alternative = c("greater", "less", "two.sided"), ... ) ## S3 method for class 'formula' vus(formula, data, diag_levels = NULL, subset, na.action, ...) ## S3 method for class 'vus' print(x, ...)vus(x, ...) ## Default S3 method: vus( x, y, z, vus0 = 1/6, ci_level = 0.95, B = 500, seed, plot = FALSE, alternative = c("greater", "less", "two.sided"), ... ) ## S3 method for class 'formula' vus(formula, data, diag_levels = NULL, subset, na.action, ...) ## S3 method for class 'vus' print(x, ...)
x, y, z
|
numeric vectors (default method) contains values of diagnostic test (biomarker) corresponding to the first, second and third class of disease. The ordering is intended to be “increasing” with respect to the disease severity. |
... |
for formula method: additional arguments to be passed to the |
vus0 |
the null-hypothesis value of the VUS, defaulting to |
ci_level |
a confidence level to be used for constructing the confidence interval; default is 0.95. |
B |
the number of bootstrap replicates (default: 500). |
seed |
Integer passed to |
plot |
a logical indicating whether you want to plot empirical likelihood ratio and confidence interval for VUS. |
alternative |
The alternative hypothesis. Use |
formula |
an object of class " |
data |
a data frame containing the variables in the formula. |
diag_levels |
a vector (of strings) containing the ordered name chosen for
the disease classes. The ordering is intended to be “increasing” with respect to the
disease severity. If |
subset |
an optional expression indicating the subset of the rows of data that should be used in the fit. This can be a logical vector, or a numeric vector indicating which observation numbers are to be included, or a character vector of the row names to be included. All observations are included by default. |
na.action |
a function which indicates what should happen when the data contain |
Supply independent samples ordered by increasing marker values,
with missing values handled before calling the default method. The formula
interface uses marker ~ group with exactly three groups.
The empirical estimate accounts for ties. Bootstrap resampling is performed
independently within groups. The likelihood statistic is scaled by
qchisq(0.5, 1) / median(r.bts), and the confidence limits are found
by inversion using a chi-squared cutoff with one degree of freedom.
If the empirical estimate is zero or one, the function returns early without
inference; an estimate of one is adjusted to 1 / (1 + 0.5 / n1 / n2 / n3).
An unbracketed confidence limit is returned as NA.
vus returns an object of class "vus" which is a list
containing the following components:
call |
the matched call. |
estimate |
the estimated VUS. |
n |
Named vector of group sizes, |
alternative |
the alternative hypothesis used for the test. |
For interior estimates, the list also contains:
conf.int |
a two-sided confidence interval for the VUS. |
p.value |
the p-value for testing VUS equal to |
ll.value |
Unadjusted empirical likelihood statistic at |
r.bts |
Bootstrap empirical likelihood statistics. |
r.adj |
the value of bootstrap adjustment factor. |
ci_level |
confidence level of the interval. |
Inference components are absent for boundary estimates. The formula method additionally returns:
formula |
The supplied formula. |
Group-label metadata are currently not retained. The print method
displays the results and returns the object invisibly.
Let be the VUS,
its empirical estimate, and the null value
(vus0). For total sample size , the empirical likelihood (EL)
statistic at the null is returned as ll.value and equals
The test uses the signed root of the bootstrap-adjusted EL statistic
where is the bootstrap scale factor returned as r.adj.
The function sets at equality and truncates negative
values of caused by rounding to zero before taking the
square root.
Under , the test uses
the standard normal approximation for the signed root (DiCiccio and
Romano, 1989). With denoting the standard normal
cumulative distribution function, p.value is computed as follows.
alternative = "greater"
for .
alternative = "less"
for .
alternative = "two.sided"
for . This equals the upper
tail probability of a chi-squared distribution with one degree of
freedom evaluated at .
DiCiccio, T. J., & Romano, J. P. (1989). On adjustments based on the signed root of the empirical likelihood ratio statistic. Biometrika, 76(3), 447–456. doi:10.1093/biomet/76.3.447.
To, D. K., Adimari, G., & Chiogna, M. (2024). Interval estimation in three-class receiver operating characteristic analysis: A fairly general approach based on the empirical likelihood. Statistical Methods in Medical Research, 33, 5, 875-893.
set.seed(123) x <- rnorm(60, 0, 1) y <- rnorm(60, 1, 1) z <- rnorm(60, 2, 1) fit <- vus(x, y, z, B = 100, seed = 34) fit$conf.intset.seed(123) x <- rnorm(60, 0, 1) y <- rnorm(60, 1, 1) z <- rnorm(60, 2, 1) fit <- vus(x, y, z, B = 100, seed = 34) fit$conf.int