pseudorank: Calculation of Pseudo-Ranks

Description Usage Arguments Value References Examples

View source: R/S3method.R

Description

Calculation of (mid) pseudo-ranks of a sample. In case of ties (i.e. equal values), the average of min pseudo-ranks and max-pseudo-ranks are taken (similar to rank with ties.method="average").

Usage

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
pseudorank(x, ...)

## S3 method for class 'numeric'
pseudorank(x, y, na.last = NA, ties.method = c("average", "max", "min"), ...)

## S3 method for class 'formula'
pseudorank(
  formula,
  data,
  na.last = NA,
  ties.method = c("average", "max", "min"),
  ...
)

Arguments

x

vector containing the observations

...

further arguments

y

vector specifiying the group to which the observations from the x vector belong to

na.last

for controlling the treatment of NAs. If TRUE, missing values in the data are put last; if FALSE, they are put first; if NA, they are removed (recommended).

ties.method

type of pseudo-ranks: either 'average' (recommended), 'min' or 'max'.

formula

formula object

data

data.frame containing the variables in the formula (observations and group)

Value

Returns a numerical vector containing the pseudo-ranks.

References

Brunner, E., Bathke, A.C., and Konietschke, F. (2018a). Rank- and Pseudo-Rank Procedures for Independent Observations in Factorial Designs - Using R and SAS. Springer Series in Statistics, Springer, Heidelberg. ISBN: 978-3-030-02912-8.

Happ M, Zimmermann G, Brunner E, Bathke AC (2020). Pseudo-Ranks: How to Calculate Them Efficiently in R. Journal of Statistical Software, Code Snippets, *95*(1), 1-22. doi: 10.18637/jss.v095.c01 (URL:https://doi.org/10.18637/jss.v095.c01).

Examples

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
df <- data.frame(data = round(rnorm(100)), group = c(rep(1,40),rep(2,40),rep(3,20)))
df$group <- as.factor(df$group)

## two ways to calculate pseudo-ranks

# Variant 1: use a vector for the data and a group vector
pseudorank(df$data,df$group)

# Variant 2: use a formula object, Note that only one group factor can be used
# that is, in data~group*group2 only 'group' will be used
pseudorank(data~group,df)

Example output

  [1]  79.250000  45.916667  16.333333  45.916667  45.916667  45.916667
  [7]   3.416667  16.333333  79.250000  45.916667  79.250000  79.250000
 [13]  79.250000  45.916667  96.333333  79.250000  45.916667  79.250000
 [19]  79.250000  96.333333  16.333333  16.333333  79.250000  45.916667
 [25]  16.333333  79.250000  16.333333  45.916667  79.250000  45.916667
 [31]  45.916667  16.333333  79.250000  96.333333  79.250000  45.916667
 [37]  96.333333  45.916667  45.916667  79.250000  79.250000  79.250000
 [43]  45.916667   3.416667  16.333333  79.250000  79.250000  45.916667
 [49]  45.916667   3.416667  45.916667  45.916667  45.916667  79.250000
 [55]  45.916667  79.250000   3.416667  45.916667  96.333333  79.250000
 [61]  16.333333  45.916667  45.916667  16.333333  16.333333  16.333333
 [67]  16.333333  16.333333  79.250000  45.916667   3.416667  45.916667
 [73]  45.916667  45.916667  45.916667  45.916667  79.250000 100.083333
 [79]  45.916667  96.333333  79.250000  79.250000  79.250000  45.916667
 [85]  45.916667  16.333333  45.916667  16.333333   3.416667  79.250000
 [91]  45.916667  79.250000  96.333333  16.333333  45.916667  16.333333
 [97]  45.916667  16.333333  45.916667  45.916667
  [1]  79.250000  45.916667  16.333333  45.916667  45.916667  45.916667
  [7]   3.416667  16.333333  79.250000  45.916667  79.250000  79.250000
 [13]  79.250000  45.916667  96.333333  79.250000  45.916667  79.250000
 [19]  79.250000  96.333333  16.333333  16.333333  79.250000  45.916667
 [25]  16.333333  79.250000  16.333333  45.916667  79.250000  45.916667
 [31]  45.916667  16.333333  79.250000  96.333333  79.250000  45.916667
 [37]  96.333333  45.916667  45.916667  79.250000  79.250000  79.250000
 [43]  45.916667   3.416667  16.333333  79.250000  79.250000  45.916667
 [49]  45.916667   3.416667  45.916667  45.916667  45.916667  79.250000
 [55]  45.916667  79.250000   3.416667  45.916667  96.333333  79.250000
 [61]  16.333333  45.916667  45.916667  16.333333  16.333333  16.333333
 [67]  16.333333  16.333333  79.250000  45.916667   3.416667  45.916667
 [73]  45.916667  45.916667  45.916667  45.916667  79.250000 100.083333
 [79]  45.916667  96.333333  79.250000  79.250000  79.250000  45.916667
 [85]  45.916667  16.333333  45.916667  16.333333   3.416667  79.250000
 [91]  45.916667  79.250000  96.333333  16.333333  45.916667  16.333333
 [97]  45.916667  16.333333  45.916667  45.916667

pseudorank documentation built on Oct. 23, 2020, 7:15 p.m.