train.TRMF {TRMF} | R Documentation |
Train a TRMF model
Description
This function is the "engine" of the TRMF package. It takes a previously created TRMF object, sets up the internal objects and fits it to the data using an alternating least squares (ALS) algorithm.
Usage
## S3 method for class 'TRMF'
train(x,numit=10,Xm=NULL,Fm=NULL,Z=NULL,...)
Arguments
x |
A TRMF object to be fit. |
numit |
Number of alternating least squares iterations |
Xm |
Optional initial matrix. See details |
Fm |
Optional initial matrix. See details |
Z |
Optional initial vector. See details |
... |
ignored |
Details
If a coefficient model is not present in object
, it adds a L2 regularization model. If no time series models have been added to object
, it adds a simple model using TRMF_simple
. If Xm, Fm
are both NULL, then initial estimates are provided. If both are provided, the ALS algorithm is started with Xm
(with a warning) and Fm
is overwritten with the next ALS step. If external regressors are in the model and Fm is provided, the number of rows of columns must equal number of regressors plus columns of Xm. The format of Fm in this case is: [column_xreg_parameters,global_xreg_parameters,Fm_parameters]^T.
If Z
is NULL, then a vector of 1's is used as initial estimate.
Value
train
returns a fitted object of class
"TRMF
" that contains the data, all added models, matrix factorization and fitted model. The matrix factors Xm, Fm
are stored in object$Factors$Xm
and object$Factors$Fm
, object$Factors$Z
respectively. Use fitted
to get fitted model, use resid
to get residuals, use coef
to get coefficients (Fm matrix) and components
to get Xm
or Fm
.
Author(s)
Chad Hammerquist
References
Yu, Hsiang-Fu, Nikhil Rao, and Inderjit S. Dhillon. "High-dimensional time series prediction with missing values." arXiv preprint arXiv:1509.08333 (2015).
See Also
create_TRMF
, TRMF_columns
, TRMF_trend
Examples
# create test data
xm = poly(x = (-10:10)/10,degree=4)
fm = matrix(rnorm(40),4,10)
Am = xm%*%fm+rnorm(210,0,.2)
# create model
obj = create_TRMF(Am)
out = train(obj)
plot(out)