Extract dynamic latent structure from multivariate time series with Dynamic Inner PCA (DiPCA), CCA (DiCCA), and PLS (DiPLS).
| Method | Function | Use case |
|---|---|---|
| DiPCA | dipca() |
Unsupervised components with predictable latent scores |
| DiCCA | dicca() |
Components ordered by predictability / canonical correlation |
| DiPLS | dipls() |
Supervised dynamic modeling from input X to output Y
|
Fitted models integrate with
multivarious for
scores(), project(), predict(), reconstruct(), and residuals().
Standard PCA finds high-variance directions but ignores temporal structure.
dipca targets latent directions that are predictable from their own past,
which is often what matters for process monitoring, temporal factor extraction,
and dynamic regression.
predict() and residuals()
install.packages("remotes")
# remotes::install_github("bbuchsbaum/dipca")
install.packages("dipca", repos = c('https://bbuchsbaum.r-universe.dev', 'https://cloud.r-project.org'))
Requires multivarious (>= 0.3.0),
available on CRAN.
library(dipca)
library(multivarious)
set.seed(42)
N <- 300; m <- 6
t1 <- arima.sim(list(ar = 0.8), n = N)
t2 <- arima.sim(list(ar = 0.4), n = N)
P <- qr.Q(qr(matrix(rnorm(m * 2), m, 2)))
X <- cbind(t1, t2) %*% t(P) + matrix(rnorm(N * m, sd = 0.3), N, m)
fit <- dipca(X, s = 1, l = 2, n_init = 3)
scores(fit) # latent scores
predict(fit, X) # one-step-ahead score forecasts
stats::residuals(fit, X) # dynamic whitening errors
dipca() — unsupervised dynamic factors balancing variance and temporal predictability:
fit <- dipca(X, s = 1, l = 3, n_init = 5, max_iter = 1000, tol = 1e-7)
dicca() — components ranked by R² (classic inner model):
fit <- dicca(X, s = 1, l = 3, inner = "classic", n_init = 5)
fit$R2
Compact per-component inner models: inner = "ar" or "arma".
dipls() — dynamic latent regression from X to Y:
fit <- dipls(X, Y, n_comp = 2, s = 2, mode = "fir", verbose = 0)
predict(fit, X)
vignette("dipca") — getting startedvignette("extracting-dynamic-components") — ground-truth simulation walkthrough?dipca, ?dicca, ?dipls — function referenceGPL (>= 3)