build.constraints {PortfolioProbe}R Documentation

Build Constraints for Optimization

Description

Builds a bounds object suitable for the input linear constraints, and ensures that the constraints are in a suitable form.

Usage

build.constraints(x, bounds = NULL)

Arguments

x required. Vector, matrix or data frame giving the information about the constraint(s) for each asset. See the Details section for more.
bounds optional matrix of bounds. The rows correspond to the constraints. Rows from this matrix that match constraint names that are created for x are put into the output bounds matrix.

Value

a list with the following components:

lin.constraints a matrix or data frame similar to the input x. This always has column names so that the constraints can be identified.
bounds a matrix with two columns and as many rows as constraints represented by the input x. Numeric columns of x embody one constraint. Columns that are factors or character or logical represent as many constraints as there are unique values in the column.

Details

Numeric linear constraints are created with numeric data. Categorical linear constraints (and count constraints) are created with a factor, character data or logical data.

A data frame is required as the input x if more than one type of data is given.

Revision

This help was last revised 2010 January 02.

See Also

constraints.realized, trade.optimizer,

Examples

my.sc <- matrix(c("energy", "telecom", "energy", "Germany", "France",
        "France"), nrow=3, ncol=2, dimnames=list(c("Asset 1", "Asset 2",
        "Asset 3"), c("Sector", "Country")))
my.constr <- build.constraints(my.sc)
my.constr$bounds[,1] <- c(-.05, -.10, 0, .05)
my.constr$bounds[,2] <- c(.15, .15, .20, .55)

random.portfolio(100, prices, 
        lin.constraints=my.constr$lin.constraints,
        lin.bounds=my.constr$bounds, 
        gross.value=1e6, net.value=c(-1e5, 6e5))


[Package PortfolioProbe version 1.01 Index]