Skip to contents

tensory 0.0.1

First development version. Everything below is new.

Tensor classes

  • Tensor, an R6 class for dense multidimensional arrays, usable either method-style (x$clone_tensor()$add(y)) or through S3 generics and operators (x + y, ttm(x, A, mode = 2)).
  • Structured companions, each with an as.tensor() method that materializes a dense Tensor: Tenmat (matricization), KTensor (CP/Kruskal), TTensor (Tucker), Sptensor and Sptenmat (sparse), SymTensor and SymKTensor (compact symmetric storage), and SumTensor (lazy sum of parts).
  • Constructors tensor(), tenrand(), ones(), zeros(), tendiag(), teneye(), tenfun(), and sptenrand().

Operations

Decompositions

Regression with tensor predictors

  • spgtr() and spgtr_cv() fit the sparse partial generalized tensor regression of Sun, Peng, Qiu, Stevens, Manatunga and Guo (submitted): a generalized linear model whose predictor is a whole array per observation. Each mode is reduced to an envelope basis, the GLM is fit on the latent scores, and the coefficient array is returned in the original shape as a TTensor. An adaptively weighted row-wise L2,1 penalty selects whole slices of the array; spgtr_cv() chooses its strength by cross-validated deviance. Any GLM family is supported, with optional unpenalized nuisance covariates. See vignette("spgtr").
  • tepls() fits the tensor envelope partial least-squares regression of Zhang and Li (2017) for continuous responses, one or several at a time. The per-mode envelope dimensions are chosen automatically when u is not given. See vignette("tepls").
  • pqtr() and pqtr_cv() fit the partial quantile tensor regression of Sun, Qiu, Peng, Guo and Manatunga (2024): a chosen quantile of the outcome, rather than its mean, is regressed on the array through per-mode partial-least-squares directions. Optional unreduced covariates are supported, the reduced dimension is chosen by an eigenvalue-ratio rule or by cross-validated check loss, and the inner quantile regressions use the MM algorithm of Hunter and Lange (2000), so no linear-programming dependency is needed. See vignette("pqtr").
  • All three accept the predictor either as a list of equally shaped observations or as a single array whose last mode indexes observations.

Data exchange

Fixes

  • scale() on an ordinary matrix no longer recurses until the C stack overflows. The default method called base::scale(), which is itself a generic and dispatched straight back to it.