This example shows how to compute the standard errors for mean and covariance of incomplete data for five years of daily total return data for 12 computer technology stocks, with six hardware and six software companies
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.
ECMMean = 12×1
0.0008
0.0008
-0.0005
0.0002
0.0011
0.0038
-0.0003
-0.0000
-0.0003
-0.0000
-0.0003
0.0004
⋮
ECMCovar = 12×12
0.0012 0.0005 0.0006 0.0005 0.0005 0.0003 0.0005 0.0003 0.0006 0.0003 0.0005 0.0006
0.0005 0.0024 0.0007 0.0006 0.0010 0.0004 0.0005 0.0003 0.0006 0.0004 0.0006 0.0012
0.0006 0.0007 0.0013 0.0007 0.0007 0.0003 0.0006 0.0004 0.0008 0.0005 0.0008 0.0008
0.0005 0.0006 0.0007 0.0009 0.0006 0.0002 0.0005 0.0003 0.0007 0.0004 0.0005 0.0007
0.0005 0.0010 0.0007 0.0006 0.0016 0.0006 0.0005 0.0003 0.0006 0.0004 0.0007 0.0011
0.0003 0.0004 0.0003 0.0002 0.0006 0.0022 0.0001 0.0002 0.0002 0.0001 0.0003 0.0016
0.0005 0.0005 0.0006 0.0005 0.0005 0.0001 0.0009 0.0003 0.0005 0.0004 0.0005 0.0006
0.0003 0.0003 0.0004 0.0003 0.0003 0.0002 0.0003 0.0005 0.0004 0.0003 0.0004 0.0004
0.0006 0.0006 0.0008 0.0007 0.0006 0.0002 0.0005 0.0004 0.0011 0.0005 0.0007 0.0007
0.0003 0.0004 0.0005 0.0004 0.0004 0.0001 0.0004 0.0003 0.0005 0.0006 0.0004 0.0005
0.0005 0.0006 0.0008 0.0005 0.0007 0.0003 0.0005 0.0004 0.0007 0.0004 0.0013 0.0007
0.0006 0.0012 0.0008 0.0007 0.0011 0.0016 0.0006 0.0004 0.0007 0.0005 0.0007 0.0020
⋮
To evaluate the impact of the estimation error and, in particular, the effect of missing data, use ecmnstd
to calculate standard errors. Although it is possible to estimate the standard errors for both the mean and covariance, the standard errors for the mean estimates alone are usually the main quantities of interest.
StdMeanF = 12×1
0.0010
0.0014
0.0010
0.0009
0.0011
0.0013
0.0009
0.0006
0.0009
0.0007
0.0010
0.0012
⋮
Calculate standard errors that use the data-generated Hessian matrix (which accounts for the possible loss of information due to missing data) with the option 'hessian'
.
StdMeanH = 12×1
0.0010
0.0014
0.0010
0.0009
0.0011
0.0021
0.0009
0.0006
0.0009
0.0007
0.0010
0.0012
⋮
The difference in the standard errors shows the increase in uncertainty of estimation of asset expected returns due to missing data. To view the differences:
Assets = 1×12 cell
{'AAPL'} {'AMZN'} {'CSCO'} {'DELL'} {'EBAY'} {'GOOG'} {'HPQ'} {'IBM'} {'INTC'} {'MSFT'} {'ORCL'} {'YHOO'}
ans = 1×12
0.0010 0.0014 0.0010 0.0009 0.0011 0.0021 0.0009 0.0006 0.0009 0.0007 0.0010 0.0012
ans = 1×12
0.0010 0.0014 0.0010 0.0009 0.0011 0.0013 0.0009 0.0006 0.0009 0.0007 0.0010 0.0012
ans = 1×12
10-3 ×
-0.0000 0.0021 -0.0000 -0.0000 -0.0000 0.7742 -0.0000 -0.0000 -0.0000 -0.0000 -0.0000 -0.0000
The two assets with missing data, AMZN and GOOG, are the only assets to have differences due to missing information.