Learn R Programming

phalen (version 1.0)

qqrank: Load-Deviance Ranking

Description

Rank by size and deviance from the hypothesized mean.

Usage

qqrank(X, INDEX, alternative = c("two.sided", "less", "greater"), absrank = TRUE, N = NA, b = NA, plotpenalty = TRUE, allowed.error = 0.005)

Arguments

X
A numeric vector.
INDEX
A factor of length X.
alternative
The alternative hypothesis. Accepts "two.sided", "less", or "greater".
absrank
If 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
The number of observations below which a growth penalty is applied. N is passed to x1 argument of glpenalty.
b
A positive numeric value representing the growth rate of the glpenalty.
plotpenalty
If TRUE, the glpenalty is plotted. The default is TRUE.
allowed.error
The allowed difference between glpenalty and 1 at N. The default is 0.005.

Value

qqrankmatrix
A data frame containing the size, mean, standard deviation, and qqrank of each INDEX.
test.used
The statistical test used to measure deviance from the mean.
pop.mean
The mean of X.
pop.sd
The standard deviation of X.

Details

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.

See Also

glpenalty t.test binom.test

Examples

Run this code
  # 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