SASquantile: Implements SAS-quantile Calculation (PCTLDEF=5) as Described...

Description Usage Arguments Author(s) Examples

View source: R/stb.R

Description

This implementation seems to be identical with 'type=2' in function quantile but less efficiently implemented, i.e. for large vectors x it is much slower than the built-in quantile-function.

Usage

1
SASquantile(x, prob, tol = 1e-12, type = c("R", "C"))

Arguments

x

(numeric) vector

prob

(numeric) value 0 < prob < 1

tol

(numeric) value used for checking numerical equivalence

type

(character) "R" = uses the R-implementation, "C" = calls the C-implementation n

Author(s)

Andre Schuetzenmeister andre.schuetzenmeister@roche.com

Examples

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
## Not run: 
SASquantile(1:100, .75)

### compare to R-default
quantile(1:100, .75) 

### or to what R calls SAS-definition
quantile(1:100, .75, type=3)

# should work for any vector (no seed)
v <- rnorm(50000,20,7)
Q.R2    <- quantile(v, probs=c(.01, .025, .05, .1, .25, .5, .75, .9, .95, .975, .99), type=2)
Q.SAS.R <- SASquantile(v, prob=c(.01, .025, .05, .1, .25, .5, .75, .9, .95, .975, .99), type="R")
Q.SAS.C <- SASquantile(v, prob=c(.01, .025, .05, .1, .25, .5, .75, .9, .95, .975, .99), type="C")

Q.R2
Q.SAS.R
Q.SAS.C

## End(Not run)

STB documentation built on Sept. 15, 2021, 5:07 p.m.

Related to SASquantile in STB...