Documentation Center

  • Trial Software
  • Product Updates

estimateAssetMoments

Class: Portfolio

Estimate mean and covariance of asset returns from data

Syntax

obj = estimateAssetMoments(obj,AssetReturns)
obj = estimateAssetMoments(obj,AssetReturns,varargin)

Description

obj = estimateAssetMoments(obj,AssetReturns) to estimate the mean and covariance of asset returns from data.

obj = estimateAssetMoments(obj,AssetReturns,varargin) to estimate mean and covariance of asset returns from data with additional options specified by one or more Name,Value pair arguments.

Tips

Use dot notation to estimate the mean and covariance of asset returns from data:

obj = obj.estimateAssetMoments(AssetReturns, varargin);

Input Arguments

obj

Portfolio object [Portfolio].

AssetReturns

Either a matrix or fints object that contains asset data that can be converted to asset returns [NumSamples-by-NumAssets matrix].

    Note:   This method estimates the mean and covariance of asset returns from either price or return data. Data can reside in a NumSamples-by-NumAssets matrix of NumSamples prices or returns. This matrix represents a given periodicity for a collection of NumAssets assets or a fints object with NumSamples observations and NumAssets time series.

Name-Value Pair Arguments

Specify optional comma-separated pairs of Name,Value arguments. Name is the argument name and Value is the corresponding value. Name must appear inside single quotes (' '). You can specify several name and value pair arguments in any order as Name1,Value1,...,NameN,ValueN.

'DataFormat'

If the input data are prices, these values can be converted into returns with the DataFormat flag, where the default format is assumed to be returns. Be careful using price data because portfolio optimization requires total returns and not simply price returns.

Acceptable values for DataFormat are:

  • 'Returns' — Data in AssetReturns contains asset total returns.

  • 'Prices' — Data in AssetReturns contains asset total return prices.

Default: 'Returns'

'MissingData'

To handle time series with missing data (indicated with NaN values), the MissingData flag either uses the ECM algorithm to obtain maximum likelihood estimates in the presences of NaN values or excludes samples with NaN values. Since the default is false, it is necessary to specify MissingData as true to use the ECM algorithm.

Acceptable values for MissingData are:

  • false — Do not use ECM algorithm to handle NaN values (just exclude NaN values).

  • true — Use ECM algorithm to handle NaN values.

For more information on the ECM algorithm, see ecmnmle and Multivariate Normal Regression.

Default: false

'GetAssetList'

If a fints object is passed into this method and the GetAssetList flag is true, the series names from the fints object are used as asset names in obj.AssetList.

If a matrix is passed and the GetAssetList flag is true, default asset names are created based on the AbstractPortfolio property defaultforAssetList, which is currently 'Asset'.

If the GetAssetList flag is false, no action occurs, which is the default behavior.

Acceptable values for GetAssetList are:

  • false — Do not extract or create asset names.

  • true — Extract or create asset names from fints object.

Default: false

Output Arguments

obj

Updated Portfolio object [Portfolio].

Attributes

Accesspublic
Staticfalse
Hiddenfalse

To learn about attributes of methods, see Method Attributes in the MATLAB® Object-Oriented Programming documentation.

Examples

expand all

Estimate Mean and Covariance of Asset Returns from Data

To illustrate using the estimateAssetMoments method, generate random samples of 120 observations of asset returns for four assets from the mean and covariance of asset returns in the variables m and C with the portsim function. The default behavior portsim creates simulated data with estimated mean and covariance identical to the input moments m and C. In addition to a return series created by the portsim function in the variable X, a price series is created in the variable Y:

m = [ 0.05; 0.1; 0.12; 0.18 ];
C = [ 0.0064 0.00408 0.00192 0;
      0.00408 0.0289 0.0204 0.0119;
      0.00192 0.0204 0.0576 0.0336;
      0 0.0119 0.0336 0.1225 ];
m = m/12;
C = C/12;
X = portsim(m', C, 120);
Y = ret2tick(X);

Given asset returns and prices in the variables X and Y from above, the following examples demonstrate equivalent ways to estimate asset moments for the Portfolio object. A Portfolio object is created in p with the moments of asset returns set directly in the constructor and a second Portfolio object is created in q to obtain the mean and covariance of asset returns from asset return data in X using the estimateAssetMoments method.

m = [ 0.05; 0.1; 0.12; 0.18 ];
C = [ 0.0064 0.00408 0.00192 0;
      0.00408 0.0289 0.0204 0.0119;
      0.00192 0.0204 0.0576 0.0336;
      0 0.0119 0.0336 0.1225 ];
m = m/12;
C = C/12;

X = portsim(m', C, 120);
p = Portfolio('mean',m,'covar',C);
q = Portfolio;
q = q.estimateAssetMoments(X);

[passetmean, passetcovar] = p.getAssetMoments
[qassetmean, qassetcovar] = q.getAssetMoments
passetmean =

    0.0042
    0.0083
    0.0100
    0.0150


passetcovar =

    0.0005    0.0003    0.0002         0
    0.0003    0.0024    0.0017    0.0010
    0.0002    0.0017    0.0048    0.0028
         0    0.0010    0.0028    0.0102


qassetmean =

    0.0042
    0.0083
    0.0100
    0.0150


qassetcovar =

    0.0005    0.0003    0.0002    0.0000
    0.0003    0.0024    0.0017    0.0010
    0.0002    0.0017    0.0048    0.0028
    0.0000    0.0010    0.0028    0.0102

Notice how either approach yields the same moments. The default behavior of the estimateAssetMoments method is to work with asset returns. If, instead, you have asset prices, such as in the variable Y, the estimateAssetMoments method accepts a parameter name 'DataFormat' with a corresponding value set to 'prices' to indicate that the input to the method is in the form of asset prices and not returns (the default parameter value for 'DataFormat' is 'returns'). The following example compares direct assignment of moments in the Portfolio object p with estimated moments from asset price data in Y in the Portfolio object q:

m = [ 0.05; 0.1; 0.12; 0.18 ];
C = [ 0.0064 0.00408 0.00192 0;
      0.00408 0.0289 0.0204 0.0119;
      0.00192 0.0204 0.0576 0.0336;
      0 0.0119 0.0336 0.1225 ];
m = m/12;
C = C/12;

X = portsim(m', C, 120);
Y = ret2tick(X);

p = Portfolio('mean',m,'covar',C);

q = Portfolio;
q = q.estimateAssetMoments(Y, 'dataformat', 'prices');

[passetmean, passetcovar] = p.getAssetMoments
[qassetmean, qassetcovar] = q.getAssetMoments
passetmean =

    0.0042
    0.0083
    0.0100
    0.0150


passetcovar =

    0.0005    0.0003    0.0002         0
    0.0003    0.0024    0.0017    0.0010
    0.0002    0.0017    0.0048    0.0028
         0    0.0010    0.0028    0.0102


qassetmean =

    0.0042
    0.0083
    0.0100
    0.0150


qassetcovar =

    0.0005    0.0003    0.0002    0.0000
    0.0003    0.0024    0.0017    0.0010
    0.0002    0.0017    0.0048    0.0028
    0.0000    0.0010    0.0028    0.0102

See Also

| |

More About

Was this topic helpful?