This package contains a set of functions that factor a time series matrix into a set of latent time series. Given a time series matrix A, alternating least squares is used to estimate the solution to the following equation:
$$\left (X,F\right) = \arg \min \limits_{X_m,F_m \in \Theta} \left( ||W\circ \left(X_m F_m-A \right)||_F^2+\lambda_f^2 ||F_m||_F^2 + \sum\limits_{s} R_s(X_m)\right)$$ where W is a weighting matrix the same size as A and has 0’s where A has missing values and || ⋅ ||F is the Frobenius norm. Θ is a constraint set for Fm, possible values are non-negative for NNLS-type solutions, or in the interval [0, 1] or non-negative and sum row-wise to 1 for probability-like solutions.
The last term does the temporal regularization Rs(X) = λD2||Ws(LXs)||22 + λA2||Xs||22 where L is a graph-Laplacian matrix, Xs is a subset of the columns of X, and Ws is a diagonal weight matrix. An example of L is a finite difference matrix Dα approximating a derivative of order α. In this case, if α = 2 then the regularization prefers penalized cubic spline solutions. If α = 1 then it can be used to fit a random walk.
If necessary, external regressors can be included in matrix factorization by modifying the first term to include the external regressor:
$$\left (X,F\right) = \arg \min \limits_{X_m,F_m \in \Theta} \left( ||W\circ \left([X_m, E_x]F_m -A \right)||_F^2+\lambda_f^2 ||F_m||_F^2 + \sum\limits_{s} R_s(X_m)\right)$$
Yu, Hsiang-Fu, Nikhil Rao, and Inderjit S. Dhillon. “High-dimensional time series prediction with missing values.” arXiv preprint arXiv:1509.08333 (2015).
To use the TRMF package to factor a time series matrix: