Wdensities {wevid} | R Documentation |
Compute densities of weights of evidence in cases and controls
Description
The function computes smoothed densities of the weight of evidence in cases and in controls from the crude probabilities, then adjusts them to make them mathematically consistent so that p(W_ctrl) = exp(-W) p(W_case).
Usage
Wdensities(y, posterior.p, prior.p, range.xseq = c(-25, 25),
x.stepsize = 0.01, adjust.bw = 1, recalibrate = TRUE,
debug = FALSE)
Arguments
y |
Binary outcome label (0 for controls, 1 for cases). |
posterior.p |
Vector of posterior probabilities generated by using model to predict on test data. |
prior.p |
Vector of prior probabilities. |
range.xseq |
Range of points where the curves should be sampled. |
x.stepsize |
Distance between each point. |
adjust.bw |
Bandwidth adjustment for the Gaussian kernel density estimator. By default it is set to 1 (no adjustment), setting it to a value smaller/larger than 1 reduces/increases the smoothing of the kernel. This argument is ignored if more than one mixture component is identified. |
recalibrate |
If |
debug |
If |
Details
If the sample distributions in cases and controls support a 2-component mixture model (based on model comparison with BIC) for the densities, this will be detected and a 2-component mixture model will be fitted before adjustment.
Value
A densities object that contains the information necessary to compute summary measures and generate plots.
Examples
data(cleveland)
densities <- with(cleveland, Wdensities(y, posterior.p, prior.p))
# Example which requires fitting a mixture distribution
data(fitonly)
densities <- with(fitonly, Wdensities(y, posterior.p, prior.p))