In this vignette we consider approximating a tensor as a product of multiple low-rank matrices (a.k.a., factor matrices) and a core tensor.
Test data is available from toyModel
.
##
## Attaching package: 'nnTensor'
## The following object is masked from 'package:iTensor':
##
## toyModel
## Formal class 'Tensor' [package "rTensor"] with 3 slots
## ..@ num_modes: int 3
## ..@ modes : int [1:3] 30 30 30
## ..@ data : num [1:30, 1:30, 1:30] 113 81 120 95 102 2 4 2 0 1 ...
You will see that there are four small blocks in the diagonal direction of the data tensor.
There are so many tensor decomposition algorithms but here we consider that each factor matrix is extracted by Independent Component Analysis (ICA). This is called Multilinear Independent Component Analysis (MultilinearICA (Vasilescu 2005)).
MultilinearICA
can be performed as follows.
The rank for each factor matrix can be set as Js
and the
decomposition algorithm can be easily switched by
algorithm
.
By using recTensor
of nnTensor
, user can
easily reconstruct the data from core tensor and factor matrices as
follows.
## R version 4.4.1 (2024-06-14)
## Platform: x86_64-pc-linux-gnu
## Running under: Ubuntu 24.04.1 LTS
##
## Matrix products: default
## BLAS: /usr/lib/x86_64-linux-gnu/openblas-pthread/libblas.so.3
## LAPACK: /usr/lib/x86_64-linux-gnu/openblas-pthread/libopenblasp-r0.3.26.so; LAPACK version 3.12.0
##
## locale:
## [1] LC_CTYPE=en_US.UTF-8 LC_NUMERIC=C
## [3] LC_TIME=en_US.UTF-8 LC_COLLATE=C
## [5] LC_MONETARY=en_US.UTF-8 LC_MESSAGES=en_US.UTF-8
## [7] LC_PAPER=en_US.UTF-8 LC_NAME=C
## [9] LC_ADDRESS=C LC_TELEPHONE=C
## [11] LC_MEASUREMENT=en_US.UTF-8 LC_IDENTIFICATION=C
##
## time zone: Etc/UTC
## tzcode source: system (glibc)
##
## attached base packages:
## [1] stats graphics grDevices utils datasets methods base
##
## other attached packages:
## [1] nnTensor_1.3.0 mixOmics_6.31.0 ggplot2_3.5.1 lattice_0.22-6
## [5] MASS_7.3-61 iTensor_1.0.3 rmarkdown_2.28
##
## loaded via a namespace (and not attached):
## [1] dotCall64_1.2 spam_2.11-0 gtable_0.3.6
## [4] ellipse_0.5.0 xfun_0.49 bslib_0.8.0
## [7] tagcloud_0.6 ggrepel_0.9.6 vctrs_0.6.5
## [10] tools_4.4.1 generics_0.1.3 parallel_4.4.1
## [13] tibble_3.2.1 fansi_1.0.6 highr_0.11
## [16] rARPACK_0.11-0 pkgconfig_2.0.3 Matrix_1.7-1
## [19] RColorBrewer_1.1-3 lifecycle_1.0.4 groupICA_0.1.1
## [22] compiler_4.4.1 stringr_1.5.1 fields_16.3
## [25] munsell_0.5.1 codetools_0.2-20 misc3d_0.9-1
## [28] einsum_0.1.2 maps_3.4.2 htmltools_0.5.8.1
## [31] sys_3.4.3 buildtools_1.0.0 sass_0.4.9
## [34] yaml_2.3.10 pillar_1.9.0 jquerylib_0.1.4
## [37] tidyr_1.3.1 BiocParallel_1.41.0 cachem_1.1.0
## [40] nlme_3.1-166 RSpectra_0.16-2 tidyselect_1.2.1
## [43] digest_0.6.37 stringi_1.8.4 dplyr_1.1.4
## [46] reshape2_1.4.4 purrr_1.0.2 maketools_1.3.1
## [49] splines_4.4.1 fastmap_1.2.0 grid_4.4.1
## [52] colorspace_2.1-1 cli_3.6.3 rTensor_1.4.8
## [55] magrittr_2.0.3 utf8_1.2.4 corpcor_1.6.10
## [58] withr_3.0.2 scales_1.3.0 plot3D_1.4.1
## [61] matrixStats_1.4.1 igraph_2.1.1 gridExtra_2.3
## [64] evaluate_1.0.1 knitr_1.48 tcltk_4.4.1
## [67] viridisLite_0.4.2 mgcv_1.9-1 jointDiag_0.4
## [70] rlang_1.1.4 Rcpp_1.0.13-1 glue_1.8.0
## [73] geigen_2.3 jsonlite_1.8.9 R6_2.5.1
## [76] plyr_1.8.9