Skip to content

Commit

Permalink
simplify contr.equalprior_deviations code
Browse files Browse the repository at this point in the history
  • Loading branch information
mattansb committed Mar 28, 2024
1 parent 4acf53e commit 27a73c0
Showing 1 changed file with 2 additions and 10 deletions.
12 changes: 2 additions & 10 deletions R/contr.equalprior.R
Original file line number Diff line number Diff line change
Expand Up @@ -179,16 +179,8 @@ contr.equalprior_pairs <- function(n, contrasts = TRUE, sparse = FALSE) {
#' @rdname contr.equalprior
contr.equalprior_deviations <- function(n, contrasts = TRUE, sparse = FALSE) {
contr <- contr.equalprior(n, contrasts, sparse)
k <- nrow(contr)

r <- -1 / (k - 1)
V <- 1 - 1 / k
VCOV <- matrix(r * V, k, k)
diag(VCOV) <- V
wts <- c(1 - 1 / k, rep(-1 / k, k - 1))
scale <- as.vector(sqrt(wts %*% VCOV %*% wts))

contr / scale
n <- nrow(contr)
contr / sqrt(1 - 1 / n)
}


Expand Down

0 comments on commit 27a73c0

Please sign in to comment.