# Documentation

### This is machine translation

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

Add group ratio constraints for portfolio weights to existing group ratio constraints

Use the addGroupratio function with a Portfolio, PortfolioCVaR, or PortfolioMAD object to add group ratio constraints for portfolio weights to existing group ratio constraints.

For details on the respective workflows when using these different objects, see Portfolio Object Workflow, PortfolioCVaR Object Workflow, and PortfolioMAD Object Workflow.

## Description

example

obj = addGroupRatio(obj,GroupA,GroupB,LowerRatio) adds group ratio constraints for portfolio weights to existing group ratio constraints.

Given base and comparison group matrices GroupA and GroupB and, either LowerRatio, or UpperRatio bounds, group ratio constraints require any portfolio in Port to satisfy the following:

(GroupB * Port) .* LowerRatio <= GroupA * Port <= (GroupB * Port) .* UpperRatio

### Note

This collection of constraints usually requires that portfolio weights be nonnegative and that the products GroupA * Port and GroupB * Port are always nonnegative. Although negative portfolio weights and non-Boolean group ratio matrices are supported, use with caution.

example

obj = addGroupRatio(obj,GroupA,GroupB,LowerRatio,UpperRatio) adds group ratio constraints for portfolio weights to existing group ratio constraints with an additional option for UpperRatio.

Given base and comparison group matrices GroupA and GroupB and, either LowerRatio, or UpperRatio bounds, group ratio constraints require any portfolio in Port to satisfy the following:

(GroupB * Port) .* LowerRatio <= GroupA * Port <= (GroupB * Port) .* UpperRatio

### Note

This collection of constraints usually requires that portfolio weights be nonnegative and that the products GroupA * Port and GroupB * Port are always nonnegative. Although negative portfolio weights and non-Boolean group ratio matrices are supported, use with caution.

## Examples

collapse all

Set a group ratio constraint to ensure that the weight in financial assets does not exceed 50% of the weight in nonfinancial assets. Then add another group ratio constraint to ensure that the weight in financial assets constitute at least 20% of the weight in nonfinancial assets of the portfolio.

p = Portfolio;
GA = [ true true true false false false ];    % financial companies
GB = [ false false false true true true ];    % nonfinancial companies
p = setGroupRatio(p, GA, GB, [], 0.5);

GA = [ true false true false true false ];    % odd-numbered companies
GB = [ false false false true true true ];    % nonfinancial companies
p = addGroupRatio(p, GA, GB, 0.2);

disp(p.NumAssets);
6
disp(p.GroupA);
1     1     1     0     0     0
1     0     1     0     1     0
disp(p.GroupB);
0     0     0     1     1     1
0     0     0     1     1     1
disp(p.LowerRatio);
-Inf
0.2000
disp(p.UpperRatio);
0.5000
Inf

Set a group ratio constraint to ensure that the weight in financial assets does not exceed 50% of the weight in nonfinancial assets. Then add another group ratio constraint to ensure that the weight in financial assets constitute at least 20% of the weight in nonfinancial assets of the portfolio.

p = PortfolioCVaR;
GA = [ true true true false false false ];    % financial companies
GB = [ false false false true true true ];    % nonfinancial companies
p = setGroupRatio(p, GA, GB, [], 0.5);

GA = [ true false true false true false ];    % odd-numbered companies
GB = [ false false false true true true ];    % nonfinancial companies
p = addGroupRatio(p, GA, GB, 0.2);

disp(p.NumAssets);
6
disp(p.GroupA);
1     1     1     0     0     0
1     0     1     0     1     0
disp(p.GroupB);
0     0     0     1     1     1
0     0     0     1     1     1
disp(p.LowerRatio);
-Inf
0.2000
disp(p.UpperRatio);
0.5000
Inf

Set a group ratio constraint to ensure that the weight in financial assets does not exceed 50% of the weight in nonfinancial assets. Then add another group ratio constraint to ensure that the weight in financial assets constitute at least 20% of the weight in nonfinancial assets of the portfolio.

GA = [ true true true false false false ];    % financial companies
GB = [ false false false true true true ];    % nonfinancial companies
p = setGroupRatio(p, GA, GB, [], 0.5);

GA = [ true false true false true false ];    % odd-numbered companies
GB = [ false false false true true true ];    % nonfinancial companies
p = addGroupRatio(p, GA, GB, 0.2);

disp(p.NumAssets);
6
disp(p.GroupA);
1     1     1     0     0     0
1     0     1     0     1     0
disp(p.GroupB);
0     0     0     1     1     1
0     0     0     1     1     1
disp(p.LowerRatio);
-Inf
0.2000
disp(p.UpperRatio);
0.5000
Inf

## Input Arguments

collapse all

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

Base groups for comparison, specified as a matrix of logical or numerical arrays.

### Note

The group matrices GroupA and GroupB are usually indicators of membership in groups, which means that their elements are usually either 0 or 1. Because of this interpretation, the GroupA and GroupB matrices can be logical or numerical arrays.

Data Types: double

Comparison group, specified as a matrix of logical or numerical arrays.

### Note

The group matrices GroupA and GroupB are usually indicators of membership in groups, which means that their elements are usually either 0 or 1. Because of this interpretation, the GroupA and GroupB matrices can be logical or numerical arrays.

Data Types: double

Lower-bound for ratio of GroupB groups to GroupA groups, specified as a vector.

### Note

If input is scalar, LowerRatio undergoes scalar expansion to be conformable with the group matrices.

Data Types: double

Upper-bound for ratio of GroupB groups to GroupA groups, specified as a vector.

### Note

If input is scalar, UpperRatio undergoes scalar expansion to be conformable with the group matrices.

Data Types: double

## Output Arguments

collapse all

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

## Tips

• You can also use dot notation to add group ratio constraints for the portfolio weights to existing group ratio constraints.

obj = obj.addGroupRatio(GroupA, GroupB, LowerRatio, UpperRatio)

• To remove group ratio constraints from any of the portfolio objects using dot notation, enter empty arrays for the corresponding arrays.