Learn R Programming

RelValAnalysis (version 1.0)

GetWeight: Computing Portfolio Weights from a Weight Function

Description

Given the benchmark weights (say, derived from a toy market, see toymkt) and a function which maps benchmark weights to portfolio weights, the function GetWeight computes a matrix of portfolio weights.

Usage

GetWeight(market, weight.function, ...)

Arguments

Value

A matrix where each row represents the portfolio weights for a period.

Details

A probability vector is a numeric vector with non-negative entries summing to one. weight.function is a function which maps probability vectors to probability vectors. It represents a portfolio whose weights are deterministic functions of the current benchmark weights.

See Also

Invest

Examples

Run this code
data(applestarbucks) 
market <- toymkt(applestarbucks)

# This is the diversity-weighted portfolio
weight.function <- function(x, p) {
  return(x^p / sum(x^p))
}

weight <- GetWeight(market, weight.function, p = 0.7)
Invest(market, weight)

Run the code above in your browser using DataLab