## Documentation Center |

Covariance matrix

cov(X) cov(X,Y)

`cov` for financial time series objects is
based on the MATLAB^{®} `cov` function. See `cov` in the MATLAB documentation.

If `X` is a financial time series object with
one series, `cov(X)` returns the variance. For
a financial time series object containing multiple series, where each
row is an observation, and each series a variable, `cov(X)` is
the covariance matrix.

`diag(cov(X))` is a vector of variances for
each series and `sqrt(diag(cov(X)))` is a vector
of standard deviations.

`cov(X, Y)`, where `X` and `Y` are
financial time series objects with the same number of elements, is
equivalent to `cov([X(:) Y(:)])`.

`cov(X)` or `cov(X, Y)` normalizes
by (`N` -`1`) if `N` > `1`,
where `N` is the number of observations. This makes `cov(X)` the
best unbiased estimate of the covariance matrix if the observations
are from a normal distribution. For `N` = `1`, `cov` normalizes
by `N`.

`cov(X, 1)` or `cov(X, Y, 1)` normalizes
by `N` and produces the second moment matrix of the
observations about their mean. `cov(X, Y, 0)` is
the same as `cov(X, Y)` and `cov(X, 0)` is
the same as `cov(X)`. The mean is removed from each
column before calculating the result.

Was this topic helpful?