Accelerating the pace of engineering and science

# Documentation Center

• Trial Software

# setAssetMoments

Class: Portfolio

Set moments (mean and covariance) of asset returns

## Syntax

obj = setAssetMoments(obj,AssetMean)
obj = setAssetMoments(obj,AssetMean,AssetCovar,NumAssets)

## Description

obj = setAssetMoments(obj,AssetMean) sets the mean of asset returns.

obj = setAssetMoments(obj,AssetMean,AssetCovar,NumAssets) sets moments (mean and covariance) of the asset returns with additional options for AssetCovar and NumAssets.

## Tips

• Use dot notation to set moments (mean and covariance) of the asset returns.

`obj = obj.setAssetMoments(obj, AssetMean, AssetCovar, NumAssets);`
• To clear AssetMean and AssetCovar, use this method to set these respective inputs to [].

## Input Arguments

obj

Portfolio object [Portfolio].

AssetMean

Mean of asset returns [vector].

 Note:   If AssetMean is a scalar and the number of assets is known, scalar expansion occurs. If the number of assets cannot be determined, this method assumes that NumAssets = 1.

AssetCovar

(Optional) Covariance of asset returns [matrix].

 Note:   AssetCovar must be a symmetric positive-semidefinite matrix. If AssetCovar is a scalar and the number of assets is known, a diagonal matrix is formed with the scalar value along the diagonals. If it is not possible to determine the number of assets, this method assumes that NumAssets = 1. If AssetCovar is a vector, a diagonal matrix is formed with the vector along the diagonal.

NumAssets

(Optional) Number of assets [integer].

 Note:   If NumAssets is not already set in the object, NumAssets can be entered to resolve array expansions with AssetMean or AssetCovar.

## Output Arguments

 obj Updated Portfolio object [Portfolio].

## Attributes

 Access public Static false Hidden false

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

## Examples

expand all

### Set Asset Moments

Set the asset moment properties, given the mean and covariance of asset returns in the variables m and C.

```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 = p.setAssetMoments(m, C);
[assetmean, assetcovar] = p.getAssetMoments
```
```assetmean =

0.0042
0.0083
0.0100
0.0150

assetcovar =

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

```