Main Content

ecmninit

Initial mean and covariance

Description

[Mean,Covariance] = ecmninit(Data,InitMethod) creates initial mean and covariance estimates for the function ecmnmle.

example

[Mean,Covariance] = ecmninit(___,InitMethod) adds an optional argument for InitMethod.

example

Examples

collapse all

This example shows how to compute the initial mean and covariance for five years of daily total return data for 12 computer technology stocks, with six hardware and six software companies

load ecmtechdemo.mat

The time period for this data extends from April 19, 2000 to April 18, 2005. The sixth stock in Assets is Google (GOOG), which started trading on August 19, 2004. So, all returns before August 20, 2004 are missing and represented as NaNs. Also, Amazon (AMZN) had a few days with missing values scattered throughout the past five years.

A naïve approach to the estimation of the mean and covariance for these 12 assets is to eliminate all days that have missing values for any of the 12 assets. Use the ecminit function with the 'nanskip' option to do this.

[NaNMean, NaNCovar] = ecmninit(Data,'nanskip')
NaNMean = 12×1

    0.0054
   -0.0006
   -0.0006
    0.0002
   -0.0009
    0.0042
    0.0011
   -0.0005
    0.0002
    0.0001
      ⋮

NaNCovar = 12×12
10-3 ×

    0.7271    0.1003    0.0755    0.0585    0.1363    0.1030    0.0084    0.0741    0.0808    0.0407    0.0889    0.1219
    0.1003    0.5958    0.1293    0.0919    0.2700    0.0554    0.0668    0.0548    0.1223    0.0724    0.1252    0.2317
    0.0755    0.1293    0.2480    0.0841    0.0680    0.0322    0.0721    0.0632    0.1360    0.0562    0.0808    0.1014
    0.0585    0.0919    0.0841    0.1414    0.0656   -0.0010    0.0386    0.0460    0.0617    0.0331    0.0499    0.0528
    0.1363    0.2700    0.0680    0.0656    0.6223    0.2062    0.0797    0.0515    0.0850    0.0436    0.1155    0.2515
    0.1030    0.0554    0.0322   -0.0010    0.2062    0.8376   -0.0103    0.0345    0.0236   -0.0034    0.0069    0.2788
    0.0084    0.0668    0.0721    0.0386    0.0797   -0.0103    0.2462    0.0414    0.0881    0.0268    0.0406    0.0621
    0.0741    0.0548    0.0632    0.0460    0.0515    0.0345    0.0414    0.1011    0.0561    0.0321    0.0494    0.0548
    0.0808    0.1223    0.1360    0.0617    0.0850    0.0236    0.0881    0.0561    0.2642    0.0647    0.1102    0.1094
    0.0407    0.0724    0.0562    0.0331    0.0436   -0.0034    0.0268    0.0321    0.0647    0.0619    0.0583    0.0472
      ⋮

Input Arguments

collapse all

Data, specified as an NUMSAMPLES-by-NUMSERIES matrix with NUMSAMPLES samples of a NUMSERIES-dimensional random vector. Missing values are indicated by NaNs.

Data Types: double

(Optional) Initialization methods to compute the initial estimates for the mean and covariance of data, specified as a character vector. The initialization methods are:

  • 'nanskip' — Skip all records with NaNs.

  • 'twostage' — Estimate mean. Fill NaNs with the mean. Then estimate the covariance.

  • 'diagonal' — Form a diagonal covariance.

Data Types: char

Output Arguments

collapse all

Initial estimate of the mean of the Data, returned as a NUMSERIES-by-1 column vector.

Initial estimate of covariance of the Data, returned as a NUMSERIES-by-NUMSERIES matrix.

Algorithms

collapse all

Model

The general model is

ZN(Mean,Covariance),

where each row of Data is an observation of Z.

Each observation of Z is assumed to be iid (independent, identically distributed) multivariate normal, and missing values are assumed to be missing at random (MAR).

Initialization Methods

This routine has three initialization methods that cover most cases, each with its advantages and disadvantages.

nanskip

The nanskip method works well with small problems (fewer than 10 series or with monotone missing data patterns). It skips over any records with NaNs and estimates initial values from complete-data records only. This initialization method tends to yield fastest convergence of the ECM algorithm. This routine switches to the twostage method if it determines that significant numbers of records contain NaN.

twostage

The twostage method is the best choice for large problems (more than 10 series). It estimates the mean for each series using all available data for each series. It then estimates the covariance matrix with missing values treated as equal to the mean rather than as NaNs. This initialization method is robust but tends to result in slower convergence of the ECM algorithm.

diagonal

The diagonal method is a worst-case approach that deals with problematic data, such as disjoint series and excessive missing data (more than 33% missing data). Of the three initialization methods, this method causes the slowest convergence of the ECM algorithm.

Version History

Introduced before R2006a