TRMF_seasonal: Add seasonal regularization model to a TRMF object

View source: R/TRMF.R

TRMF_seasonalR Documentation

Add seasonal regularization model to a TRMF object

Description

Creates a regularization scheme that favors seasonally varying 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 (with a lag of freq) finite difference matrix (or rolling sum matrix, see details).

Usage

TRMF_seasonal(obj,numTS = 1,freq = 12,sumFirst=FALSE,lambdaD=1,lambdaA=0.0001,weight=1)

Arguments

obj

A TRMF object

numTS

number of latent time series in this model

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

freq

The frequency of the seasonal time series model.

sumFirst

Minimize the rolling sum of length freq instead of a lagged finite difference.

Details

TRMF_seasonal(freq=N) fits a lag N random walk. For monthly data, use freq=12, for quarterly data, freq=4. If sumFirst = TRUE, (called this for legacy reasons), a different regularization matrix is used which minimizes a rolling sum of length freq in the latent time series. This can be useful to prevent drift and force the seasonal component to vary around a zero mean.

Value

Returns an updated object of class TRMF.

Note

Unlike TRMF_columns(), these lambdas are squared in the code.

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_simple, TRMF_trend

Examples

# create test data
tm = 3*poly(x = (-20:20)/10,degree=3)
sm = diffinv(rnorm(29,0,.1),lag=12,xi=(-5:6)/6)
xm = cbind(sm,tm)
fm = matrix(runif(40),4,10)
Am = xm%*%fm+rnorm(410,0,.1)

# create model
obj = create_TRMF(Am)
obj = TRMF_columns(obj,reg_type ="interval")
obj = TRMF_trend(obj,numTS=3,order=2)
obj = TRMF_seasonal(obj,numTS=1,freq=12,lambdaD=5)
out = train(obj)
plot(out)


TRMF documentation built on June 22, 2024, 10:41 a.m.