group_constraint | R Documentation |
Group constraints specify the grouping of the assets, weights of the groups, and number of postions (i.e. non-zero weights) iof the groups.
This function is called by add.constraint when type="group" is specified. see add.constraint
group_constraint( type = "group", assets, groups, group_labels = NULL, group_min, group_max, group_pos = NULL, enabled = TRUE, message = FALSE, ... )
type |
character type of the constraint |
assets |
number of assets, or optionally a named vector of assets specifying initial weights |
groups |
list of vectors specifying the groups of the assets |
group_labels |
character vector to label the groups (e.g. size, asset class, style, etc.) |
group_min |
numeric or vector specifying minimum weight group constraints |
group_max |
numeric or vector specifying minimum weight group constraints |
group_pos |
vector specifying the number of non-zero weights per group |
enabled |
TRUE/FALSE |
message |
TRUE/FALSE. The default is message=FALSE. Display messages if TRUE. |
... |
any other passthru parameters to specify group constraints |
an object of class 'group_constraint'
Ross Bennett
add.constraint
data(edhec) ret <- edhec[, 1:4] pspec <- portfolio.spec(assets=colnames(ret)) # Assets 1 and 3 are groupA # Assets 2 and 4 are groupB pspec <- add.constraint(portfolio=pspec, type="group", groups=list(groupA=c(1, 3), groupB=c(2, 4)), group_min=c(0.15, 0.25), group_max=c(0.65, 0.55)) # 2 levels of grouping (e.g. by sector and geography) pspec <- portfolio.spec(assets=5) # Assets 1, 3, and 5 are Tech # Assets 2 and 4 are Oil # Assets 2, 4, and 5 are UK # Assets 1 and are are US group_list <- list(group1=c(1, 3, 5), group2=c(2, 4), groupA=c(2, 4, 5), groupB=c(1, 3)) pspec <- add.constraint(portfolio=pspec, type="group", groups=group_list, group_min=c(0.15, 0.25, 0.2, 0.1), group_max=c(0.65, 0.55, 0.5, 0.4))
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.