Implementation of news analysis in JDemetra+
The weights associated to each piece of news are calculated as follows:
\[\begin{equation} \underbrace{\left[ w^{k,h}_{1} \ldots w^{k,h}_{J}\right]}_{w} = \underbrace{E[y_{k,t+h}\mathcal{I}^{'}]}_{A} \underbrace{E[\mathcal{I}\mathcal{I}^{'}]^{-1}}_{(LL')^{-1}} \end{equation}\]In 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[\mathcal{I}\mathcal{I}^{'}]\) -
weights(int series, TsPeriod p)
first stores \(E[y_{k,t+h}\mathcal{I}^{'}]\) in a DataBlocka
, and then it solves the system without the need to invert \(E[\mathcal{I}\mathcal{I}^{'}]\) -
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