Wdensities: Compute densities of weights of evidence in cases and...

Description Usage Arguments Details Value Examples

View source: R/wdists.R

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

1
2
3
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 TRUE (the default) the weights of evidence are calculated after the posterior probabilities have been recalibrated against y using a logistic regression model.

debug

If TRUE, the size of the adjustment is reported.

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

1
2
3
4
5
6
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))

wevid documentation built on Sept. 12, 2019, 5:04 p.m.