This is machine translation

Translated by Microsoft
Mouseover text to see original. Click the button below to return to the English version of the page.

Note: This page has been translated by MathWorks. Click here to see
To view all translated materials including this page, select Country from the country navigator on the bottom of this page.

cov

Covariance matrix

cov will be removed in a future release. Use timetable instead. For more information, see Convert Financial Time Series Objects fints to Timetables.

Syntax

cov(X)
cov(X,Y)

Arguments

X

Financial times series object.

Y

Financial times series object.

Description

cov for financial time series objects is based on the MATLAB® cov function. See cov.

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.

Examples

collapse all

This example shows how to create a covariance matrix for the following dates.

dates = {'01-Jan-2007';'02-Jan-2007';'03-Jan-2007'};
A = [-1 1 2 ; -2 3 1 ; 4 0 3];
f = fints(dates, A);
Warning: FINTS will be removed in a future release. Use TIMETABLE instead. For more information, see <a href="matlab:web(fullfile(docroot, 'finance/convert-from-fints-to-timetables.html'))">Convert Financial Time Series Objects (fints) to Timetables</a>.
c = cov(f)
Warning: FINTS will be removed in a future release. Use TIMETABLE instead. For more information, see <a href="matlab:web(fullfile(docroot, 'finance/convert-from-fints-to-timetables.html'))">Convert Financial Time Series Objects (fints) to Timetables</a>.
c = 3×3

   10.3333   -4.1667    3.0000
   -4.1667    2.3333   -1.5000
    3.0000   -1.5000    1.0000

See Also

| | | |

Introduced before R2006a