checkquantiles: Check Quantiles and Probabilities

Description Usage Arguments Examples

View source: R/n_estimation.R

Description

Check that quantiles (or probabilities) are all different from each other and correctly ordered. If proba = TRUE, check that values are in range (0, 1).

Usage

1
checkquantiles(x, proba = FALSE, acceptNA = FALSE, STOP = TRUE)

Arguments

x

vector of quantiles.

proba

boolean. If TRUE, check range (0,1).

acceptNA

boolean. If FALSE, NA value are not accepted.

STOP

boolean. If an error is encountered, TRUE stops the function and returns an error message. FALSE just returns FALSE.

Examples

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
    

lst <- list(
  0.8,
  c(0.1, 0.5, 0.8),
  c(0.1, 0.5, 0.8, 0.2),
  c(2, 3, 1),
  c(2, 3),
  -0.01,
  NA,
  c(NA, NA),
  c(0.1, NA),
  c(0.1, NA, 0.5, 0.8),
  c(0.1, NA, 0.8, NA, 0.5),
  c(12, NA)
)

## Evaluate
for (i in seq_along(lst)) { 
  cat(i, lst[[i]], " : ",
      checkquantiles(lst[[i]], proba = FALSE, STOP = FALSE), 
      checkquantiles(lst[[i]], proba = TRUE, STOP = FALSE), 
      checkquantiles(lst[[i]], proba = FALSE, acceptNA = TRUE, STOP = FALSE), 
      checkquantiles(lst[[i]], proba = TRUE,  acceptNA = TRUE, STOP = FALSE), 
	     "\n") 
}

sapply(lst, checkquantiles, proba = TRUE, acceptNA = TRUE, STOP = FALSE)

## Not run: 
checkquantiles(matrix((1:12)/16, ncol=3), proba = TRUE, STOP = FALSE)
## End(Not run)

FatTailsR documentation built on March 12, 2021, 9:06 a.m.