I am given the means for four samples $x_1,...x_4$ and a sample covariance matrix S that’s size $4\times 4$.
How do I compute the sample covariance for $x_1-x_2$? I assumed it would just be $s_{11}-s_{22}$, but I am not getting the correct value.
I am given the means for four samples $x_1,...x_4$ and a sample covariance matrix S that’s size $4\times 4$.
How do I compute the sample covariance for $x_1-x_2$? I assumed it would just be $s_{11}-s_{22}$, but I am not getting the correct value.
Copyright © 2021 JogjaFile Inc.
If you are given a $S \in \Bbb{R^{4 \times 4}}$ covariance matrix, then each element will provide you with the variance between $x_i$ and $x_j$. $$Cov(x_i,x_j) =s_{ij}$$ where $S = [s_{ij}]_{i,j=1}^4$.
Another important fact to note is that $Var(x_i-x_j) = Var(x_i) + Var(x_j) - 2\ Cov(x_i,x_j)$. (See more basic variance properties here.)
And lastly, $Var(x_i) = Cov(x_i,x_i) = s_{ii}$.
Now putting these all together:
$$Var(x_i-x_j) = Var(x_i) + Var(x_j) - 2\ Cov(x_i,x_j) = s_{ii} + s_{jj} - 2\ s_{ij}$$
Or, since the covariance matrix is symmetric:
$$Var(x_i-x_j) = Var(x_i) + Var(x_j) - 2\ Cov(x_i,x_j) = s_{ii} + s_{jj} - s_{ij} - s_{ji}.$$
And specifically,
$$Var(x_1-x_2) = Var(x_1) + Var(x_2) - 2\ Cov(x_1,x_2) = s_{11} + s_{22} - 2\ s_{12}.$$