sparseICA: Sparse Independent Component Analysis (Sparse ICA) Function

View source: R/SICAmain.R

sparseICAR Documentation

Sparse Independent Component Analysis (Sparse ICA) Function

Description

This function performs Sparse Independent Component Analysis (Sparse ICA), implemented in both pure R and RCpp for efficiency.

Usage

sparseICA(
  xData,
  n.comp,
  nu = "BIC",
  nu_list = seq(0.1, 4, 0.1),
  U.list = NULL,
  whiten = c("eigenvec", "sqrtprec", "none"),
  lngca = FALSE,
  orth.method = c("svd", "givens"),
  method = c("C", "R"),
  restarts = 40,
  use_irlba = TRUE,
  eps = 1e-06,
  maxit = 500,
  verbose = TRUE,
  BIC_verbose = FALSE,
  converge_plot = FALSE,
  col.stand = TRUE,
  row.stand = FALSE,
  iter.stand = 5,
  positive_skewness = TRUE
)

Arguments

xData

A numeric matrix of input data with dimensions P x T, where P is the number of features and T is the number of samples.

n.comp

An integer specifying the number of components to estimate.

nu

A positive numeric value or a character "BIC" specifying the tuning parameter controlling the balance between accuracy and sparsity of the results. It can be selected using a BIC-like criterion ("BIC") or based on expert knowledge (a positive number). Default is "BIC".

nu_list

A numeric vector specifying the list of candidate tuning parameters. Default is seq(0.1, 4, 0.1).

U.list

An optional matrix specifying the initialization of the U matrix. Default is NULL.

whiten

A character string specifying the method for whitening the input xData. Options are "eigenvec", "sqrtprec", "lngca", or "none". Default is "eigenvec".

lngca

A logical value indicating whether to perform Linear Non-Gaussian Component Analysis (LNGCA). Default is FALSE.

orth.method

A character string specifying the method used for generating initial values for the U matrix. Default is "svd".

method

A character string specifying the computation method. If "C" (default), C code is used for most computations for better performance. If "R", computations are performed entirely in R.

restarts

An integer specifying the number of random initializations for optimization. Default is 40.

use_irlba

A logical value indicating whether to use the irlba method for fast truncated Singular Value Decomposition (SVD) during whitening. This can improve memory efficiency for intermediate datasets. Default is TRUE.

eps

A numeric value specifying the convergence threshold. Default is 1e-6.

maxit

An integer specifying the maximum number of iterations for the Sparse ICA method using Laplace density. Default is 500.

verbose

A logical value indicating whether to print convergence information during execution. Default is TRUE.

BIC_verbose

A logical value indicating whether to print BIC selection information. Default is FALSE.

converge_plot

A logical value indicating whether to generate a line plot showing the convergence trace. Default is FALSE.

col.stand

A logical value indicating whether to standardize columns. For each column, the mean of the entries in the column equals 0, and the variance of the entries in the column equals 1. Default is TRUE.

row.stand

A logical value indicating whether to standardize rows. For each row, the mean of the entries in the row equals 0, and the variance of the entries in the row equals 1. Default is FALSE.

iter.stand

An integer specifying the number of iterations for achieving both row and column standardization when col.stand = TRUE and row.stand = TRUE. Default is 5.

positive_skewness

A logical value indicating whether to enforce positive skewness on the estimated components. Default is TRUE.

Value

A list containing the following elements:

loglik

The minimal log-likelihood value among the random initializations.

estS

A numeric matrix of estimated sparse independent components with dimensions P x Q.

estM

The estimated mixing matrix with dimensions Q x T.

estU

The estimated U matrix with dimensions Q x Q.

whitener

The whitener matrix used for data whitening.

converge

The trace of convergence for the U matrix.

BIC

A numeric vector of BIC values corresponding to each candidate nu in nu_list.

nu_list

A numeric vector of candidate tuning parameter values.

best_nu

The optimal nu selected based on the BIC-like criterion.

Examples


#get simulated data
data(example_sim123)

my_sparseICA <- sparseICA(xData = example_sim123$xmat, n.comp = 3, nu = "BIC", method="C",
      restarts = 40, eps = 1e-6, maxit = 500, verbose=TRUE)

res_matched <- matchICA(my_sparseICA$estS,example_sim123$smat)

# Visualize the estimated components
oldpar <- par()$mfrow
par(mfrow=c(1,3))
image(matrix(res_matched[,1],33,33))
image(matrix(res_matched[,2],33,33))
image(matrix(res_matched[,3],33,33))
par(mfrow=oldpar)



SparseICA documentation built on April 12, 2025, 1:50 a.m.