box_constraint: constructor for box_constraint.

Description Usage Arguments Value Author(s) See Also Examples

Description

Box constraints specify the upper and lower bounds on the weights of the assets. This function is called by add.constraint when type="box" is specified. See add.constraint.

Usage

1
2
box_constraint(type = "box", assets, min, max, min_mult, max_mult,
  enabled = TRUE, message = FALSE, ...)

Arguments

type

character type of the constraint

assets

number of assets, or optionally a named vector of assets specifying initial weights

min

numeric or named vector specifying minimum weight box constraints

max

numeric or named vector specifying minimum weight box constraints

min_mult

numeric or named vector specifying minimum multiplier box constraint from initial weight in assets

max_mult

numeric or named vector specifying maximum multiplier box constraint from initial weight in assets

enabled

TRUE/FALSE

message

TRUE/FALSE. The default is message=FALSE. Display messages if TRUE.

...

any other passthru parameters to specify box constraints

Value

an object of class 'box_constraint'

Author(s)

Ross Bennett

See Also

add.constraint

Examples

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
data(edhec)
ret <- edhec[, 1:4]

pspec <- portfolio.spec(assets=colnames(ret))

# defaults to min=0 and max=1
pspec <- add.constraint(pspec, type="box")

# specify box constraints as a scalar
pspec <- add.constraint(pspec, type="box", min=0.05, max=0.45)

# specify box constraints per asset
pspec <- add.constraint(pspec, 
                        type="box", 
                        min=c(0.05, 0.10, 0.08, 0.06), 
                        max=c(0.45, 0.55, 0.35, 0.65))
                        

PortfolioAnalytics documentation built on May 1, 2019, 10:56 p.m.