# Update sample covariance matrix

I would like to update a covariance matrix $$\mathbf{R}_T$$ with a new incoming sample at time $$T+1$$, i.e. I would like a rank-1 update of the form $$\frac{1}{T+1} [T \mathbf{R}_T + \mathbf{x}_{T+1}\mathbf{x}_{T+1}^{\top}]$$. However I want a weighted average by forgetting past observations.

That is, I would like something of the form:

$$\mathbf{R}_{T+1}= \frac{1}{T+1} \big[\sum_{i=1}^{T-1} \alpha^{T-i}\mathbf{x}_{i}\mathbf{x}_{i}^{\top} + \alpha^0\mathbf{x}_{T+1}\mathbf{x}_{T+1}^{\top}\big]$$,

subject to $$\sum \alpha=1$$. But I would like to express $$\mathbf{R}_{T+1}$$ as function of $$\mathbf{R}_{T}$$, because I already have it. So I want to forget the data while retaining the covariance information. Could you please tell me where to search something related to it? I have read someting about the EWMA model, but not sure whether it's what I am searching.

Thanks.

• I think if you want to “forget” / “update” a data entry, you have to keep track of all data points entering your estimator. You would, for example, have to keep a $N\times K$ data matrix and update every $i \mod N$ entry with new information... Oct 17 '20 at 10:36
• Possible relevant link stats.stackexchange.com/questions/26123/… Oct 17 '20 at 11:50

Hi: Exponential smoothing weights observations by taking a weighted combination of the old estimate and the new. So, if you denote your original matrix ( or current covariance matrix ) as $$R_t$$ and your new one as $$R^{*}_t$$, then exponential smoothing does

$$R_{t+1} = \lambda R_{t} + (1- \lambda) R^{*}_t$$.

But there are two issues with doing this update.

1. The value of $$\lambda$$. The closer it is to 1.0, the more weight is being put on the old ( current ) estimate.

2. How to calculate the $$R^{*}_t$$ ? You may want to exponentially smooth the values that go into the calculation of the covariance matrix or just use a covariance matrix that cuts off the raw observations before some $$t = t^{*}$$.

So, exponential smoothing, in this case, is part art and part science.

• Technically, you can simply use demeaned or raw return squares / co-returns for $R_t^*$. The selection of $\lambda$, effectively, controls the number of past observations entering the estimation. But they are not weighted equally of course. Oct 17 '20 at 17:00
• @Albus: I think what kermittfrog is saying is that, when calculating $R_t^{*}$, you can just add whatever new raw observations have arrived into the calculation of it. This might be okay, but, as you get more and more data, if you don't cut it off at the back, then the new observation(s) will make up a smaller and smaller percentage of the total number of observations as time goes on, if you don't drop observations, the two matrices ( the previously calculated one and the new one ) will start to converge to the same matrix. One way to drop is to using some moving average of returns. Oct 18 '20 at 2:44
• The circular nature of this is discussed here: stackoverflow.com/questions/5147378/rolling-variance-algorithm Oct 18 '20 at 4:43
• @Kermittfrog: It looks involved and I don't have time to read it right now but thanks for link. Oct 18 '20 at 14:59