qqrank(X, INDEX, alternative = c("two.sided", "less", "greater"), absrank = TRUE, N = NA, b = NA, plotpenalty = TRUE, allowed.error = 0.005)
X
."two.sided"
, "less"
, or "greater"
.TRUE
, INDEX
means greater than or less than the population mean will produce a positive qqscore
. If FALSE
, INDEX
means greater than the population mean will have a positive qqscore
and INDEX
means less than the population mean will have a negative qqscore
. The default is TRUE
.N
is passed to x1
argument of glpenalty
.glpenalty
.TRUE
, the glpenalty
is plotted. The default is TRUE
.glpenalty
and 1
at N
. The default is 0.005
.INDEX
.X
.X
.qqrank
ranks by size and deviance from the hypothesized mean using either the Binomial Test or Welch's t-Test. Restated, qqrank
is a function of a size penalty, test statistic or variant thereof, and p-value.
glpenalty
t.test
binom.test
# which hospital has the "worst" readmissions? (note: the average
# readmission rate is 17.13%
data(ipadmits)
attach(ipadmits)
ip.ag = data.frame('sum' = tapply(ipadmits$isReadmission,ipadmits$HospID,sum),
'avg' = tapply(ipadmits$isReadmission,ipadmits$HospID,mean))
# hospital 9 has the most readmissions (1,094), but the percent of readmissions
# is low at 14%, less than the population average.
ip.ag[order(-ip.ag$sum),][1,]
# hostpital 80 has the highest percentage of readmissions 87.5%, but only
# 7 readmissions over all.
ip.ag[order(-ip.ag$avg),][1,]
# using qqrank and penalizing samples less than N = 250 at a growth
# rate of b = 0.05, Hospital 39 has 1606 readmissions with a readmission
# percent of 38%.
qqr = qqrank(ipadmits$isReadmission,ipadmits$HospID
,alternative = "greater",N = 250, b = 0.05)
round(qqr$rankmatrix,2)
# relax sample penalty and rank on both sides of the mean
# Hospital 21 has the "best" readmission track record.
qqr = qqrank(ipadmits$isReadmission,ipadmits$HospID
,alternative = "two.sided",absrank = FALSE,N = 30, b = 0.1)
round(qqr$rankmatrix,2)
detach(ipadmits)
Run the code above in your browser using DataLab