<< nan_corrcov Data Correlation and Covariance nan_covm >>

NaN Toolbox >> NaN Toolbox > Data Correlation and Covariance > nan_cov

nan_cov

calculates covariance matrix

Calling Sequence

C = nan_cov(X [,Mode]);
C = nan_cov(X,Y [,Mode]);

Parameters

C :

correlation matrix

Mode = 0:

[default] scales C by (N-1)

Mode = 1:

scales C by N.

Description

X and Y can contain missing values encoded with NaN. NaN's are skipped, NaN do not result in a NaN output. The output gives NaN only if there are insufficient input data The mean is removed from the data.

C = nan_cov(X [,Mode]); calculates the (auto-)correlation matrix of X

C = nan_cov(X,Y [,Mode]); calculates the crosscorrelation between X and Y. C(i,j) is the correlation between the i-th and jth column of X and Y, respectively.

NOTE: Octave and Matlab have (in some special cases) incompatible implemenations. This implementation follows Octave. If the result could be ambigous or incompatible, a warning will be presented in Matlab. To avoid this warning use: a) use COV([X(:),Y(:)]) if you want the traditional Matlab result. b) use C = COV([X,Y]), C = C(1:size(X,2),size(X,2)+1:size(C,2)); if you want to be compatible with this software.

See also

Bibliography

http://mathworld.wolfram.com/Covariance.html

Authors

<< nan_corrcov Data Correlation and Covariance nan_covm >>