Main Content

getAssetMoments

Obtain mean and covariance of asset returns from Portfolio object

Description

Use the getAssetMoments function with a Portfolio object to obtain mean and covariance of asset returns.

For details on the workflow, see Portfolio Object Workflow.

[AssetMean,AssetCovar] = getAssetMoments(obj) obtains mean and covariance of asset returns for a Portfolio object.

example

Examples

collapse all

Given the mean and covariance of asset returns in the variables m and C, the asset moment properties can be set and then obtained using the getAssetMoments function:

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;
 
p = Portfolio;
p = setAssetMoments(p, m, C);
[assetmean, assetcovar] = getAssetMoments(p)
assetmean = 4×1

    0.0042
    0.0083
    0.0100
    0.0150

assetcovar = 4×4

    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

Input Arguments

collapse all

Object for portfolio, specified using a Portfolio object. For more information on creating a portfolio object, see

Data Types: object

Output Arguments

collapse all

Mean of asset returns, returned as a vector.

Covariance of asset returns, returned as a matrix.

Tips

You can also use dot notation to obtain the mean and covariance of asset returns from a Portfolio object:

[AssetMean, AssetCovar] = obj.getAssetMoments;

Version History

Introduced in R2011a