Accelerating the pace of engineering and science

# Documentation Center

• Trial Software
• Product Updates

# setGroupRatio

Class: PortfolioMAD

Set up group ratio constraints for portfolio weights in PortfolioMAD object

## Syntax

obj = setGroupRatio(obj,GroupA)
obj = setGroupRatio(obj,GroupA,GroupB,LowerRatio,
UpperRatio)

## Description

obj = setGroupRatio(obj,GroupA) sets up the group ratio constraints for MAD portfolio weights with lower bound on the ratio between groups.

obj = setGroupRatio(obj,GroupA,GroupB,LowerRatio,
UpperRatio)
to set up group ratio constraints for portfolio weights with an additional option specified for UpperRatio.

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

`(GroupB * Port) .* LowerRatio <= GroupA * Port <= (GroupB * Port) .* UpperRatio`
 Caution   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.

## Tips

• Use dot notation to set up group ratio constraints for portfolio weight.

`obj = obj.setGroupRatio(GroupA, GroupB, LowerRatio, UpperRatio);`
• To remove group ratio constraints, enter empty arrays for the corresponding arrays. To add to existing group ratio constraints, use addGroupRatio.

## Input Arguments

obj

MAD portfolio object [PortfolioMAD].

GroupA

Matrix that forms base groups for comparison [matrix].

GroupB

Matrix that forms comparison groups [matrix].

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

LowerRatio

Lower bound for ratio of GroupB groups to GroupA groups [vector].

 Note:   If input is scalar, LowerRatio undergoes scalar expansion to conform with the group matrices.

UpperRatio

(Optional) Upper bound for ratio of GroupB groups to GroupA groups [vector].

 Note:   If input is scalar, UpperRatio undergoes scalar expansion to conform with the group matrices.

## Output Arguments

 obj Updated MAD portfolio object [PortfolioMAD].

## 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 Group Ratio Constraints

Suppose you want to ensure that the ratio of financial to nonfinancial companies in your portfolio never exceeds 50%. Assume you have six assets with three financial companies (assets 1-3) and three nonfinanical companies (assets 4-6). Group ratio constraints can be set with:

```GA = [ true true true false false false ];    % financial companies
GB = [ false false false true true true ];    % nonfinancial companies
p = PortfolioMAD;
p = p.setGroupRatio(GA, GB, [], 0.5);
disp(p.NumAssets);
disp(p.GroupA);
disp(p.GroupB);
disp(p.UpperRatio);
```
```     6

1     1     1     0     0     0

0     0     0     1     1     1

0.5000

```

## More About

Was this topic helpful?