This function computes the threshold estimate and its corresponding confidence interval in a two-state setting.
thres2(k1, k2, rho,
costs = matrix(c(0, 0, 1, (1 - rho)/rho), 2, 2, byrow = TRUE),
method = c("equal", "unequal", "empirical", "parametric"),
dist1 = NULL, dist2 = NULL, ci.method = c("delta", "boot"),
B = 1000, alpha = 0.05, extra.info = FALSE, na.rm = FALSE)vector containing the healthy sample values.
vector containing the diseased sample values.
disease prevalence.
cost matrix. Costs should be entered as a 2x2 matrix, where the first row corresponds to the true positive and true negative costs and the second row to the false positive and false negative costs. Default cost values are a combination of costs that yields R=1, which would be the equivalent to the Youden index method (for details about this concept, see References).
method used in the estimation. The user can specify just the initial letters. Default, "equal". See Details for more information about the methods available.
distribution to be assumed for the healthy population. See Details.
distribution to be assumed for the diseased population. See Details.
method to be used for the confidence intervals computation. The user can specify just the initial letters. Default, "delta". See Details for more information about the methods available.
number of bootstrap resamples when ci.method = "boot". Otherwise, ignored. Default, 1000.
significance level for the confidence interval. Default, 0.05.
when using method="empirical", if set to TRUE the function returns extra information about the computation of the threshold. Ignored when method is not "empirical". Default, FALSE.
a logical value indicating whether NA values in k1 and k2 should be stripped before the computation proceeds. Default, FALSE.
An object of class thres2, which is a list with two components:
a list of at least seven components:
thres threshold estimate.
prev disease prevalence provided by the user.
costs cost matrix provided by the user.
R R term, the product of the non-disease odds and the cost ratio (for further details about this concept, see References).
method method used in the estimation.
k1 vector containing the healthy sample values provided by the user.
k2 vector containing the diseased sample values provided by the user.
When method = "empirical", T also contains:
sens sensitivity obtained.
spec specificity obtained.
cost the minimum cost associated with T$thres.
tot.thres vector of possible thresholds. Only if extra.info = TRUE.
tot.cost vector of empirical costs. Only if extra.info = TRUE.
tot.spec.c complementary of the vector of empirical specificities (1-spec). Only if extra.info = T.
tot.sens vector of empirical sensitivities. Only if extra.info = TRUE.
When method = "parametric", T also contains:
dist1 distribution assumed for the healthy population.
dist2 distribution assumed for the diseased population.
pars1 a numeric vector containing the estimation of the parameters of dist1.
pars2 a numeric vector containing the estimation of the parameters of dist2.
When ci.method = "delta", a list of four components:
lower the lower limit of the confidence interval.
upper the upper limit of the confidence interval.
alpha significance level provided by the user.
ci.method method used for the confidence intervals computation.
When ci.method = "boot", a list of seven components:
low.norm the lower limit of the bootstrap confidence interval based on the normal distribution.
up.norm the upper limit of the bootstrap confidence interval based on the normal distribution.
low.perc the lower limit of the bootstrap confidence interval based on percentiles.
up.perc the upper limit of the bootstrap confidence interval based on percentiles.
alpha significance level provided by the user.
B number of bootstrap resamples.
ci.method method used for the confidence intervals computation.
For parameter method the user can choose between "equal" (assumes binormality and equal variances), "unequal" (assumes binormality and unequal variances), "empirical" (leaves out any distributional assumption) or "parametric" (based on the distribution assumed for the two populations).
Parameters dist1 and dist2 can be chosen between the following 2-parameter distributions: "beta", "cauchy", "chisq" (chi-squared), "gamma", "lnorm" (lognormal), "logis" (logistic), "norm" (normal) and "weibull". Notice that dist1 and dist2 are only needed when method = "parametric".
For parameter ci.method the user can choose between "delta" (delta method is used to estimate the threshold standard error assuming a binormal underlying model) or "boot" (the confidence interval is computed by bootstrap).
Efron B, Tibshirani RJ. (1993). An introduction to the bootstrap, Chapman & Hall.
Skaltsa K, Jover L, Carrasco JL. (2010). Estimation of the diagnostic threshold accounting for decision costs and sampling uncertainty. Biometrical Journal 52(5):676-697.
# NOT RUN {
# example 1
n1 <- 100
n2 <- 100
set.seed(1234)
par1.1 <- 0
par1.2 <- 1
par2.1 <- 2
par2.2 <- 1
rho <- 0.2
k1 <- rnorm(n1, par1.1, par1.2) # non-diseased
k2 <- rnorm(n2, par2.1, par2.2) # diseased
thres2(k1, k2, rho, method="eq", ci.method="d")
thres2(k1, k2, rho, method="uneq", ci.method="d")
# }
# NOT RUN {
thres2(k1, k2, rho, method="empirical", ci.method="b")
# example 2
set.seed(1234)
k1 <- rnorm(50, 10, 3)
k2 <- rlnorm(55)
rho <- 0.3
thres2(k1, k2, rho, method="param", ci.method="boot", dist1="norm", dist2="lnorm")
# }
Run the code above in your browser using DataLab