R/connection_matrix.R

Defines functions connection_matrix

#' Construct connection matrix based on 3 common types.
#' @noRd
connection_matrix <- function(blocks, type = "pair",
                              J = length(blocks), response = J) {
  name_blocks <- names(blocks)
  switch(type,
    "pair" = {
      connection <- 1 - diag(J)
    },
    "all" = {
      connection <- matrix(1, J, J)
    },
    "response" = {
      if (J > length(blocks)) name_blocks <- c(name_blocks, "superblock")
      connection <- matrix(0, J, J)
      connection[, response] <- connection[response, ] <- 1
      connection[response, response] <- 0
    }
  )
  rownames(connection) <- colnames(connection) <- name_blocks
  return(connection)
}

Try the RGCCA package in your browser

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

RGCCA documentation built on Oct. 9, 2023, 5:09 p.m.