MATLAB Function Reference
lscov

Least squares solution in the presence of known covariance

Syntax

• ```x` `=` `lscov(A,b,V)
[x,dx] = lscov(A,b,V)
```

Description

```x = lscov(A,b,V) ``` returns the vector `x` that solves `A*x = b + e` where `e` is normally distributed with zero mean and covariance `V`. Matrix `A` must be `m`-by-`n` where `m > n`. This is the over-determined least squares problem with covariance `V`. The solution is found without inverting `V`.

```[x,dx] = lscov(A,b,V) ``` returns the standard errors of `x` in `dx`. The standard statistical formula for the standard error of the coefficients is:

• ```mse = B'*(inv(V)-inv(V)*A*inv(A'*inv(V)*A)*A'*inv(V))*B./(m-n)
dx = sqrt(diag(inv(A'*inv(V)*A)*mse))
```

Algorithm

The vector `x` minimizes the quantity `(A*x-b)'*inv(V)*(A*x-b)`. The classical linear algebra solution to this problem is

• ```` `x = inv(A'*inv(V)*A)*A'*inv(V)*b
```

but the `lscov` function instead computes the QR decomposition of `A` and then modifies `Q` by `V`.

`lsqnonneg`, `qr`
The arithmetic operator `\`