TRMF_trend | R Documentation |
Creates a regularization scheme that favors trend-like solutions and adds it to a TRMF object. In matrix optimization form, it adds the following term to the TRMF cost function: R(x) = lambdaD^2||w(DX_s)||^2 + lambdaA^2||X_s||^2
where X_s
is sub-set of the Xm matrix controlled by this model and D is a finite difference matrix.
TRMF_trend(obj,numTS = 1,order = 1,lambdaD=1,lambdaA=0.0001,weight=1)
obj |
A TRMF object |
numTS |
number of latent time series in this model |
order |
The order of derivative for finite difference constraint matrix. Fractionally and negative values allowed. |
lambdaD |
regularization parameter for temporal constraint matrix |
lambdaA |
regularization parameter to apply simple L2 regularization to this time series model |
weight |
optional vector of weights to weight constraints, i.e. R(x) = lambdaD^2*||w*(D%*%X)||^2 |
An arbitrary number of time series models can be added. TRMF_trend(order = 1)
fits a random walk. TRMF_trend(order = 2)
fits a cubic smoothing spline. For a single time series, TRMF_trend(order = 2)
is basically equivalent to the Hodge-Prescot filter. A fractional value for order minimizes a squared fractional derivative. A negative value minimizes a (possibly fractional order) squared integral of time-series. Using a fractional or negative order for TRMF_trend
could drastically reduce the sparsity of constraint matrix and slow down training. Fractional or negative order has only been lightly tested, so use with care.
Returns an updated object of class TRMF.
Unlike TRMF_columns()
, these lambdas are squared in the code.
Chad Hammerquist
Yu, Hsiang-Fu, Nikhil Rao, and Inderjit S. Dhillon. "High-dimensional time series prediction with missing values." arXiv preprint arXiv:1509.08333 (2015).
create_TRMF
, TRMF_columns
, TRMF_simple
, TRMF_seasonal
# create test data
xm = poly(x = (-10:10)/10,degree=4)
fm = matrix(runif(40),4,10)
Am = xm%*%fm+rnorm(210,0,.1)
# create model
obj = create_TRMF(Am)
obj = TRMF_columns(obj,reg_type ="interval")
obj = TRMF_trend(obj,numTS=4,order=2,lambdaD=2)
out = train(obj)
plot(out)
# more complex model
require(magrittr) # for pipes
obj = create_TRMF(Am)%>%
TRMF_columns(reg_type ="interval")%>%
TRMF_trend(numTS=2,order=1,lambdaD=4)%>%
TRMF_trend(numTS=2,order=2,lambdaD=4)%>%
TRMF_trend(numTS=1,order=1.5)
out = train(obj)
plot(out)
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.