Learn R Programming

independence (version 1.0.1)

.calc.taustar: Compute the Tau* statistic

Description

This is an internal CPP function, used by the R function tau.star.test.

Usage

.calc.taustar(perm)

Arguments

perm

An integer vector containing exactly 0,1,...,n-1 in any order.

The validity of the input is not checked by this function.

Value

The Tau* statistic of perm.

The normalization is such that -1/3 <= Tau* <= 2/3.

The return value -1.0 indicates an error.

Details

Given (X1,Y1),...,(Xn,Yn), the Tau*_n statistic only depends on the permutation P that satisfies rank Yi = P[rank Xi]. This function computes Tau*_n given P in O(n log n) time.

Examples

Run this code
# NOT RUN {
.calc.taustar(0:3)
## [1] 0.6666667

.calc.taustar(c(0,2,1,3))
## [1] -0.3333333

set.seed(397)
.calc.taustar(order(runif(1000))-1)
## [1] 0.004392385

# }

Run the code above in your browser using DataLab