simulateNormalScenariosByData

Class: PortfolioMAD

Estimate mean and covariance of asset returns from data for PortfolioMAD object

Syntax

obj = simulateNormalScenariosByData(obj,AssetReturns,...
NumScenarios)
obj = simulateNormalScenariosByData(obj,AssetReturns,...
NumScenarios,varargin)

Description

obj = simulateNormalScenariosByData(obj,AssetReturns,...
NumScenarios)
to estimate mean and covariance of asset returns from data for a PortfolioMAD object.

obj = simulateNormalScenariosByData(obj,AssetReturns,...
NumScenarios,varargin)
to estimate mean and covariance of asset returns from data for a PortfolioMAD object using the optional input varagin with additional options specified by one or more Name,Value pair arguments.

This method estimates the mean and covariance of asset returns from either price or return data and then uses these estimates to generate the specified number of scenarios with the function mvnrnd.

Data can in be either a NumSamples-by-NumAssets matrix of NumSamples prices or returns at a given periodicity for a collection of NumAssets assets or a fints object with NumSamples observations and NumAssets time series.

    Note:   If you want to use the method multiple times and you want to simulate identical scenarios each time the function is called, precede each function call with rng(seed) using a specified integer seed.

Tips

You can also use dot notation to estimate mean and covariance of asset returns from data for a PortfolioMAD object.

obj = obj.simulateNormalScenariosByData(AssetReturns, NumScenarios, varargin);

Input Arguments

obj

A MAD portfolio object [PortfolioMAD].

AssetReturns

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

NumScenarios

Number of scenarios to simulate [positive integer].

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

DataFormat values are:

  • Returns — Data in AssetReturns are asset total returns.

  • Prices — Data in AssetReturns are asset total return prices.

Default: Returns

MissingData

MissingData values are:

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

  • true — Use ECM algorithm to handle NaN values.

Default: false

GetAssetList

GetAssetList values are:

  • false — Do not extract or create asset names.

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

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, nothing happens, which is the default.

Default: false

Output Arguments

obj

Updated MAD portfolio object [PortfolioMAD].

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

Given a PortfolioMAD object p, use the simulateNormalScenariosByData method to simulate multivariate normal asset return scenarios from data.

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;

RawData = mvnrnd(m, C, 240);
NumScenarios = 2000;

p = PortfolioMAD;
p = simulateNormalScenariosByData(p, RawData, NumScenarios);
p = setDefaultConstraints(p);

disp(p);
  PortfolioMAD with properties:

         BuyCost: []
        SellCost: []
    RiskFreeRate: []
        Turnover: []
     BuyTurnover: []
    SellTurnover: []
    NumScenarios: 2000
            Name: []
       NumAssets: 4
       AssetList: []
        InitPort: []
     AInequality: []
     bInequality: []
       AEquality: []
       bEquality: []
      LowerBound: [4x1 double]
      UpperBound: []
     LowerBudget: 1
     UpperBudget: 1
     GroupMatrix: []
      LowerGroup: []
      UpperGroup: []
          GroupA: []
          GroupB: []
      LowerRatio: []
      UpperRatio: []

Estimate Mean and Covariance of Asset Returns from Market Data

Create a PortfolioMAD object p and use the simulateNormalScenariosByData method with market data loaded from CAPMuniverse.mat to simulate multivariate normal asset return scenarios.

load CAPMuniverse

p = PortfolioMAD('AssetList',Assets(1:12));
disp(p);
  PortfolioMAD with properties:

         BuyCost: []
        SellCost: []
    RiskFreeRate: []
        Turnover: []
     BuyTurnover: []
    SellTurnover: []
    NumScenarios: []
            Name: []
       NumAssets: 12
       AssetList: {1x12 cell}
        InitPort: []
     AInequality: []
     bInequality: []
       AEquality: []
       bEquality: []
      LowerBound: []
      UpperBound: []
     LowerBudget: []
     UpperBudget: []
     GroupMatrix: []
      LowerGroup: []
      UpperGroup: []
          GroupA: []
          GroupB: []
      LowerRatio: []
      UpperRatio: []

Simulate the scenarios from the data for each of the 12 assets from CAPMuniverse.mat.

p = simulateNormalScenariosByData(p, Data(:,1:12), 20000 ,'missingdata',true);
Was this topic helpful?