# NOT RUN {
#Simulating data from two gaussian distributions:
xE <- rnorm(100) # distribution of the marker in diseased patients
xEb <- rnorm(400, 2) # distribution of the marker in the subjects without the disease
#When working with real data. You can check the decision rule (whether low or high
#value of the marker are associated with the disease) using the densCurves function:
densCurves(x0 = xEb, x1 = xE, type = "diagnostic")
#Fit normal distributions on the two groups:
fitE <- fit(xE, "norm")
fitEb <- fit(xEb, "norm")
#Apply the main function to estimate the optimal threshold:
# }
# NOT RUN {
res <- diagThresh(fitE, fitEb, p = 0.2, r = 0.3, lowEvt = TRUE, le.MCMC = 5000,
plot = TRUE, progress.bar = "text")
#You can summarize the results using the summary() function:
summary(res,method = "median")
#You can extract the estimates and CI bounds of each indicator presented in the summary:
estimates(res, method = "median")
credibleIntervals(res)
#Plot the decision curves (this function is time-consuming):
dCres <- decisionCurve(res, r = seq(0, 0.5, length.out = 10))
#You can plot again the decision curves by applying the plot method to dCres,
#this function is a lot faster than the previous one. It also has more options
#to customize the plot:
plot(dCres)
# }
Run the code above in your browser using DataLab