ecmninit
Initial mean and covariance
Description
[
creates initial mean and covariance estimates for the function
Mean
,Covariance
] = ecmninit(Data
,InitMethod
)ecmnmle
.
[
adds an optional argument for Mean
,Covariance
] = ecmninit(___,InitMethod
)InitMethod
.
Examples
Compute Initial Mean and Covariance
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 NaN
s. 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
Data
— Data
matrix
Data, specified as an
NUMSAMPLES
-by-NUMSERIES
matrix with NUMSAMPLES
samples of
a NUMSERIES
-dimensional random
vector. Missing values are indicated by
NaN
s.
Data Types: double
InitMethod
— Initialization methods to compute initial estimates for mean and covariance of data
'nanskip'
(default) | character vector
(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 withNaN
s.'twostage'
— Estimate mean. FillNaN
s with the mean. Then estimate the covariance.'diagonal'
— Form a diagonal covariance.
Data Types: char
Output Arguments
Algorithms
Model
The general model is
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 NaN
s 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 NaN
s. 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
MATLAB Command
You clicked a link that corresponds to this MATLAB command:
Run the command by entering it in the MATLAB Command Window. Web browsers do not support MATLAB commands.
Select a Web Site
Choose a web site to get translated content where available and see local events and offers. Based on your location, we recommend that you select: .
You can also select a web site from the following list
How to Get Best Site Performance
Select the China site (in Chinese or English) for best site performance. Other MathWorks country sites are not optimized for visits from your location.
Americas
- América Latina (Español)
- Canada (English)
- United States (English)
Europe
- Belgium (English)
- Denmark (English)
- Deutschland (Deutsch)
- España (Español)
- Finland (English)
- France (Français)
- Ireland (English)
- Italia (Italiano)
- Luxembourg (English)
- Netherlands (English)
- Norway (English)
- Österreich (Deutsch)
- Portugal (English)
- Sweden (English)
- Switzerland
- United Kingdom (English)
Asia Pacific
- Australia (English)
- India (English)
- New Zealand (English)
- 中国
- 日本Japanese (日本語)
- 한국Korean (한국어)