Documentation

This is machine translation

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

Note: This page has been translated by MathWorks. Please click here
To view all translated materals including this page, select Japan from the country navigator on the bottom of this page.

nanvar

Variance ignoring NaNs

Syntax

y = nanvar(X)
y = nanvar(X,1)
y = nanvar(X,W)
y = nanvar(X,W,DIM)

Arguments

X

Financial times series object.

W

Weight vector.

DIM

Dimension along which the operation is conducted.

Description

nanvar for financial times series objects is based on the Statistics and Machine Learning Toolbox™ function nanvar. See nanvar in the Statistics and Machine Learning Toolbox documentation.

y = nanvar(X) returns the sample variance of the values in a financial time series object X, treating NaNs as missing values. y is the variance of the non-NaN elements of each series in X.

nanvar normalizes y by N1 if N > 1, where N is the sample size of the non-NaN elements. This is an unbiased estimator of the variance of the population from which X is drawn, as long as X consists of independent, identically distributed samples, and data are missing at random. For N = 1, y is normalized by N.

y = nanvar(X,1) normalizes by N and produces the second moment of the sample about its mean. nanvar(X, 0) is the same as nanvar(X).

y = nanvar(X,W) computes the variance using the weight vector W. The length of W must equal the length of the dimension over which nanvar operates, and its non-NaN elements must be nonnegative. Elements of X corresponding to NaN elements of Ware ignored.

y = nanvar(X,W,DIM) takes the variance along dimension DIM of X.

Examples

To compute nanvar:

f = fints((today:today+1)', [4 -2 1; 9  5 7])
f.series1(1) = nan;
f.series3(2) = nan;

nvar = nanvar(f)
nvar =
         0   24.5000         0

Related Examples

See Also

| | | | |

Introduced before R2006a

Was this topic helpful?