I am attempting to implement a generalized least squares estimator that uses a noise covariance matrix from measured data. The basic model is as follows
$$\hat{c}_{GLS} = \left(\bf{A}^T\bf{\Sigma}^{-1}\bf{A}\right)^{-1}\bf{A}^T\bf{\Sigma}^{-1}\bf{r}$$
where $\bf{A}$ is a matrix of my basis functions, $\bf{\Sigma}$ is the noise covariance matrix and $\bf{r}=[r_x r_y r_z]^T$ is a column vector of my vector measurements ordered as shown. Likewise the noise vector measurements are $\bf{n}=[n_x n_y n_z]^T$.
The statement is made in the paper that $\Sigma = E\left\{\bf{n}\bf{n}^T\right\}$, which results in $\Sigma$ being size $3N\times 3N$ which makes sense. However, when I do this I get horrible results and the structure of $\Sigma$ doesn't look right. I expect it to be diagonal dominant and then falling off.
- My question is what am I doing wrong?
- How do I build the noise covariance matrix correctly?
I have data for $\bf{n}=[n_x n_y n_z]^T$ It isn't just the $3\times 3$ covariance matrix I am use to dealing with.
Edit: added code
minutes = 5;
NSamples = Fs*60*minutes;
NOverlap = NSamples/2;
Sigma = zeros(3*NSamples,3*NSamples);
M=20;
for nn = 1:M
nStart = (nn-1)*NOverlap+1;
nStop = nStart+NSamples-1;
nx = x1(nStart:nStop);
ny = y1(nStart:nStop);
nz = z1(nStart:nStop);
Rxx = xcov(nx );Rxx= (Rxx(NSamples:end));
Rxy = xcov(nx,ny );Rxy= (Rxy(NSamples:end));
Rxz = xcov(nx,nz );Rxz= (Rxz(NSamples:end));
Ryy = xcov(ny );Ryy= (Ryy(NSamples:end));
Rzz = xcov(nz );Rzz= (Rzz(NSamples:end));
Ryz = xcov(ny, nz );Ryz= (Ryz(NSamples:end));
N = [toeplitz(Rxx) toeplitz(Rxy) toeplitz(Rxz);
toeplitz(Rxy) toeplitz(Ryy) toeplitz(Ryz);
toeplitz(Rxz) toeplitz(Ryz) toeplitz(Rzz)];
Sigma = N + Sigma;
end
Sigma = Sigma/M;
x1,y1,z1
were generated or were processed, but to have your expected result, i.e. diagonal dominant matrix, the elements of x1, y1,z1 must be uncorrelated. Below is the extra code I addedNN = M * NOverlap * 2; x1 = randn(1,NN) + 1i * randn(1,NN); y1 = randn(1,NN) + 1i * randn(1,NN); z1 = randn(1,NN) + 1i * randn(1,NN);
$\endgroup$ – AlexTP Jun 25 '17 at 7:28