R/cqc.R

Defines functions cqc

Documented in cqc cqc

cqc <- function(x, y) {
  n   <- length(y)
  tau <- 1:(n-1) / n
  k   <- length(tau)
  rho <- NULL
  for(i in 1:k){
    ytau   <- as.numeric(stats::quantile(y, probs = tau[i]))
    psiy   <- rep(tau[i], n) - I(y - ytau < 0)
    rho[i] <- (x - mean(x)) %*% psiy / (n * sqrt(tau[i] - tau[i] ^ 2) * stats::sd(x)) 
  }
  cqc <- mean(rho)
  return(cqc)
}

Try the QCSIS package in your browser

Any scripts or data that you put into this service are public.

QCSIS documentation built on May 1, 2019, 9:17 p.m.