Set moments (mean and covariance) of asset returns for Portfolio object
Portfolio object to set moments (mean and
covariance) of asset returns.
For details on the workflow, see Portfolio Object Workflow.
obj = setAssetMoments(obj,AssetMean)
obj = setAssetMoments(obj,AssetMean,AssetCovar,NumAssets)
Set the asset moment properties, given the mean and covariance of asset returns in the variables
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 = 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
obj— Object for portfolio
Object for portfolio, specified using a
For more information on creating a portfolio object, see
AssetMean— Mean of asset returns
Mean of asset returns, specified as a vector.
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
AssetCovar— Covariance of asset returns
Covariance of asset returns, specified as a symmetric positive-semidefinite matrix.
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
AssetCovar is a vector, a diagonal matrix
is formed with the vector along the diagonal.