R/contr.R

Defines functions contr

contr <- function(d) {
  C <- matrix(0, d * (d + 1) / 2, d ^ 2)
  for (i in 1:d) {
    for (j in 1:d) {
      if (j == i) {
        C[(2 * d - i) / 2 * (i - 1) + j, d * (i - 1) + j] <- 1
      } else if (j > i) {
        C[(2 * d - i) / 2 * (i - 1) + j, d * (i - 1) + j] <- 1 / 2
      } else {
        C[(2 * d - j) / 2 * (j - 1) + i, d * (i - 1) + j] <- 1 / 2
      }
    }
  }
  return(C)  
}

Try the Renvlp package in your browser

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

Renvlp documentation built on Oct. 11, 2023, 1:06 a.m.