tiebreak: Break the ties in a given vector or between two vectors

Description Usage Arguments Details Examples

View source: R/tiebreak.R

Description

If the vector contains ties (either inside a single or between two vectors), the function breaks them using a random perturbation.

Usage

1
tiebreak(x, y = NULL, nb_break = FALSE)

Arguments

x, y

the variables containing ties.

nb_break

if TRUE return also the number of values that have been broken

Details

If y=NULL the function detects the ties in the vector x. A uniform variable with parameters [-e^(-5),e^(-5)] is added to the value of all the ties but one in the vector x. If y is also provided, the function detects the ties between x and y and break them (only in the x vector) by adding a uniform variable with parameters [-e^(-5),e^(-5)] to these values. If nb_break equals TRUE the result is returned as a list that also includes the number of values that have been broken.

Examples

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
x <- c(1,2,2,3,4,5,5,5,7)
xbreak=tiebreak(x)
xbreak
#a uniform value has been added to the second, sixth and seventh value of x.
tiebreak(x,nb_break=TRUE) #3 values have been broken in x
sum(duplicated(xbreak))#check if the breaking procedure has worked.
y <- c(4,9,12,11,2,10)
xy_break=tiebreak(x,y)
xy_break$x
xy_break$y #a uniform value has been added to the second, third and fifth value of x.
xy_break$x%in%xy_break$y #check that no values for xbreak can be found in ybreak
tiebreak(x,y,nb_break=TRUE) #also returns the number of broken values

obouaziz/robusTest0 documentation built on Dec. 22, 2021, 4:13 a.m.