R/covWarton.R

Defines functions corrWarton covWarton

covWarton <- function(S, gamma) {
    if (gamma < 0 || gamma > 1) {
        stop("\"gamma\" must be between 0 and 1")
    }
    ns <- ncol(S)
    D1 <- diag(diag(S)^-0.5)
    D2 <- diag(diag(S)^0.5)
    R <- gamma * D1 %*% S %*% D1 + (1 - gamma) * diag(ns)
    Sigma <- D2 %*% R %*% D2
    return (Sigma)
}


corrWarton <- function(R, gamma) {
    ns <- ncol(R)
    gamma * R + (1 - gamma) * diag(ns)
}

Try the BSL package in your browser

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

BSL documentation built on Nov. 3, 2022, 9:06 a.m.