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
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.matThe 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
0.0009
0.0010
⋮
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
0.0889 0.1252 0.0808 0.0499 0.1155 0.0069 0.0406 0.0494 0.1102 0.0583 0.3239 0.0951
0.1219 0.2317 0.1014 0.0528 0.2515 0.2788 0.0621 0.0548 0.1094 0.0472 0.0951 0.3203
⋮
Input Arguments
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 withNaNs.'twostage'— Estimate mean. FillNaNs with the mean. Then estimate the covariance.'diagonal'— Form a diagonal covariance.
Data Types: char
Output Arguments
Algorithms
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).
This routine has three initialization methods that cover most cases, each with its advantages and disadvantages.
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.
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.
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.
Seleziona un sito web
Seleziona un sito web per visualizzare contenuto tradotto dove disponibile e vedere eventi e offerte locali. In base alla tua area geografica, ti consigliamo di selezionare: .
Puoi anche selezionare un sito web dal seguente elenco:
Come ottenere le migliori prestazioni del sito
Per ottenere le migliori prestazioni del sito, seleziona il sito cinese (in cinese o in inglese). I siti MathWorks per gli altri paesi non sono ottimizzati per essere visitati dalla tua area geografica.
Americhe
- América Latina (Español)
- Canada (English)
- United States (English)
Europa
- 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)