scrdsp
A risk score’s spread across groups
scrdsp(score, group = NULL, ref = NULL, conf = 0.95)Each group’s number of cases, mean, median and standard deviation of a score, each mean’s gap to a reference group with its interval, and the one-way analysis of variance of the score on group, with Welch’s (1951) test, which does not assume equal variances.
Parameters
Section titled “Parameters”scoreThe scores: finite numbers, one per case. A
clprelist fromclprep()is taken too: its elements fill the arguments by name.groupThe group of each case: labels.
refThe reference group:
NULLfor the group with the lowest mean (the first on ties), its label, or its position from 1.confThe confidence level of the intervals, strictly between 0 and 1.
Returns
Section titled “Returns”A list: tab, a data frame with one row per group: group, n,
mean, median, sd (NaN for one case), gap, se, lo and hi
(NaN for the reference); anova and welch, named vectors f,
df1, df2 and p; spread (the largest mean minus the smallest);
ref.
The analysis of variance is the standard one (stats::anova() of
stats::lm()): a group with one case adds to the between-group sum of
squares and nothing to the within-group one. The gaps’ intervals use the
pooled within-group variance on its degrees of freedom. Welch’s test
needs two or more cases and some spread in every group, and is NaN
otherwise.
A gap in mean scores is not by itself a sign of bias: a score built to
predict an outcome differs between groups whose rates of that outcome
differ. Read it with calaud(), which compares the scores with what was
recorded, or fair(), which compares them with outcomes case by case.
References
Section titled “References”Welch, B. L. (1951). On the comparison of several mean values: an alternative approach. Biometrika, 38(3-4), 330-336. doi:10.1093/biomet/38.3-4.330
Examples
Section titled “Examples”set.seed(7)g <- rep(c("x", "y", "z"), c(40, 40, 20))s <- rnorm(100, ifelse(g == "x", 0, ifelse(g == "y", 0.5, 1)))scrdsp(s, g)Also in the R reference, with the method and its source.