R/Lir.R

Defines functions Lir

Documented in Lir

#' Compute loss per data matrix using multivariate regression
#'@description Internal function for CICA package
#' @param Xi datablock
#' @param SkL list with Group ICA parameters
#'
#' @keywords internal
#' @return a numeric vector with loss function values
Lir <- function(Xi, SkL)
{
  # compute Ahats
  Ah <- lapply(seq_along( SkL), function(i) {
    crossprod(Xi, SkL[[i]]) %*% mpinv( t(SkL[[i]]) %*% SkL[[i]])
  })

  # compute Xhats --> Xhat^r
  Xhat <- lapply(seq_along(Ah), function(i) {
    tcrossprod( SkL[[i]], Ah[[i]])
  })

  # loss per data matrix
  SS <- sapply(seq_along(Xhat), function(i) {
    sum((Xi - Xhat[[i]]) ^ 2)
  })

  return(SS)
}#function

Try the CICA package in your browser

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

CICA documentation built on Sept. 11, 2024, 6:33 p.m.