R/deflation.R

Defines functions deflation

deflation <- function(X, y, na.rm = TRUE, left = TRUE) {
  # Computation of the residual matrix R
  # Computation of the vector p.
  if (left) {
    p <- pm(t(X), y, na.rm = na.rm) / as.vector(crossprod(y))
    R <- X - tcrossprod(y, p)
  } else {
    p <- pm(X, y, na.rm = na.rm) / as.vector(crossprod(y))
    R <- X - tcrossprod(p, y)
  }
  return(list(p = p, R = R))
}

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.