Implementation of news analysis in JDemetra+
The weights associated to each piece of news are calculated as follows:
[wk,h1…wk,hJ]⏟w=E[yk,t+hI′]⏟AE[II′]−1⏟(LL′)−1In order to calculate the weights, we use the Kalman smoother for the determination of the precision matrices, which are an essential part of the formula:
- The covariance between the target variable and the news vector has the following form:
- The covariance of the news vector can be written as follows:
Our implementation can be summarized in a few simple steps:
-
computeNewsCovariance()
computes a lower-triangular matrixlcov_
, which is the Choleski factor of E[II′] -
weights(int series, TsPeriod p)
first stores E[yk,t+hI′] in a DataBlocka
, and then it solves the system without the need to invert E[II′] -
The weights are computed by solving two systems, which can be represented in matrix notation:
- First, calculate B=wL by solving LB′=A′ using the
rsolve
method contained in the class lower triangular - Second, calculate w by solving wL=B using the
lsolve
method
- First, calculate B=wL by solving LB′=A′ using the