Documentation

This is machine translation

Translated by Microsoft
Mouseover text to see original. Click the button below to return to the English verison of the page.

Note: This page has been translated by MathWorks. Please click here
To view all translated materals including this page, select Japan from the country navigator on the bottom of this page.

simulateNormalScenariosByData

Simulate multivariate normal asset return scenarios from data

Use the simulateNormalScenariosByData function with a PortfolioCVaR or PortfolioMAD objects to simulate multivariate normal asset return scenarios from data.

For details on the workflows, see PortfolioCVaR Object Workflow, and PortfolioMAD Object Workflow.

Syntax

obj = simulateNormalScenariosByData(obj,AssetReturns)
obj = simulateNormalScenariosByData(obj,AssetReturns,NumScenarios,Name,Value)

Description

example

obj = simulateNormalScenariosByData(obj,AssetReturns) simulates multivariate normal asset return scenarios from data for portfolio object for PortfolioCVaR or PortfolioMAD objects.

example

obj = simulateNormalScenariosByData(obj,AssetReturns,NumScenarios,Name,Value) simulates multivariate normal asset return scenarios from data for portfolio object for PortfolioCVaR or PortfolioMAD objects using additional options specified by one or more Name,Value pair arguments.

This function 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.

Examples

collapse all

Given a PortfolioCVaR object p, use the simulateNormalScenariosByData function 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 = PortfolioCVaR;
p = simulateNormalScenariosByData(p, RawData, NumScenarios)
p = 
  PortfolioCVaR with properties:

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

p = setDefaultConstraints(p);
p = setProbabilityLevel(p, 0.9);

disp(p);
  PortfolioCVaR with properties:

             BuyCost: []
            SellCost: []
        RiskFreeRate: []
    ProbabilityLevel: 0.9000
            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: []

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

load CAPMuniverse

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

             BuyCost: []
            SellCost: []
        RiskFreeRate: []
    ProbabilityLevel: []
            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);

Given a PortfolioMAD object p, use the simulateNormalScenariosByData function 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: []

Create a PortfolioMAD object p and use the simulateNormalScenariosByData function 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);

Input Arguments

collapse all

Object for portfolio, specified using a PortfolioCVaR or PortfolioMAD object.

For more information on creating a PortfolioCVaR or PortfolioMAD object, see

Asset data that can be converted into asset returns, specified as a fints object or NumSamples-by-NumAssets matrix

Data Types: double

Number of scenarios to simulate, specified as a positive integer.

Data Types: double

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.

Example: p = simulateNormalScenariosByData(p,RawData,NumScenarios,'DataFormat','Returns','MissingData',true,'GetAssetList',true)

collapse all

Flag to convert input data as prices into returns, specified using a character vector with the values:

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

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

Data Types: char

Flag to use ECM algorithm to handle NaN values, as a logical with a value of true or false.

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

  • true — Use ECM algorithm to handle NaN values.

Data Types: logical

Flag indicating which asset names to use for the asset list, specified as a logical with a value of true or false.

  • 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 function 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 'Asset'.

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

Data Types: logical

Output Arguments

collapse all

Updated portfolio object, returned as a PortfolioCVaR or PortfolioMAD object. For more information on creating a portfolio object, see

Tips

You can also use dot notation to simulate multivariate normal asset return scenarios from data for a PortfolioCVaR or PortfolioMAD object.

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

Introduced in R2012b

Was this topic helpful?