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.

Portfolios with Missing Data

This example illustrates how to use the missing data algorithms for portfolio optimization and for valuation. This example works with five years of daily total return data for 12 computer technology stocks, with 6 hardware and 6 software companies. The example estimates the mean and covariance matrix for these stocks, forms efficient frontiers with both a naïve approach and the ECM approach, and compares results.

You can run the example directly with ecmtechdemo.m.

  1. Load the following data file:

    load ecmtechdemo
    

    This file contains these three quantities:

    • Assets is a cell array of the tickers for the 12 stocks in the example.

    • Data is a 1254-by-12 matrix of 1254 daily total returns for each of the 12 stocks.

    • Dates is a 1254-by-1 column vector of the dates associated with the data.

    The time period for the 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.

  2. 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 function ecmninit with the nanskip option to do this.

    [NaNMean, NaNCovar] = ecmninit(Data,'nanskip');
    
  3. Contrast the result of this approach with using all available data and the function ecmnmle to compute the mean and covariance. First, call ecmnmle with no output arguments to establish that enough data is available to obtain meaningful estimates.

    ecmnmle(Data);
    

    The following figure shows that, even with almost 87% of the Google data being NaN values, the algorithm converges after only four iterations.

  4. Estimate the mean and covariance as computed by ecmnmle.

    [ECMMean, ECMCovar] = ecmnmle(Data)
    ECMMean =
    
        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 =
    
        0.0012    0.0005    0.0006    0.0005    0.0005    0.0003
        0.0005    0.0024    0.0007    0.0006    0.0010    0.0004
        0.0006    0.0007    0.0013    0.0007    0.0007    0.0003
        0.0005    0.0006    0.0007    0.0009    0.0006    0.0002
        0.0005    0.0010    0.0007    0.0006    0.0016    0.0006
        0.0003    0.0004    0.0003    0.0002    0.0006    0.0022
        0.0005    0.0005    0.0006    0.0005    0.0005    0.0001
        0.0003    0.0003    0.0004    0.0003    0.0003    0.0002
        0.0006    0.0006    0.0008    0.0007    0.0006    0.0002
        0.0003    0.0004    0.0005    0.0004    0.0004    0.0001
        0.0005    0.0006    0.0008    0.0005    0.0007    0.0003
        0.0006    0.0012    0.0008    0.0007    0.0011    0.0016
    
    ECMCovar (continued)
    
        0.0005    0.0003    0.0006    0.0003    0.0005    0.0006
        0.0005    0.0003    0.0006    0.0004    0.0006    0.0012
        0.0006    0.0004    0.0008    0.0005    0.0008    0.0008
        0.0005    0.0003    0.0007    0.0004    0.0005    0.0007
        0.0005    0.0003    0.0006    0.0004    0.0007    0.0011
        0.0001    0.0002    0.0002    0.0001    0.0003    0.0016
        0.0009    0.0003    0.0005    0.0004    0.0005    0.0006
        0.0003    0.0005    0.0004    0.0003    0.0004    0.0004
        0.0005    0.0004    0.0011    0.0005    0.0007    0.0007
        0.0004    0.0003    0.0005    0.0006    0.0004    0.0005
        0.0005    0.0004    0.0007    0.0004    0.0013    0.0007
        0.0006    0.0004    0.0007    0.0005    0.0007    0.0020
    
  5. Given estimates for the mean and covariance of asset returns derived from the naïve and ECM approaches, estimate portfolios, and associated expected returns and risks on the efficient frontier for both approaches.

    [ECMRisk, ECMReturn, ECMWts] = portopt(ECMMean',ECMCovar,10);
    [NaNRisk, NaNReturn, NaNWts] = portopt(NaNMean',NaNCovar,10);
    
  6. Plot the results on the same graph to illustrate the differences.

    figure(gcf)
    plot(ECMRisk,ECMReturn,'-bo','MarkerFaceColor','b','MarkerSize', 3);
    hold on
    plot(NaNRisk,NaNReturn,'-ro','MarkerFaceColor','r','MarkerSize', 3);
    title('\bfEfficient Frontiers under Various Assumptions');
    legend('ECM','NaN','Location','SouthEast');
    xlabel('\bfStd. Dev. of Returns');
    ylabel('\bfMean of Returns');
    hold off
    

  7. Clearly, the naïve approach is optimistic about the risk-return trade-offs for this universe of 12 technology stocks. The proof, however, lies in the portfolio weights. To view the weights, enter

    Assets
    ECMWts
    NaNWts
    

    which generates

    >> Assets
    
    ans = 
    
        'AAPL'    'AMZN'    'CSCO'    'DELL'    'EBAY'    'GOOG'
    
    >> ECMWts
    
    ans =
    
        0.0358    0.0011   -0.0000    0.0000    0.0000    0.0989
        0.0654    0.0110    0.0000    0.0000    0.0000    0.1877
        0.0923    0.0194    0.0000    0.0000    0.0000    0.2784
        0.1165    0.0264    0.0000   -0.0000    0.0000    0.3712
        0.1407    0.0334   -0.0000         0    0.0000    0.4639
        0.1648    0.0403    0.0000         0   -0.0000    0.5566
        0.1755    0.0457    0.0000   -0.0000   -0.0000    0.6532
        0.1845    0.0509    0.0000    0.0000   -0.0000    0.7502
        0.1093    0.0174   -0.0000    0.0000         0    0.8733
             0         0   -0.0000    0.0000         0    1.0000
    
    >> NaNWts
    
    ans =
    
       -0.0000    0.0000   -0.0000    0.1185    0.0000    0.0522
        0.0576   -0.0000   -0.0000    0.1219    0.0000    0.0854
        0.1248   -0.0000   -0.0000    0.0952   -0.0000    0.1195
        0.1969   -0.0000   -0.0000    0.0529   -0.0000    0.1551
        0.2690   -0.0000   -0.0000    0.0105    0.0000    0.1906
        0.3414    0.0000   -0.0000   -0.0000   -0.0000    0.2265
        0.4235    0.0000   -0.0000   -0.0000   -0.0000    0.2639
        0.5245    0.0000   -0.0000   -0.0000   -0.0000    0.3034
        0.6269   -0.0000   -0.0000   -0.0000   -0.0000    0.3425
        1.0000   -0.0000   -0.0000    0.0000   -0.0000         0
    
    Assets (continued)
    
        'HPQ'    'IBM'    'INTC'    'MSFT'    'ORCL'    'YHOO'
    
    ECMWts (continued)
    
        0.0535    0.4676    0.0000    0.3431   -0.0000    0.0000
        0.0179    0.3899   -0.0000    0.3282    0.0000   -0.0000
             0    0.3025   -0.0000    0.3074    0.0000   -0.0000
        0.0000    0.2054   -0.0000    0.2806    0.0000    0.0000
        0.0000    0.1083   -0.0000    0.2538   -0.0000    0.0000
        0.0000    0.0111   -0.0000    0.2271   -0.0000    0.0000
        0.0000    0.0000   -0.0000    0.1255   -0.0000    0.0000
        0.0000         0   -0.0000    0.0143   -0.0000   -0.0000
        0.0000   -0.0000   -0.0000   -0.0000   -0.0000    0.0000
        0.0000   -0.0000   -0.0000   -0.0000   -0.0000    0.0000
    
    NaNWts (continued)
    
        0.0824    0.1779    0.0000    0.5691   -0.0000    0.0000
        0.1274    0.0460    0.0000    0.5617   -0.0000   -0.0000
        0.1674   -0.0000    0.0000    0.4802    0.0129   -0.0000
        0.2056   -0.0000    0.0000    0.3621    0.0274   -0.0000
        0.2438   -0.0000    0.0000    0.2441    0.0419   -0.0000
        0.2782   -0.0000    0.0000    0.0988    0.0551   -0.0000
        0.2788   -0.0000    0.0000   -0.0000    0.0337   -0.0000
        0.1721   -0.0000    0.0000   -0.0000   -0.0000   -0.0000
        0.0306   -0.0000    0.0000    0.0000         0   -0.0000
             0    0.0000    0.0000   -0.0000   -0.0000   -0.0000
    

    The naïve portfolios in NaNWts tend to favor Apple Computer (AAPL), which happened to do well over the period from the Google IPO to the end of the estimation period, while the ECM portfolios in ECMWts tend to underweight Apple Computer and to recommend increased weights in Google relative to the naïve weights.

  8. To evaluate the impact of 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 = ecmnstd(Data,ECMMean,ECMCovar,'fisher');
    
  9. 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 = ecmnstd(Data,ECMMean,ECMCovar,'hessian');
    

    The difference in the standard errors shows the increase in uncertainty of estimation of asset expected returns due to missing data. This can be viewed by entering:

    Assets
    StdMeanH'
    StdMeanF'
    StdMeanH' - StdMeanF'
    

    The two assets with missing data, AMZN and GOOG, are the only assets to have differences due to missing information.

See Also

| | | | | | | | | | | | | | | | | |

Related Topics

Was this topic helpful?