R/computeDelta.R

Defines functions computeDelta

computeDelta <- function(X, ExpInd, covariance=TRUE){
  ## difference between the covariance matrices of X under the different interventions

    n <- nrow(X)
    settings <- sort(unique(ExpInd))
    G <- length(settings)
    
    # initialize list containing Delta matrices
    Deltalist <- vector("list", G)
    
    for (k in 1:G){
        useo <- which(ExpInd==settings[k])
        useo2 <- which(ExpInd!=settings[k])
        if(covariance){
            Deltalist[[k]] <- cov( X[useo ,]) - cov( X[useo2,])
        }else{
            Deltalist[[k]] <- 1/(length(useo))*(t(X[useo,])%*%X[useo,]) - 1/(length(useo2))*(t(X[useo2,])%*%X[useo2,])
        }
    }
  
    list(Delta = Deltalist, K = G)
}

Try the backShift package in your browser

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

backShift documentation built on July 2, 2020, 4:01 a.m.