the fportfolio package -...

47
The fPortfolio Package October 8, 2007 Version 260.72 Date 1997 - 2007 Title Rmetrics - Portfolio Selection and Optimization Author Diethelm Wuertz and many others, see the SOURCE file Depends R (>= 2.4.0), quadprog, lpSolve, MASS, fAssets Maintainer Diethelm Wuertz and Rmetrics Core team <[email protected]> Description Environment for teaching “Financial Engineering and Computational Finance” NOTE SEVERAL PARTS ARE STILL PRELIMINARY AND MAY BE CHANGED IN THE FUTURE. THIS TYPICALLY INCLUDES FUNCTION AND ARGUMENT NAMES, AS WELL AS DEFAULTS FOR ARGUMENTSAND RETURN VALUES. LazyLoad yes LazyData yes License GPL Version 2 or later URL http://www.rmetrics.org R topics documented: DrawdownStatistics ..................................... 2 Extractors .......................................... 4 PortfolioClass ........................................ 5 PortfolioClassExtractors .................................. 10 PortfolioConstraints ..................................... 13 PortfolioData ........................................ 15 PortfolioDataExtractors ................................... 16 PortfolioDataSets ...................................... 17 PortfolioPlots ........................................ 18 PortfolioSlider ........................................ 21 PortfolioSolver ....................................... 25 1

Upload: lyquynh

Post on 25-Aug-2018

214 views

Category:

Documents


0 download

TRANSCRIPT

The fPortfolio PackageOctober 8, 2007

Version 260.72

Date 1997 - 2007

Title Rmetrics - Portfolio Selection and Optimization

Author Diethelm Wuertz and many others, see the SOURCE file

Depends R (>= 2.4.0), quadprog, lpSolve, MASS, fAssets

Maintainer Diethelm Wuertz and Rmetrics Core team <[email protected]>

Description Environment for teaching “Financial Engineering and Computational Finance”

NOTE SEVERAL PARTS ARE STILL PRELIMINARY AND MAY BE CHANGED IN THEFUTURE. THIS TYPICALLY INCLUDES FUNCTION AND ARGUMENT NAMES, ASWELL AS DEFAULTS FOR ARGUMENTS AND RETURN VALUES.

LazyLoad yes

LazyData yes

License GPL Version 2 or later

URL http://www.rmetrics.org

R topics documented:DrawdownStatistics . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 2Extractors . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 4PortfolioClass . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 5PortfolioClassExtractors . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 10PortfolioConstraints . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 13PortfolioData . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 15PortfolioDataExtractors . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 16PortfolioDataSets . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 17PortfolioPlots . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 18PortfolioSlider . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 21PortfolioSolver . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 25

1

2 DrawdownStatistics

PortfolioSpec . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 26PortfolioSpecExtractors . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 30RollingPortfolio . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 32VaRModelling . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 34donlp2 . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 38donlp2Control . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 41Portfolio . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 42

Index 44

DrawdownStatistics Drawdown Statistics

Description

This is a collection and description of functions which compute drawdown statistics. Included aredensity, distribution function, and random generation for the maximum drawdown distribution. Inaddition the expectation of drawdowns for Brownian motion can be computed.

The functions are:

dmaxdd the Density function,pmaxdd the Distribution function,rmaxdd the random number generator,maxddStats the expectation of drawdowns.

Usage

dmaxdd(x, sd = 1, horizon = 100, N = 1000)pmaxdd(q, sd = 1, horizon = 100, N = 1000)rmaxdd(n, mean = 0, sd = 1, horizon = 100)

maxddStats(mean = 0, sd = 1, horizon = 1000)

Arguments

x, q a numeric vector of quantiles.

n an integer value, the number of observations.

mean, sd two numeric values, the mean and standard deviation.

horizon an integer value, the (run time) horizon of the investor.

N an integer value, the precession index for summations. Before you change thisvalue please inspect Magdon-Ismail et. al. (2003).

Value

dmaxddreturns for a trendless Brownian process mean=0 and standard deviation "sd" the density from the

DrawdownStatistics 3

probability that the maximum drawdown "D" is larger or equal to "h" in the interval [0,T], where"T" denotes the time horizon of the investor.

pmaxddreturns for a trendless Brownian process mean=0 and standard deviation "sd" the the probabilitythat the maximum drawdown "D" is larger or equal to "h" in the interval [0,T], where "T" denotesthe time horizon of the investor.

rmaxddreturns for a Brownian Motion process with mean mean and standard deviation sd random variatesof maximum drawdowns.

maxddStatsreturns the expectation Value E[D] of maximum drawdowns of Brownian Motion for a given driftmean, variance sd, and runtime horizon of the Brownian Motion process.

Note

Currrently, for the functions dmaxdd and pmaxdd only the trend or driftless case is implemented.

Author(s)

Diethelm Wuertz for the Rmetrics port.

References

Magdon-Ismail M., Atiya A.F., Pratap A., Abu-Mostafa Y.S. (2003); On the Maximum Drawdownof a Brownian Motion, Preprint, CalTech, Pasadena USA, p. 24.

Examples

## rmaxdd -# Set a random seedset.seed(1953)# horizon of the investor, time Thorizon = 1000# number of MC samples, N -> infinitysamples = 1000# Range of expected Drawdonsxlim = c(0, 5)*sqrt(horizon)# Plot Histogram of Simulated Max Drawdowns:r = rmaxdd(n = samples, mean = 0, sd = 1, horizon = horizon)hist(x = r, n = 40, probability = TRUE, xlim = xlim,col = "steelblue4", border = "white", main = "Max. Drawdown Density")

points(r, rep(0, samples), pch = 20, col = "orange", cex = 0.7)

## dmaxdd -x = seq(0, xlim[2], length = 200)d = dmaxdd(x = x, sd = 1, horizon = horizon, N = 1000)lines(x, d, lwd = 2)

4 Extractors

## pmaxdd -# Count Frequencies of Drawdowns Greater or Equal to "h":n = 50x = seq(0, xlim[2], length = n)g = rep(0, times = n)for (i in 1:n) g[i] = length (r[r > x[i]]) / samplesplot(x, g, type ="h", lwd = 3,xlab = "q", main = "Max. Drawdown Probability")

# Compare with True Probability "G_D(h)":x = seq(0, xlim[2], length = 5*n)p = pmaxdd(q = x, sd = 1, horizon = horizon, N = 5000)lines(x, p, lwd = 2, col="steelblue4")

## maxddStats -# Compute expectation Value E[D]:maxddStats(mean = -0.5, sd = 1, horizon = 10^(1:4))maxddStats(mean = 0.0, sd = 1, horizon = 10^(1:4))maxddStats(mean = 0.5, sd = 1, horizon = 10^(1:4))

Extractors Extractors

Description

A collection and description of functions allowing to get information about objects of class fPFO-LIODATA, FPFOLIOSPEC, and fPORTFOLIO.

The functions are:

Usage

getConstraints(object)getData(object)getEstimator(object)getFrontier(object, ...)getMu(object)getNames(object)getNumberOfAssets(object)getNFrontierPoints(object)getPortfolio(object)getParams(object)getCovRiskBudgets(object)getRiskFreeRate(object)getSeries(object)getSigma(object)getSolver(object)getSpec(object)getStatistics(object)

PortfolioClass 5

getTargetAlpha(object)getTailRisk(object)getTailRiskBudgets(object)getTargetReturn(object)getTargetRisk(object)getTrace(object)getType(object)getWeights(object)

Arguments

object an object of class fPFOLIODATA, fPFOLIOSPEC or fPORTFOLIO.

... [getPortfolio, getFrontier, getWeights] -optional arguments to be passed.

Author(s)

Diethelm Wuertz and Oliver Greshake for the Rmetrics port.

Examples

##

PortfolioClass Portfolio Class

Description

A collection and description of functions allowing to gain information about optimal portfolios.Generally, optimization is done via three arguments, data, specification of the portfolio, and con-straints, while function portfolioFrontier() has two additional arguments for title and description.

The functions are:

feasiblePortfolio Returns a feasible portfolio,cmlPortfolio returns the capital market line portfolio,tangencyPortfolio returns the tangency portfolio,minvariancePortfolio returns the minimum variance portfolio,efficientPortfolio returns an efficient portfolio,portfolioFrontier returns the efficient frontier,show print method for ’fPPORTFOLIO’ objects,plot plot method for objects of class fPORTFOLIO.

Usage

portfolioFrontier(data, spec = portfolioSpec(), constraints = NULL,

6 PortfolioClass

title = NULL, description = NULL)

feasiblePortfolio(data, spec = portfolioSpec(), constraints = NULL)cmlPortfolio(data, spec = portfolioSpec(), constraints = NULL)tangencyPortfolio(data, spec = portfolioSpec(), constraints = NULL)minvariancePortfolio(data, spec = portfolioSpec(), constraints = NULL)efficientPortfolio(data, spec = portfolioSpec(), constraints = NULL)

show.fPORTFOLIO(object)## S3 method for class 'fPORTFOLIO':plot(x, which = "ask", control = list(), ...)## S3 method for class 'fPORTFOLIO':summary(object, ...)

Arguments

constraints a character string vector, containing the constraints of the form"minW[asset]=percentage" for box constraints resp."maxsumW[assets]=percentage" for sector constraints.

control [plot, *Sliders] -a list, defining the plotting parameters. The list modifies amongst others thecolor, e.g. minvariance.col, type of point, e.g. tangency.pch, or thedimension of the point, e.g. cml.cex, see Notes for a complete list of controlparameters.

data a multivariate time series described by an S4 object of class timeSeries.If your timeSerie is not a timeSeries object, consult the generic functionas.timeSeries to convert your time series.

description [portfolioFrontier] -a character string, allowing for a brief project description, by default NULL, i.e.Date and User.

object [show, *Sliders] -an S4 object of class fPORTFOLIO, containing slots call, data, specification,constraints, portfolio, title, description, see Value for a full slot description.

spec an S4 object of class fPFOLIOSPEC, containing slots call, model, portfolio,title, description, see PortfolioSpec for a full slot description.

title [portfolioFrontier] -a character string, containing the title for the object, by default NULL.

which [plot] -which of the plots should be displayed? which can be either a character string,"all" (displays all plots) or "ask" (interactively asks which one to display),or a vector of integer values displaying the corresponding plot. Default value is"ask".

x [plot] -an S4 object of class fPORTFOLIO.

... [plot, *Sliders] -optional arguments to be passed.

PortfolioClass 7

Details

Portfolio Class:

This S4 class contains all information about the portfolio. Basically this are risk measure, meanand covariance estimation, target return, risk free rate, number of frontier points, ranges for calcu-lation, see the "Value" section for a detailed description of the slots.

Portfolio Frontier:

The function portfolioFrontier calculates the whole efficient frontier. The portfolio infor-mation consists of five arguments: data, specifications, constraints, title and description. The datacan be either the mean vector and the covariance matrix in a equivalently named list or a time seriestable. The specifications are done by the portfolioSpec function, see PortfolioSpec. Theconstrains have the following syntax. For bound constraints: "minW[asset]=percentage"and for sector constraints "maxsumW[assets]=percentage". The function chooses fromthis information the right algorithm to calculate the efficient frontier. The function returns an S4object of class fPortfolio containing amongst others risk, return and weights of the whole effi-cient frontier, see Value for further details.

Individual Portfolios:

Individual portfolio functions allow a direct computation of portfolios with specific properties. Thefunctions are:

feasiblePortfolio a feasible portfolio,cmlPortfolio the capital market line portfolio,tangencyPortfolio the tangency portfolio,minvariancePortfolio the minimum variance portfolio,efficientPortfolio an efficient portfolio.

The functions require three arguments: data, spec (specifications), and constraints, seeabove. The functions are named according to their specific property and return the result of thecomputed or optimized portfolio as an S4 object of class fPortfolio.

FeasiblePortfolio: The weights are retrieved from the specification structure, by default they areundefined, NULL, and in this case the function feasiblePortfolio assumes equal weights.To set user specified weights in the specification structure, use the function setWeights.

Value

portfolioFrontier()returns an S4 object of class "fPORTFOLIO", with the following slots:

@call a call, returning the matched function call.

@data a list with two named elements, series holding the time series data if avail-able, otherwise NA, and statistics, itself a named list with two namedelements mu and Sigma holding the vector of means and the matrix of covari-ances.

8 PortfolioClass

@description a character string, allowing for a brief project description.

@portfolio a list, containing parameter specifications for the portfolio:weights a numeric vector specifying the portfolio weights,targetReturn a numeric value specifying the target return,targetRisk a numeric value specifying the target risk,targetMean a numeric value specifying the target return determinated withfunction mean(),targetStdev a numeric value specifying the target risk in standart deviationas risk measure.

@specificationa list with one named element specwhich represents an object of class fPFOLIOSPEC,including all information about the portfolio specifications, see PortfolioSpecfor further details.

@title a title string.

feasiblePortfoliocmlPortfoliotangencyPortfoliominvariancePortfolioefficientPortfolioreturn an S4 object of class fPORTFOLIO having information only about one portfolio.

Control Parameters

In the following all elements of argument control from functions plot, weightsSlider, frontierSliderare listed.

sliderResolution [weightsSlider, frontierSlider] - a numeric, determining the numbers of sliderpoints, by default nFrontierPoints/10.

sliderFlag [weightsSlider, frontierSlider] - a character string, denoting the slidertype, by default"frontier" for frontierSlider and "weights" for weightsSlider.

sharpeRatio.col [plot, frontierSlider] - a character string, defining color of the Sharpe ratio plot,by default "black".

minvariance.col a character string, defining color of the minimum variance portfolio, by default"red".

tangency.col a character string, defining color of the tangency portfolio, by default "steelblue".

cml.col [plot, frontierSlider] - a character string, defining color of the market portfolio and thecapital market line, by default "green".

equalWeights.col [plot, frontierSlider] - a character string, defining the color of the equal weightsportfolio, by default "blue".

runningPoint.col [weightsSlider] - a character string, defining color of the point indicating thecurrent portfolio, by default "red".

singleAsset.col a character string vector, defining color of the single asset portfolios. The vectormust have length the number of assets, by default rainbow.

twoAssets.col [plot, frontierSlider] - a character string, defining color of the two assets efficientfrontier, by default "grey".

PortfolioClass 9

monteCarlo.col [plot, frontierSlider] - a character string, defining color of the Monte Carlo port-folios, by default "black".

minvariance.pch a number, defining symbol used for the minimum variance portfolio. See pointsfor description. Default symbol is 17.

tangency.pch a number, defining symbol used for the tangency portfolio. See points for de-scription. Default symbol is 17.

cml.pch [plot, frontierSlider] - a number, defining symbol used for the market portfolio. Seepoints for description. Default symbol is 17.

equalWeights.pch [plot, frontierSlider] - a number, defining symbol used for the equal weightsportfolio. See points for description. Default symbol is 15.

singleAsset.pch a number, defining symbol used for the single asset portfolios. See points fordescription. Default symbol is 18.

sharpeRatio.cex [plot, frontierSlider] - a number, determining size (percentage) of the Sharpe ratioplot, by default 0.1.

minvariance.cex a number, determining size (percentage) of the minimum variance portfolio sym-bol, by default 1.

tangency.cex a number, determining size (percentage) of the tangency portfolio symbol, by default1.25.

cml.cex [plot, frontierSlider] - a number, determining size (percentage) of the market portfoliosymbol, by default 1.25.

equalWeights.cex [plot, frontierSlider] - a number, determining size (percentage) of the equalweights portfolio symbol, by default 0.8.

runningPoint.cex [weightsSlider] - a number, determining size (percentage) of the point indicatingthe current portfolio equal weights portfolio symbol, by default 0.8.

singleAsset.cex a number, determining size (percentage) of the singel asset portfolio symbols, bydefault 0.8.

twoAssets.cex [plot, frontierSlider] - a number, determining size (percentage) of the two assetsefficient frontier plot, by default 0.01.

monteCarlo.cex [plot, frontierSlider] - a number, determining size (percentage) of the MonteCarol portfolio symbols, by default 0.01.

monteCarlo.cex [plot, frontierSlider] - a number, determining size (percentage) of the MonteCarol portfolio symbols, by default 0.01.

mcSteps [plot] - a number, determining number of Monte Carol portfolio, by default 5000.

pieR [plot, frontierSlider] - a vector, containing factors for shrinking and stretching the x- andy-axis, by default NULL, i.e. c(1, 1) is used. Default pie size is 1/15 of the plot range.

piePos [plot, frontierSlider] - a number, determining the weight on the efficient frontier, which isillustrated by the pie. Default is tangency portfolio

pieOffset [plot, frontierSlider] - a vector, containing the pie’s x- and y-axis offset from the efficientfrontier. Default is NULL, i.e. the pie is set one default radius left of the efficient frontier.

xlim [weightsSlider, frontierSlider] - a vector, containing x-axis plot limits of the efficient frontier.Default setting is maximum of frontier range or single assets portfolios.

ylim [weightsSlider, frontierSlider] - a vector, containing y-axis plot limits of the efficient frontier.Default setting is maximum of frontier range or single assets portfolios.

10 PortfolioClassExtractors

Author(s)

Diethelm Wuertz and Oliver Greshake for the Rmetrics port.

See Also

PortfolioData, PortfolioSpec, PortfolioConstraints, PortfolioPlots, PortfolioPlots.

Examples

## minvariancePortfolio -# Load Data and Convert to timeSeries Object:Data = as.timeSeries(data(smallcap.ts))Data = Data[, c("BKE", "GG", "GYMB", "KRON")]Data# Set Default Specifications:Spec = portfolioSpec()Spec# Allow for unlimited Short Selling:Constraints = "Short"# Compute Short Selling Minimum Variance PortfoliominvariancePortfolio(Data, Spec, Constraints)

## portfolioFrontier -# Modify Constraints - Now Long Only Constraints:Constraint = c("minW[1:nAssets]=0")# Calculation of the Efficient Frontierfrontier = portfolioFrontier(Data, Spec, Constraint)print(frontier)

## plot -# Plot Efficient Frontier with Minimum Variance Portfolio# plot(frontier, which = c(1, 3))

## frontierSlider -# Try Frontier Slider:# frontierSlider(frontier)

PortfolioClassExtractorsPortfolio Class Extractors

Description

A collection and description of functions allowing to get information about an object of classfPORTFOLIO.

The functions are:

getData Extracts ...,

PortfolioClassExtractors 11

getSeries Extracts ...,getStatistics Extracts ...,getNumberOfAssets Extracts ...,getSpec Extracts ...,getType Extracts ...,getEstimator Extracts ...,getParams Extracts ...,getSolver Extracts ...,getTrace Extracts ...,getConstraints Extracts ...,getPortfolio Extracts ...,getWeights Extracts ...,getTargetReturn Extracts ...,getTargetRisk Extracts ...,getTargetAlpha Extracts ...,getRiskFreeRate Extracts ...,getNFrontierPoints Extracts ...,getStatus Extracts ...,getFrontier Extracts ...,getCovRiskBudgets Extracts ...,getTailRiskBudgets Extracts ... .

Usage

## S3 method for class 'fPORTFOLIO':getData(object)## S3 method for class 'fPORTFOLIO':getSeries(object)## S3 method for class 'fPORTFOLIO':getStatistics(object)## S3 method for class 'fPORTFOLIO':getNumberOfAssets(object)

## S3 method for class 'fPORTFOLIO':getSpec(object)## S3 method for class 'fPORTFOLIO':getType(object)## S3 method for class 'fPORTFOLIO':getEstimator(object)## S3 method for class 'fPORTFOLIO':getParams(object)## S3 method for class 'fPORTFOLIO':getSolver(object)## S3 method for class 'fPORTFOLIO':getTrace(object)

## S3 method for class 'fPORTFOLIO':getConstraints(object)

12 PortfolioClassExtractors

## S3 method for class 'fPORTFOLIO':getPortfolio(object)## S3 method for class 'fPORTFOLIO':getWeights(object)## S3 method for class 'fPORTFOLIO':getTargetReturn(object)## S3 method for class 'fPORTFOLIO':getTargetRisk(object)## S3 method for class 'fPORTFOLIO':getTargetAlpha(object)## S3 method for class 'fPORTFOLIO':getRiskFreeRate(object)## S3 method for class 'fPORTFOLIO':getNFrontierPoints(object)## S3 method for class 'fPORTFOLIO':getStatus(object)

## S3 method for class 'fPORTFOLIO':getFrontier(object, frontier = c("both", "lower", "upper"),

doplot = FALSE, ...)## S3 method for class 'fPORTFOLIO':getCovRiskBudgets(object)## S3 method for class 'fPORTFOLIO':getTailRiskBudgets(object)

Arguments

doplot [getPortfolio, getFrontier, getWeights] -a logical value, determining whether the extracted data should be plotted, bydefaultFALSE.

frontier [getFrontier] -a character string, determining which part of the frontier should be extracted."both" stands for the full hyperbola, "lower" for all points below the min-imum variance return and "upper" for the actual efficient frontier, by default"both".

object an object of class fPORTFOLIO, containing slots call, data, specification, con-straints, portfolio, title, description.

... [getPortfolio, getFrontier, getWeights] -optional arguments to be passed.

Author(s)

Diethelm Wuertz and Oliver Greshake for the Rmetrics port.

Examples

##

PortfolioConstraints 13

PortfolioConstraintsPortfolio Constraints

Description

A collection and description of functions, which allow to set, manipulate and/or view portfolio con-straints. Type of constraints include box/group constraints of weights, and covariance risk-budgetconstraints.

The functions are:

portfolioConstraints Checks portfolio constraints for consistency.

Usage

portfolioConstraints(data, spec = portfolioSpec(), constraints = NULL)

Arguments

constraints [setConstraints] -a character value or character vector, containing the constraint strings. Settingconstraints is described in the details section

data [setConstraints] -a list, having a statistics named list, having named entries ’mu’ and ’Sigma’,containing the information of the statistics

spec [setConstraints] -an object of class fPFOLIOSPEC, containing slots call, model, portfolio, title,description.

Details

How to define constraints?

Constraints are defined by a character string or a vector of character strings.

Special Constraint Settings:

There are three special cases, the settings constraints=NULL, constraints="Short",and constraints="LongOnly". Note, that these three constraint settings are not allowed tobe combined with more general constraint definitions.

NULL: This selection defines the default value and is equivalent to the "LongOnly" case, seebelow.

"Short": This selection defines the case of unlimited short selling. i.e. each weight may rangebetween -Inf and Inf. Consequently, there are no group constraints. Risk budget constraints arenot included in the portfolio optimization.

14 PortfolioConstraints

"LongOnly": This selection is the same as the default setting. Each weight may range between 0ans 1. No group constraints and risk budget constraints will be included in the portfolio optimiza-tion.

Tailored Weight Constrained Portfolios:

Weight constrained portfolios may be specified by a vector of character strings which describe ex-ecutable code, setting values to to vectors minW, maxW, minsumW, and maxsumW. The individualstring elements of the vector have the following form:

box constraints "minW[Asset(s)]=Value(s)", and/or \ "maxW[Asset(s)]=Value(s)".

sector constraints "minsumW[Asset(s)]=Value(s)", and/or \ "maxsumW[Asset(s)]=Value(s)".

Asset(s) is an index of one or more assets, and value a numeric value or vector assigning thedesired value. Note, if the values range between zero and one, then we have a long only portfolioallowing for box and group constraints of the weights. If the values are set to negative values, andvalues larger than one, then (constrained) short selling will be allowed.

Tailored Risk Budget Constrained Portfolios:

By default, risk budgets are not included in the portfolio optimization. Covariance risk budgets haveto be added explicitely, and have the following form:

box constraints "minB[Asset(s)]=Value(s)", and/or \ "minB[Asset(s)]=Value(s)".

Again, Asset(s) is an index of one or more assets, and value a numeric value or vector withnumbers ranging between zero and one, assigning the desired risk budgets.

Author(s)

Diethelm Wuertz and Oliver Greshake for the Rmetrics port.

See Also

PortfolioData, PortfolioSpec, fPORTFOLIO, PortfolioPlots.

Examples

## portfolioConstraints -# Load Data, i.e. a List of Returns:Data = as.timeSeries(data(smallcap.ts))Data = Data[, c("BKE", "GG", "GYMB", "KRON")]Data# Specification:Spec = portfolioSpec()# Portfolio Constraints:Constraints = "minW[1:4]"portfolioConstraints(Data, Spec, Constraints)

PortfolioData 15

PortfolioData Portfolio Data Handling

Description

A collection and description of functions to handle portfolio data.

The functions are:

portfolioStatistics Estimates ’mu’ and ’Sigma’ statistics,print|show Print method for fPFOLIOSPEC objects.

Usage

portfolioData(data, spec = portfolioSpec())

portfolioStatistics(data, spec = portfolioSpec())

show.fPFOLIODATA(object)

Arguments

data [portfolioStatistics] -a time series or a named list, containing either a series of returns or namedentries ’mu’ and ’Sigma’ being mean and covariance matrix.

object [show] -an object of class fPFOLIODATA as returned by the function portfolioData.

spec an S4 object of class fPFOLIOSPEC, the specification to be modified, by de-fault the default of the function portfolioSpec().

Details

Dutch Portfolio Data Set:

This data represents seven stocks from the Dutch AEX index, Netherlands blue chips. The datais a list of the covariance matrix and the return means and is based on daily returns over a periodfrom January 1990 till end of October 2003. Companies representing the data are Elsevier, Fortis,Getronics, Heineken, Philips, Shell and Unilever.

US Portfolio Data Set:

The data inherits eight assets being indexes, commodities and bonds. The data is a time series ofyearly returns from December 1973 till December 1994. Assets are TBills3m, LongBonds, SP500,Wilshire5000, NASDAQComp, LehmanBonds, EAFE, Gold.

16 PortfolioDataExtractors

Simulated Mean-Cov Data Set:

This data is taken from chapter 1.3.2 in Scherer, M., Martin, R.D. (2005); Introduction To Mod-ern Portfolio Optimization with NuOPT, S-PLUS and S+Bayes, Springer, Berlin. It is a list ofcovariance matrix and the return means of imaginary assets. It is an example set for learning aboutoptimization.

World Index Returns Data Set:

This data set is contributed by D. Locher (2007); It is a timeSeries object of four world indexreturn data sets including Asia, Eastern Europe, Far East and Latin America.

Value

portfolioStatisticsreturns a named list of estimated mean $mu and covariance $Sigma statistics, from a multivariatetime series of assets.

portfolioDatareturns a named list of the time series $series and the portfolio $statistics as returned bythe function portfolioStatistics.

Author(s)

Diethelm Wuertz and Oliver Greshake for the Rmetrics port.

See Also

PortfolioSpec, PortfolioConstraints, fPORTFOLIO, PortfolioPlots.

Examples

## ...

PortfolioDataExtractorsPortfolio Data Extractors

Description

A collection and description of functions allowing to get information about an object of class fP-FOLIODATA.

The functions are:

getData Extracts data slot,getSeries Extracts assets series data,

PortfolioDataSets 17

getNumberOfAssets Extracts number of assets from statistics,getNames Extracts names of assets,getStatistics Extracts statistics slot,getMu Extracs mean mu from statistics,getSigma Extracs covariance Sigma from statistics,getTailRisk Extracts tail risk slot.

Usage

## S3 method for class 'fPFOLIODATA':getData(object)## S3 method for class 'fPFOLIODATA':getSeries(object)## S3 method for class 'fPFOLIODATA':getNumberOfAssets(object)## S3 method for class 'fPFOLIODATA':getNames(object)

## S3 method for class 'fPFOLIODATA':getStatistics(object)## S3 method for class 'fPFOLIODATA':getMu(object)## S3 method for class 'fPFOLIODATA':getSigma(object)

## S3 method for class 'fPFOLIODATA':getTailRisk(object)

Arguments

object an object of class fPFOLIODATA.

Author(s)

Diethelm Wuertz and Oliver Greshake for the Rmetrics port.

Examples

## ...

PortfolioDataSets fPortfolio Data Sets

Description

Data sets used in the examples of the ’fPortfolio’ package.

18 PortfolioPlots

Format

The Van Hedge Fund Indices were one of the first performance benchmarks based on a large andrepresentative sample of hedge fund returns. Published from 1995 until now, the Van Indices reflectthe average performance of hedge funds back to 1988. The Indices are produced on a monthly basis.They represent the average performance of hedge funds around the world and therefore tracks theperformance of the overall hedge fund universe.

All Index returns are based on hedge funds returns that are net of fees. They are simple non-dollar-weighted averages. Indexes for different time periods may be based on different funds, dependingon the hedge funds reporting to VAN at the time. The database, used in construction of the Indices,contains information on approximately 5,300 hedge funds.

The Van Global Hedge Fund Index is reported on a percentage-change basis. The Index was set atan initial value of 1,000 as of its January 1, 1988 inception.

The csv data file consists of 16 columns, the first with the date entries formatted as "%m/%d/%Y",followed by 14 columns with the Index, and the last column with the Global Hedge Fund Index.

The Indexes are:

AggressiveGrowthDistressedSecuritiesEmergingMarketsFundofFundsIncomeMacroMarketNeutralArbitrageMarketNeutralHedgingMarketTimingOpportunisticSeveralStrategiesShortSellingSpecialSituationsValueVanGlobalHedgeFundIndex

Source

Van Hedge Fund Advisors International, Inc.http://hedgefund.com/

Examples

## -

PortfolioPlots Portfolio Plots

PortfolioPlots 19

Description

A collection and description of plot functions. Included are weights, frontier, and related plots, aswell as covariance ellipses plots.

The functions are:

frontierPlot Plots efficient frontier,weightsPlot Plots staggered weights,attributesPlot Plots weighted means,covRiskBudgetsPlot Plots covariance risk budgets,tailRiskBudgetsPlot Plots tail risk budgets,weightsPie Plots staggered weights,attributesPie Plots weighted means,covRiskBudgetPie Plots weighted risks,tailRiskBudgetPie Plots weighted risks,covEllipsesPlot Plots covariance ellipses.

Usage

frontierPlot(object, frontier = c("both", "lower", "upper"),col = c("black", "grey"), add = FALSE, ...)

weightsPlot(object, col = NULL, legend = TRUE)attributesPlot(object, col = NULL, legend = TRUE)covRiskBudgetsPlot(object, col = NULL, legend = TRUE)tailRiskBudgetsPlot(object, col = NULL, legend = TRUE)

weightsPie(object, pos = NULL, col = NULL, box = TRUE, legend = TRUE)attributesPie(object, pos = NULL, col = NULL, box = TRUE, legend = TRUE)covRiskBudgetsPie(object, pos = NULL, col = NULL, box = TRUE, legend = TRUE)tailRiskBudgetsPie(object, pos = NULL, col = NULL, box = TRUE, legend = TRUE)

covEllipsesPlot(x = list(), ...)

Arguments

add [frontierPlot] -a logical value, determining whether the frontier should be added to an existingplot, by default FALSE.

box [weightsPie] -a logical value, determining whether a frame (box) should be plotted around thepie, by default TRUE.

col a character string vector, setting the color. For frontierPlot it is a twodimensional a vector; first entry is the upper part of the frontier,second entry the lower, by default "black" and "grey".For the other functions the argument defines the color representation, by defaultsets the default color is the rainbow palette.

20 PortfolioPlots

frontier [frontierPlot] -a character string, determining which part of the frontier should be extracted."both" stands for the full hyperbola, "lower" for all points below the min-imum variance return and "upper" for the actual efficient frontier, by default"both".

legend [*Pie][*Plot] -a numeric value, determining the position on the efficient frontier plotting thepie, by default NULL, i.e. expecting a object having only one set of weights likethe tangency portfolio.

pos [*Pie] -a logical value, determining whether a legend with the names of the assetsshould be plotted, by default TRUE.

object an S4 object of class fPORTFOLIO, containing slots call, data, specification,constraints, portfolio, title, description.

x [covEllipsesPlot] -a list of at least two covariance matrices.

... [covEllipsesPlot] -optional arguments to be passed.

Details

Frontier Plot:

The frontier plot provides plotting three parts of the efficient frontier. The part superior to theminimum variance portfolio is plotted with argument frontier = "upper". The part below is plottedwith "lower". Both parts are plotted with "both", which is default. The ranges of plots are de-termined by maximum of the ranges of the assets or the minimum and maximum of the efficientfrontier. Adding an efficient frontier to an existing plot is possible with the argument add. Theargument col determines the color of the upper and lower part of the efficient frontier.

Weights, Attributes, and Risk Budgets Plots:

These plotds give a view on three different views related to the weights of the frontier. This con-cern the constitution of the weights, the weights attributes and of the risk budgets. A vertical lineindicates the minimum variance portfolio. The weights plot displays staggered weights, while theattributes plot shows the mean return weighted weights of the portfolio, i.e. the real return. The riskbudget plot shows the risk weighted weights.

Covariance Ellipses Plot:

This plot visualizes the difference between two or more covariance matrices. It is meant to comparedifferent methods of covariance estimation.

Author(s)

Diethelm Wuertz and Oliver Greshake for the Rmetrics port.

PortfolioSlider 21

See Also

PortfolioData, PortfolioSpec, PortfolioConstraints, fPORTFOLIO.

Examples

## portfolioFrontier -# Load Data:Data = as.timeSeries(data(smallcap.ts))Data = Data[, c("BKE", "GG", "GYMB", "KRON")]Data# Compute Long Only Efficient Frontierfrontier = portfolioFrontier(Data)frontier

## frontierPlot -# Plot Upper Part of Frontier:# frontierPlot(frontier, frontier = "upper")# Adding Lower Part to Plot# frontierPlot(frontier, frontier = "lower", add = TRUE)

## weightsPlot -# View Weights Plot:# weightsPlot(frontier)

## attributesPlot -# View Attributes Plot:# attributesPlot(frontier, legend = TRUE)

PortfolioSlider Portfolio Slider

Description

Pop ups interactive plots onportfolio weights and the portfolio frontier.

The functions are:

frontierSlider starts the efficient frontier Slider,weightsSlider starts the weights slider.

Usage

frontierSlider(object, control = list(), ...)weightsSlider(object, control = list(), ...)

22 PortfolioSlider

Arguments

control a list, defining the plotting parameters. The list modifies amongst others thecolor, e.g. minvariance.col, type of point, e.g. tangency.pch, or thedimension of the point, e.g. cml.cex, see Notes for a complete list of controlparameters.

object an S4 object of class fPORTFOLIO.

... optional arguments to be passed.

Details

The sliders have illustrative objectives. The functions expect an S4 object of class fPortfolio.

frontierSlider: With the frontier slider it is possible to slide over the efficient frontier. Riskand return of the current portfolio is plotted in the title. The frontier slider has several addable plotfeatures listed in the following. Little pies at the current portfolio showing the weights (left pie)and/or the attributed weights (right pie), legend, minimum variance portfolio, tangency portfolio,market portfolio with capital market line (risk free rate is slidable), Sharpe ratio plot, equal weightsportfolio, single asset portfolios, two assets short selling efficient frontier, Monte Carlo portfolios(number is sliderable in a range from 0 to 25000).

weightsSlider: The weights slider gives an overview of the weights on the efficient frontier.Three weight plots weightsPlot, piePlot and the not stacked weights and a frontier plotwith the single assets, the tangency portfolio and a legend are provided. In the two weights plotsthe vertical line indicates the current portfolio and a dotted one indicates the minimum varianceportfolio. The number in the pie plot stands for the asset and the sign shows whether this asset isshort or long. In all plots colors represent the same asset.

Value

Creates interactive plots.

Control Parameters

In the following all elements of argument control from functions plot, weightsSlider, frontierSliderare listed.

sliderResolution [weightsSlider, frontierSlider] - a numeric, determining the numbers of sliderpoints, by default nFrontierPoints/10.

sliderFlag [weightsSlider, frontierSlider] - a character string, denoting the slidertype, by default"frontier" for frontierSlider and "weights" for weightsSlider.

sharpeRatio.col [plot, frontierSlider] - a character string, defining color of the Sharpe ratio plot,by default "black".

minvariance.col a character string, defining color of the minimum variance portfolio, by default"red".

tangency.col a character string, defining color of the tangency portfolio, by default "steelblue".

PortfolioSlider 23

cml.col [plot, frontierSlider] - a character string, defining color of the market portfolio and thecapital market line, by default "green".

equalWeights.col [plot, frontierSlider] - a character string, defining the color of the equal weightsportfolio, by default "blue".

runningPoint.col [weightsSlider] - a character string, defining color of the point indicating thecurrent portfolio, by default "red".

singleAsset.col a character string vector, defining color of the single asset portfolios. The vectormust have length the number of assets, by default rainbow.

twoAssets.col [plot, frontierSlider] - a character string, defining color of the two assets efficientfrontier, by default "grey".

monteCarlo.col [plot, frontierSlider] - a character string, defining color of the Monte Carlo port-folios, by default "black".

minvariance.pch a number, defining symbol used for the minimum variance portfolio. See pointsfor description. Default symbol is 17.

tangency.pch a number, defining symbol used for the tangency portfolio. See points for de-scription. Default symbol is 17.

cml.pch [plot, frontierSlider] - a number, defining symbol used for the market portfolio. Seepoints for description. Default symbol is 17.

equalWeights.pch [plot, frontierSlider] - a number, defining symbol used for the equal weightsportfolio. See points for description. Default symbol is 15.

singleAsset.pch a number, defining symbol used for the single asset portfolios. See points fordescription. Default symbol is 18.

sharpeRatio.cex [plot, frontierSlider] - a number, determining size (percentage) of the Sharpe ratioplot, by default 0.1.

minvariance.cex a number, determining size (percentage) of the minimum variance portfolio sym-bol, by default 1.

tangency.cex a number, determining size (percentage) of the tangency portfolio symbol, by default1.25.

cml.cex [plot, frontierSlider] - a number, determining size (percentage) of the market portfoliosymbol, by default 1.25.

equalWeights.cex [plot, frontierSlider] - a number, determining size (percentage) of the equalweights portfolio symbol, by default 0.8.

runningPoint.cex [weightsSlider] - a number, determining size (percentage) of the point indicatingthe current portfolio equal weights portfolio symbol, by default 0.8.

singleAsset.cex a number, determining size (percentage) of the singel asset portfolio symbols, bydefault 0.8.

twoAssets.cex [plot, frontierSlider] - a number, determining size (percentage) of the two assetsefficient frontier plot, by default 0.01.

monteCarlo.cex [plot, frontierSlider] - a number, determining size (percentage) of the MonteCarol portfolio symbols, by default 0.01.

monteCarlo.cex [plot, frontierSlider] - a number, determining size (percentage) of the MonteCarol portfolio symbols, by default 0.01.

24 PortfolioSlider

mcSteps [plot] - a number, determining number of Monte Carol portfolio, by default 5000.

pieR [plot, frontierSlider] - a vector, containing factors for shrinking and stretching the x- andy-axis, by default NULL, i.e. c(1, 1) is used. Default pie size is 1/15 of the plot range.

piePos [plot, frontierSlider] - a number, determining the weight on the efficient frontier, which isillustrated by the pie. Default is tangency portfolio

pieOffset [plot, frontierSlider] - a vector, containing the pie’s x- and y-axis offset from the efficientfrontier. Default is NULL, i.e. the pie is set one default radius left of the efficient frontier.

xlim [weightsSlider, frontierSlider] - a vector, containing x-axis plot limits of the efficient frontier.Default setting is maximum of frontier range or single assets portfolios.

ylim [weightsSlider, frontierSlider] - a vector, containing y-axis plot limits of the efficient frontier.Default setting is maximum of frontier range or single assets portfolios.

Author(s)

Diethelm Wuertz and Oliver Greshake for the Rmetrics port.

See Also

PortfolioClass, PortfolioData, PortfolioSpec, PortfolioConstraints, PortfolioPlots.

Examples

## minvariancePortfolio -# Load Data and Convert to timeSeries Object:Data = as.timeSeries(data(smallcap.ts))Data = Data[, c("BKE", "GG", "GYMB", "KRON")]Data# Set Default Specifications:Spec = portfolioSpec()Spec# Allow for unlimited Short Selling:Constraints = "Short"# Compute Short Selling Minimum Variance PortfoliominvariancePortfolio(Data, Spec, Constraints)

## portfolioFrontier -# Modify Constraints - Now Long Only Constraints:Constraint = c("minW[1:nAssets]=0")# Calculation of the Efficient Frontierfrontier = portfolioFrontier(Data, Spec, Constraint)print(frontier)

## frontierSlider -# Try Frontier Slider:# frontierSlider(frontier)

## weightsSlider -# Try Weights Slider:# weightsSlider(frontier)

PortfolioSolver 25

PortfolioSolver Portfolio Solver

Description

A collection and description of solver and utility functions for portfolio optimization.

The functions are:

solveRQuadprog Calls Goldfarb and Idnani’s QP solver,solveRDonlp2 Calls Spelucci’s donlp2 solver,setSolver Sets the desired solver,setSolver<- Sets the desired solver.

Usage

solveRQuadprog(data, spec, constraints)solveRDonlp2(data, spec, constraints)solveRlpSolve(data, spec, constraints)

Arguments

data [portfolioStatistics] -a time series or a named list, containing either a series of returns or namedentries ’mu’ and ’Sigma’ being mean and covariance matrix.

spec an S4 object of class fPFOLIOSPEC, containing slots call, model, portfolio,title, description, see PortfolioSpec for a full slot description.

constraints a character string vector, containing the constraints of the form"minW[asset]=percentage" for box constraints resp."maxsumW[assets]=percentage for sector constraints.

Author(s)

Diethelm Wuertz and Oliver Greshake for the Rmetrics port.

See Also

PortfolioData, PortfolioSpec, PortfolioConstraints, fPORTFOLIO.

Examples

## Solver RQuadprog:# Load Data:Data = as.timeSeries(data(smallcap.ts))Data = Data[, c("BKE", "GG", "GYMB", "KRON")]Data

26 PortfolioSpec

## Solve RDonlp2:# ...

## Solve RlpSolve:# ...

PortfolioSpec Specification of Portfolios

Description

A collection and description of functions to specify a portfolio. Typical specifications include modelsettings, portfolio parameters, and selection of the type of solver.

The functions are:

portfolioSpec Specifies a portfolio,setType Sets type of portfolio optimization,setEstimator Sets names of mean and covariance estimators,setParams Sets optional model parameters,setWeights Sets weights vector,setTargetReturn Sets target return value,setTargetAlpha Sets CVaR target alpha value,setRiskFreeRate Sets risk-free rate value,setNFrontierPoints Sets number of frontier points,setNFrontierPoints Sets tail dependence matrix,portfolioStatistics Estimates ’mu’ and ’Sigma’ statistics,print|show Print method for fPFOLIOSPEC objects.

Usage

portfolioSpec(model = list(type = c("MV", "CVaR"), estimator = c("mean", "cov"),tailRisk = list(), params = list()), portfolio = list(weights = NULL,targetReturn = NULL, targetRisk = NULL, targetAlpha = 0.05, riskFreeRate = 0,nFrontierPoints = 50),solver = list(solver = c("quadprog", "Rdonlp2","lpSolve"), trace = FALSE))

show.fPFOLIOSPEC(object)

setType(spec) <- valuesetEstimator(spec) <- valuesetParams(spec) <- value

setWeights(spec) <- valuesetTargetReturn(spec) <- valuesetTargetAlpha(spec) <- valuesetRiskFreeRate(spec) <- valuesetNFrontierPoints(spec) <- value

PortfolioSpec 27

setTailRisk(spec) <- value

setSolver(spec) <- valuesetTrace(spec) <- value

Arguments

estimator [setEstimator] -a character string vector, determining which estimation type should be used cal-culating mean and covariance matrix, by default "mean" and "cov" meaningfunctions mean() and cov(). Other estimators are "mcd", using an mcd estima-tor, and "shrink", using an shrinkage estimator. See section details for furtherinformation.

model [portfolioSpec] -a list, containing different arguments: type, estimator, params. See these argu-ments for further explanation.

nFrontierPoints[setNFrontierPoints] -a numeric, determining the number of equidistant steps on the frontier, by de-fault 50.

object [show] -an S4 object of class fPFOLIOSPEC, having slots call, model, portfolio, title,description. See value for slot description.

params [setParams] -a list of optional model parameters, currently not used.

portfolio [portfolioSpec] -a list, containing different arguments: weights, targetReturn, riskFreeRate, nFron-tierPoints. See these arguments for further explanation.

riskFreeRate [setRiskFreeRate] -a integer value, determining the percentage of the yearly return for a risk freeasset.

solver a character string denoting the type of the solver to be used.spec an S4 object of class fPFOLIOSPEC, the specification to be modified, by de-

fault the default of the function portfolioSpec().tailRisk a list with two matrices for the upper and lower tail dependence coefficients.targetAlpha [setTargetAlpha] -

a numerical value, setting the desired portfolio CVaR alpha.targetReturn [setTargetReturn] -

a numerical value, setting the desired portfolio return, by default return of thetangency portfolio.

targetRisk [setTargetRisk] -a numerical value, setting the desired portfolio risk, only for the dual portfoliocalculation.

type [setType] -a character string, determining which risk measure should be taken, by default"MV" meaning mean-variance. Other types are "CVaR" and "LPM".

28 PortfolioSpec

value a value for that component of spec to be set.

weights [setWeights] -a numerical vector, containing the weights of the desired optimal portfolio. Notethat the program stops if desired return and weights are set.

Details

Portfolio Specifcation Structure:

The S4 class fPFOLIOSPEC specifies the portfolio. The slots are:

@call a call, returning the matched function call.

@model a list, setting the type of portfolio to be optimized, and the mean/covariance estimatorto be applied: \ type=c("MV","CVaR") a character string denoting the type of portfolio,the implemented types are the Mean-Variance Markowitz Portfolio, "MV", and the Mean-CVaR Portfolio, "CVaR". \ estimator=c("mean","cov") a vector of two characterstrings, the first denoting the mean estimator, and the second the covariance estimator. Addi-tional meaningful selections include robust covariance estimators, e.g. c("mean","mcd"),or c("mean","shrink"). \ params=list() a list of optional model parameters, cur-rently not used.

@portfolio a list, settings portfolio parameters including predefined weights, target return, riskfree rate, number of frontier points: \ weights=NULL a numeric vector specifying theportfolio weights. \ targetReturn=NULL a numeric value specifying the target return.The default value sets the target return. \ targetAlpha=NULL a numeric value speci-fying the target alpha confidence level for CVaR portfolio optimization. The default valuesets the target return. \ riskFreeRate=0 a numeric value specifying the risk free rate. \nFrontierPoints=50 a numeric value determining the number of points on the efficientfrontier.

@solver a list, setting the type of solver to be used for portfolio optimization: \ type=c("RQuadprog","RDonlp2", "RlpSolve")

@title a title string, with a default project title.

@description a character string, with a default project description.

The function portfolioSpec() sets the values for the default specification structure. The de-fault settings can be modified using the assignment functions for the specification structure.

Model:

Type: The risk measure in use is determined by the argument model$type. Available measuresare mean-variance/Markowitz "MV", later we will add lower partial moments LPM and conditionalvalue at risk "CVaR".Estimators: The estimator(s) for the mean vector and covariance matrix are determined by theargument model$type, which is a character vector with two elements, the first for the meanand the second for the covariance matrix. Valid pairs for example are c("mean","cov"),

PortfolioSpec 29

c("mean","shrink"), or c("mean","mcd"). The latter two covariance estimators are ro-bust covariance estimators which are recommended to be used for portfolios with many assets andfew number of data records.

Portfolio:

This slot sets portfolio parameters including weights, target return, risk free rate, and number offrontier points. Note, only one of portfolio$weights or targetReturn can be set exclu-sively. If one of both is set, the other will be set to NULL.

Solver:

The default solver is the quadratic programming solver from the contributes R package quadprog,Optionally, one can use the sequential quadratic programming algorithm from Spelucci as imple-mented in the contributed R package Rdonlp2. Note, this package is not part of the Rmetricssoftware and has to be installed separately. In the case of non-linear risk budget constraints whichcan can be handled by quadprog, one has to use Rdonlp2.

Value

portfolioSpec

returns an S4 object of class "fPFOLIOSPEC".

setTypesetEstimator

Model Settings: just modify the model settings including the portfolio type, the mean/covarianceestimator, and optional parameters of an existing portfolio structure.

setWeightssetTargetReturnsetRiskFreeRatesetNFrontierPointssetReturnRangesetRiskRange

Portfolio Settings: just modify the portfolio settings including predefined weights, the target re-turn, the risk free rate, the number of frontier points, and the return and risk range of an existingportfolio structure.

setSolver

Solver Settings: just modifies the solver setting, i.e. the type of solver to be used for portfoliooptimization.

30 PortfolioSpecExtractors

Note

Using Spelucci’s solver "donlp2" requires to load the contributed R package Rdonlp2.

Author(s)

Diethelm Wuertz and Oliver Greshake for the Rmetrics port.

See Also

PortfolioData, PortfolioConstraints, fPORTFOLIO, PortfolioPlots.

Examples

## portfolioSpec -# Show Default Portfolio Specifications:Spec = portfolioSpec()# Change Risk Free RatesetRiskFreeRate(Spec) = 3Spec

## portfolioStatistics -# Load Data, i.e. a List of Returns:Data = as.timeSeries(data(smallcap.ts))Data = Data[, c("BKE", "GG", "GYMB", "KRON")]Data# Estimating Mean and Covariance with mean()and cov()portfolioStatistics(Data)# Set Covariance Estimator to "shrink" Estimator:setEstimator(Spec) = c("mean", "shrink")# Estimating Mean and Covariance MCDportfolioStatistics(Data, Spec)

PortfolioSpecExtractorsPortfolio Specification Extractors

Description

A collection and description of functions allowing to get information about an object of class fP-FOLIOSPEC.

The functions are:

getType Extract portfolio type from specification,getEstimator Extract type of covariance estimator,getEstimator Extract list of tail dependency risk matrixes,getParams Extract parameters from specification,getWeights Extracts weights from a portfolio object,

PortfolioSpecExtractors 31

getTargetReturn Extracts target return from specification,getTargetRisk Extracts target riks from specification,getTargetAlpha Extracts target VaR-alpha specification,getRiskFreeRate Extracts risk free rate from specification,getNFrontierPoints Extracts number of frontier points,getSolver Extracts solver from specification,getTrace Extracts solver’s trace flag.

Usage

## S3 method for class 'fPFOLIOSPEC':getType(object)## S3 method for class 'fPFOLIOSPEC':getEstimator(object)## S3 method for class 'fPFOLIOSPEC':getTailRisk(object)## S3 method for class 'fPFOLIOSPEC':getParams(object)

## S3 method for class 'fPFOLIOSPEC':getWeights(object)## S3 method for class 'fPFOLIOSPEC':getTargetReturn(object)## S3 method for class 'fPFOLIOSPEC':getTargetRisk(object)## S3 method for class 'fPFOLIOSPEC':getTargetAlpha(object)## S3 method for class 'fPFOLIOSPEC':getRiskFreeRate(object)## S3 method for class 'fPFOLIOSPEC':getNFrontierPoints(object)

## S3 method for class 'fPFOLIOSPEC':getSolver(object)## S3 method for class 'fPFOLIOSPEC':getTrace(object)

Arguments

object an object of class fPFOLIOSPEC.

Author(s)

Diethelm Wuertz and Oliver Greshake for the Rmetrics port.

Examples

## ...

32 RollingPortfolio

RollingPortfolio Rolling Portfolio

Description

A collection and description of functions allowing to roll a portfolio optimization over time.

The functions are:

rollingWindows Returns a list of rolling window frames,rollingCmlPortfolio Rolls a CML portfolio,rollingTangencyPortfolio Rolls a tangency portfolio,rollingMinvariancePortfolio Rolls a minimum risk portfolio,rollingPortfolioFrontier returns an efficient portfolio,portfolioBacktesting Does portfolio backtesting.

Usage

rollingWindows(x, period = "12m", by = "1m")

rollingCmlPortfolio(data, spec, constraints, from, to, action = NULL,title = NULL, description = NULL, ...)

rollingTangencyPortfolio(data, spec, constraints, from, to, action = NULL,title = NULL, description = NULL, ...)

rollingMinvariancePortfolio(data, spec, constraints, from, to, action = NULL,title = NULL, description = NULL, ...)

rollingPortfolioFrontier(data, spec, constraints, from, to, action = NULL,title = NULL, description = NULL, ...)

portfolioBacktesting(formula, data, spec = portfolioSpec(), constraints = NULL,portfolio = "minvariancePortfolio", horizon = "12m", smoothing = "6m",trace = TRUE)

Arguments

action [*Portfolio][*Frontier] -a character string naming a user defined function. This function is optionallyapplied after each rolling step.

by [rollingWindows] -a character string, by default "1m", which denotes 1 month. The shift by whichthe portfolio is rolled.

constraints [*Portfolio][*Frontier] -a character string vector, containing the constraints of the form"minW[asset]=percentage" for box constraints resp."maxsumW[assets]=percentage" for sector constraints.

RollingPortfolio 33

data [*Portfolio][*Frontier] -a list, having a statistics named list, having named entries ’mu’ and ’Sigma’,containing the information of the statistics.[*Backtesting] -

description [*Portfolio][*Frontier] -a character string, allowing for a brief project description, by default NULL, i.e.Date and User.

formula [*Backtesting] -a formula describing the benchmark and assets used for backtesting in the formbacktest ~ assetA + ... + assetZ. Here, backtest and asset*are column names of the data set.

from, to [*Portfolio][*Frontier] -a vector of S4 timeDate objects which denote the starting and ending datesfor the investigation.

horizon [*Backtesting] -a character string, by default "12m", which denotes 12 months. The period overwhich the portfolio is rolled.

period [rollingWindows] -a character string, by default "12m", which denotes 12 months. The period overwhich the portfolio is rolled.

portfolio [portfolioBacktesting] -a character string, the function name of a user defined portfolio function, whichdefines the rolling portfolio strategy.

smoothing [portfolioBacktesting] -a character string, by default "6m", which denotes 6 months. The period overwhich the rolling weights are smoothed by an exponential moving average.

spec [*Portfolio][*Frontier] -an S4 object of class fPFOLIOSPEC, containing slots call, model, portfolio,title, description, see PortfolioSpec for a full slot description.

title [*Portfolio][*Frontier] -a character string, containing the title for the object, by default NULL.

trace [portfolioBacktesting][*OptimalPortfolio] -a logical value. Should the calculataion be traced?

x [rollingWindows] -an S4 object of class timeSeries from which the rolling window frames willbe created. The length of these frames is given by the argument period andthey are shifted by the value specified by the argument by.

... optional arguments to be passed.

Details

RollingWindows: The function rollingWindows constructs from a ’timeSeries’ object win-dows frames of given length period and shift by. ...

34 VaRModelling

Rolling Portfolios:

The functions rolling*Portfolio ...

Rolling Frontier:

The function rollingPortfolioFrontier ...

Rolling Backtesting:

The functions ...

Value

rollingwindows()returns ...

rollingCmlPortfoliorollingTangencyPortfoliorollingMinvariancePortfolioreturn ...

rollingPortfolioFrontierreturns ...

portfolioBacktestingreturns ...

Author(s)

Diethelm Wuertz and Oliver Greshake for the Rmetrics port.

See Also

PortfolioClass, PortfolioData, PortfolioSpec, PortfolioConstraints.

Examples

## ...

VaRModelling Value-at-Risk Measures for Portfolios

VaRModelling 35

Description

A collection and description of functions to compute Value-at-Risk and related risk measures fora portfolio of assets. In addition utility functions are available to compute the maximum loss, tocalculate the total return, and to plot a histogram of the total return.

The functions are:

pfolioVaR computes Value-at-Risk for a portfolio of assets,pfolioCVaRplus computes Value-at-Risk+ for a portfolio of assets,pfolioCVaR computes Conditional Value-at-Risk for a PF of assets,lambdaCVaR computes CVaR’s atomic split value lambda,pfolioMaxLoss computes Maximum Loss for a portfolio of assets,pfolioReturn computes return values of a portfolio,pfolioTargetReturn computes the target return of a portfolio,pfolioTargetRisk computes the target risk of a portfolio,pfolioHist plots a histogram of the returns of a portfolio.

Usage

pfolioVaR(x, weights = NULL, alpha = 0.05)pfolioCVaRplus(x, weights = NULL, alpha = 0.05)pfolioCVaR(x, weights = NULL, alpha = 0.05)lambdaCVaR(n, alpha = 0.05)

pfolioMaxLoss(x, weights = NULL)pfolioReturn(x, weights = NULL)pfolioTargetReturn(x, weights = NULL)pfolioTargetRisk(x, weights = NULL)pfolioHist(x, weights = NULL, alpha = 0.05, range = NULL, details = TRUE, ...)

Arguments

alpha a numeric value, the confidence interval, by default 0.05.

details a logical value, should details be printed?

n the number of observation from which the CVaR’s atomic split value lambda=1-floor(alpha*n)/(alpha*n) will be evaluated.

weights usually a numeric vector which has the length of the number of assets. Theweights measures the normalized weights of the individual assets. By defaultNULL, then an equally weighted set of assets is assumed.

range a numeric vector of two elements limiting the plot range of the histogram.This is quite useful if one likes to compare several plots on the same scale. Ifrange=NULL, the default value, then the range will be selected automatically.

x a ’timeSeries’ object, data frame or any other rectangular object which can beexpressed as a matrix. The first dimension is the number of observations, wecall it n, and the second is the number of assets in the data set, we call it dim.

... optional arguments to be passet to the function hist.

36 VaRModelling

Details

The percentile measures of loss (or reward) are defined in the following way: Let f(x, y) be a lossfunctions depending upon a decision vector x = (x1, ..., xn) and a random vector y = (y1, ..., ym),then

pfolioVaR is the alpha-percentile of the loss distribution, a smallest value such that the probabilitythat losses exceed or are equal to this value is greater or equal to alpha.

pfolioCVaRplus or "CVaR+" or the "upper CVaR" are the expected losses strictly exceeding VaR.This is also also called "Mean Excess Loss" and "Expected Shortfall".

pfolioCVaR is a weighted average of VaR and CVaRplus defined as CV aR = lambda ∗ V aR +(1− lambda) CVaRplus, for 0 <= lambda <= 1.

Note, CVaR is convex, but VaR and CVaRplus may be non-convex. The following inequalities arevalid: V aR <= CV aR <= CV aRplus.

Value

pfolioVaRreturns the value of risk, VaR, for a portfolio of assets, a numeric value.

pfolioCVaRplusreturns the conditional value of risk plus, CVaRplus, for a portfolio of assets, a numeric value.

pfolioCVaRreturns the conditional value of risk, CVaR, for a portfolio of assets, a numeric value.

lambdaCVaRreturns CVaR’s atomic split value lambda, a numeric value.

pfolioMaxLossreturns the maximum loss value of the portfolio, a numeric value.

pfolioReturnreturns the total portfolio return computed from the set of assets x, a numeric vector.

pfolioTargetReturnreturns the total return or target return computed from the set of assets x and weights weights, anumeric value.

pfolioTargetRiskreturns the total risk (Sigma) or target risk computed from the set of assets x and weights via theformual sqrt(weights %*% cov(x) %*% weights), a numeric value.

pfolioHistplots a histogram of portfolio returns and adds the values for the VaR (blue), for the CVaRplus (red),and for the maximum loss (green) to the histogram plot. The function invisibly returns a list with

VaRModelling 37

the following elements: VaR, VaRplus, maxLoss, mean, and sd. If details is TRUE, then theresult is printed.

Author(s)

Diethelm Wuertz for the Rmetrics port.

References

Uryasev S. (2000); Conditional Value-at-Risk (CVaR): Algorithms and Applications, Risk Manage-ment and Financial Engineering Lab, University of Florida

Examples

## assetsSim -myAssets = 100/12 * assetsSim(n = 120, dim = 4)# Plot Cumulated Returns of the Assets:prices = apply(myAssets, 2, FUN = cumsum)par(mfrow = c(2, 1), cex = 0.7)ts.plot(prices, col = 1:4, ylim = c(-300, 300))legend(0, 300, legend = colnames(myAssets), pch = "----", col = 1:4)title(main = "Cumulated Returns", ylab = "Cumulated Returns")abline(h = 0, lty = 3)

## pfolioCVaR -equalWeights = rep(1/4, 4)alpha = 0.10# Value at Risk:pfolioVaR(myAssets, equalWeights, alpha)# Conditional Value at Risk Plus:pfolioCVaRplus(myAssets, equalWeights, alpha)# Conditional Value at Risk Plus:pfolioCVaR(myAssets, equalWeights, alpha)# Lambda - Atomic Split Value:lambdaCVaR(120, alpha)

## pfolioHist -# Maximum Loss Value of the PortfoliopfolioMaxLoss(myAssets, equalWeights)# Compute Portfolio Returns:r = pfolioReturn(myAssets, equalWeights)head(r)# Target Return and Target Risk:pfolioTargetReturn(myAssets, equalWeights)pfolioTargetRisk(myAssets, equalWeights)# Plot:pfolioHist(myAssets, equalWeights, alpha, n = 20)

38 donlp2

donlp2 Solve constrained nonlinear minimization problem

Description

Solve constrained nonlinear minimization problem.

Usage

rdonlp2(par, fn,par.upper=rep(+Inf, length(par)), par.lower=rep(-Inf, length(par)),A = NULL,lin.upper = rep(+Inf, length(par)), lin.lower = rep(-Inf, length(par)),nlin = list(),nlin.upper = rep(+Inf, length(nlin)), nlin.lower = rep(-Inf, length(nlin)),control = rdonlp2Control(), control.fun = function(lst){return(TRUE)},env = .GlobalEnv, name = NULL)

Arguments

fn the objective function to be minimized. Currently, fn must take only one argu-ment, and the parameter vector(par) will be passed to fn during the optimiza-tion. The first element of return value must be the evaluated value.

par parameter vector(vector object).par.upper, par.lower

upper and lower bounds for parameter vector, respectively. Their length mustequal to length(par). If some elements are unbounded, specify +Inf or-Inf explicitly.

A the matrix object that represents linear constraints. Its columns must be equal tolength(par), and its rows must be equal to the number of linear constraints.

lin.upper, lin.lowerupper and lower bounds for linear constraints, respectively. Their length mustequal to the number of linear constraints. If some elements are unbounded,specify +Inf or -Inf explicitly.

nlin list object whose elements are functions that represents nonlinear constraints.Rule for argument and return value is the same as fn, i.e., these functions takeonly one arugument(par), and return a vector object whose first element is theevaluated value.

nlin.upper, nlin.lowerupper and lower bounds for nonlinear constraints, respectively. Their lengthmust equal to length(nlin). If some elements are unbounded, specify+Inf or -Inf explicitly.

control "control parameters" that defines the behavior of Rdonlp2. See rdonlp2Controlfor details.

donlp2 39

control.fun rdonlp2() reports a group of optimization parameters in every iteration(seebelow for details). This (read-only) information can be available within control.fun(),in which user can decide whether the optimization should be iterrupted. Set itsreturn value to FALSE to interrupt rdonlp2().

env the environment in which objective, constraint, control functions are evaluated.

name an character object that specify file name(without extension, max 40 characters)of output file. If not NULL, DONLP2 creates 2 files(name.pro and name.mes)in current working directory which contain detailed information during the opti-mization. The amount of information depends te0,te1,te2,te3 specifiedin rdonlp2Control.

Value

For n=length(par) parameters, lin linear constraints, and nlin nonlinear constraints, a listwith following elements:

par parameters returned by DONLP2.

gradf gradient evaluated at par.

u 2*(n+lin+nlin) vector of lagrange multipliers for constraints.

w 2*(n+lin+nlin) vector of penalty term.

step.nr total number of iterations.

fx the value of objective function fn.

sci scaling of fn.

psi psi the weighted penalty term.

upsi the unweighted penalty term(L1 norm of constraint vector).

del.k.1 bound for the last active constraints.

b2n0 weighted L2 norm of projected gradients.

b2n L2norm of gradients based on del.k.1.

nr number of binding constraints.

sing value other than -1 indicates working set is singular.

umin infinity norm of negative part of inequalities multipliers.

not.used always 0(currently not used).

cond.r condition number of diagonal part of qr decomposition of normalized gradientsof binding constraints.

cond.h condition number of diagonal of cholesky factor of updated full Hessian.

scf0 the relative damping of tangential component if upsi > tau0/2.

xnorm L2 norm of par.

dnorm unsclaed norm of d, correction from eqp/qp subproblem.

phase -1:infeasibility improvement phase, 0: initial optimization, 1:binding constraintsunchanged, 2:d small, maratos correction is in use.

c.k number of decreases of penalty weights.

40 donlp2

wmax infinity norm of weights.

sig.k stepsize from uidimensional minimization(backgracking).

cfincr number of objective function evaluations for stepsize algorithm

dirder scaled derectional derivative of penalty function along d.

dscal scaling factor for d.

cosphi cosine of arc between d and previous d.

violis number of constraints not binding at current values of par but hit during linesearch.

hesstype one of 4 values indicating type of update for Hessian. 1: normal P&M-BFGSupdate, 0: update suppressed, -1: restart with scaled unit matrix, 2: standardBFGS, 3: BFGS modified by Powell’s Device.

modbifgs modification factor for damping the projector into the BFGS or pantoja-mayneupdate.

modnr modification factor for daming the quasi-newton-relation in BFGS.

qpterm 0:if sing==-1, termination indicator of the QP solver, 1:successful, -1:tau becomes larger than tauqp without slack variables becoming sufficientlysmall.

tauqp weight of slack variables in QP solver.

infeas L1 norm of slack variables in QP solver.

nr.update the approximated newton-raphson update in upper trianglar form.

hessian numeric Hessian matrix if hessian=TRUE in rdonlp2Control.

runtime the elapsed time for the optimization.

message the termination message.

Note

IMPORTANT: Due to license reasons the R package Rdonlp2 is not part of the Rmetrics distribu-tion. You can download and install the package fromhttps://svn.r-project.org/Rmetrics/trunk/Rdonlp2/

Author(s)

Rdonlp2(R port) is copyrighted by Ryuichi Tamura. Original DONLP2 is copyrighted softwarewritten by Peter Sperucci.

References

http://plato.la.asu.edu/donlp2.html(original DONLP2), http://arumat.net/Rdonlp2/(Rdonlp2)

See Also

rdonlp2Control

donlp2Control 41

donlp2Control Control variables for Rdonlp2

Description

Collection of Control Variables

Usage

rdonlp2Control(iterma = 4000, nstep = 20,fnscale = 1, report = FALSE,rep.freq = 1, tau0 = 1.0, tau = 0.1, del0 = 1.0, epsx = 1e-5,delmin = 0.1*del0, epsdif = 1e-8, nreset.multiplier = 1,difftype = 3,epsfcn = 1e-16,taubnd = 1.0, hessian = FALSE,te0 = TRUE, te1 = FALSE, te2 = FALSE, te3 = FALSE, silent = FALSE,intakt = TRUE)

Arguments

iterma maximum number of iterations.

nstep maximum number of tries in the backtracking.

fnscale set -1 to maximize the object function.

report If TRUE, a list object which contains detailed information will be passed tocontrol.fun() in donlp2.

rep.freq the frequency of report(positive integer). the report will be passed to control.funevery rep.freq iterations.

tau0 the positive amount how much any constaint other than abound can be violated.A small tau0 diminishes the efficiency of DONLP2, while a large tau0 maydegarde the reliability of the code.

tau gives a weight between descent for fn and infeasibility and is also used as asafety parameter for chosing the penalty weigths. It can be chosen larger zero atwill, but useful values are between 0.1 and 1. The smaller tau, the more may fnbe scaled down. Tau is also used as an additive increase for the penalty-weights.Therefore it should not be chosen too large, since that degrades the performance.

del0 The positive amount by which constraints are considered binding. If too small,the indentification of correct sets of binding constraints may be delayed. If toolarge, DONLP2 will escape to the full regularlized SQP method(quite costly).Good values are in [0.01, 1.0].

epsx successful temination is indicated if the Kuhn-Tucker criteria are satisfied withinthe value.

delmin constraints are considered as sufficiently satisfied if absolute values of their vi-olation are less than the value.

epsdif relative precision in the gradients.

42 Portfolio

nreset.multipliermaximum number of steps (nreset.multiplier times n) until a “restart”of the accumulated quasi-newton-update is tried. Value should be integer be-tween 1 and 4.

difftype 1,2,3. numerical differentiation algorithm. The algorithm with difftype=2is nearly identical to one used in optim(). See PDF manual attached in thispackage.

epsfcn relative precision of the function evaluation routine.

taubnd The positive amount by which bounds may be violated if numerical differentionis used.

hessian if TRUE, numeric Hessian matrix is calculated by numerical differentiation al-gorithm specified in difftype.

intakt if TRUE, informations about current iteration step in optimization and final re-sults are output to R console. The amount of information depends on te0, te1,te2, te3.

te0 if TRUE one-line-output for every step is printed.

te1 if TRUE post-mortem-dump of accumlated information is printed.

te2 if TRUE, more detailed information is “pretty-printed”.

te3 if TRUE, the gradients and approximated Newton-Raphson updates(in uppertriangler matrix) are printed.

silent If TRUE, donlp2() runs quietly, i.e., intakt=FALSE, .pro/.mes files are notcreated, and te0,te1,te2,te3 are omitted.

See Also

rdonlp2

Portfolio Portfolio Modelling, Optimization and Benchmarking

Description

A collection and description of functions for portfolio modelling, pptimization and benchmarking.

Details

Assets Modelling:

Functions for the analysis, simulation and parameter estimation of financial assets.

Portfolio Optimization: Functions for the optimization of portfolios including the mean-varianceMarkowitz approach, "MV", the lower partial moment portfolio approach "PM", and the conditionalvalue-at-risk approach "CVaR".

Portfolio 43

Benchmarkung: Functions for the scenario analysis, portfolio performance measures, and bench-marking.

Index

∗Topic dataPortfolioDataSets, 17

∗Topic distributionDrawdownStatistics, 1

∗Topic mathVaRModelling, 34

∗Topic modelsExtractors, 3Portfolio, 41PortfolioClass, 5PortfolioClassExtractors, 10PortfolioConstraints, 12PortfolioData, 14PortfolioDataExtractors, 16PortfolioPlots, 18PortfolioSlider, 21PortfolioSolver, 24PortfolioSpec, 25PortfolioSpecExtractors, 30RollingPortfolio, 31

∗Topic optimizedonlp2, 37donlp2Control, 40

altInvest (PortfolioDataSets), 17annualInvest (PortfolioDataSets),

17assetsCorr (PortfolioDataSets), 17attributesPie (PortfolioPlots), 18attributesPlot (PortfolioPlots),

18

berndtInvest (PortfolioDataSets),17

cmlPortfolio (PortfolioClass), 5covEllipsesPlot (PortfolioPlots),

18covRiskBudgetsPie

(PortfolioPlots), 18

covRiskBudgetsPlot(PortfolioPlots), 18

dmaxdd (DrawdownStatistics), 1donlp2, 37, 40donlp2Control, 40DrawdownStatistics, 1

efficientPortfolio(PortfolioClass), 5

equityFunds (PortfolioDataSets),17

Extractors, 3

feasiblePortfolio(PortfolioClass), 5

fPFOLIODATA (PortfolioData), 14fPFOLIODATA-class

(PortfolioData), 14fPFOLIOSPEC (PortfolioSpec), 25fPfoliospec (PortfolioSpec), 25fPFOLIOSPEC-class

(PortfolioSpec), 25fPORTFOLIO, 14, 16, 20, 25, 29fPORTFOLIO (PortfolioClass), 5fPORTFOLIO-class

(PortfolioClass), 5frontierPlot (PortfolioPlots), 18frontierSlider (PortfolioSlider),

21

getConstraints (Extractors), 3getConstraints.fPORTFOLIO

(PortfolioClassExtractors),10

getCovRiskBudgets (Extractors), 3getCovRiskBudgets.fPORTFOLIO

(PortfolioClassExtractors),10

getData (Extractors), 3

44

INDEX 45

getData.fPFOLIODATA(PortfolioDataExtractors),16

getData.fPORTFOLIO(PortfolioClassExtractors),10

getEstimator (Extractors), 3getEstimator.fPFOLIOSPEC

(PortfolioSpecExtractors),30

getEstimator.fPORTFOLIO(PortfolioClassExtractors),10

getFrontier (Extractors), 3getFrontier.fPORTFOLIO

(PortfolioClassExtractors),10

getMu (Extractors), 3getMu.fPFOLIODATA

(PortfolioDataExtractors),16

getNames (Extractors), 3getNames.fPFOLIODATA

(PortfolioDataExtractors),16

getNFrontierPoints (Extractors), 3getNFrontierPoints.fPFOLIOSPEC

(PortfolioSpecExtractors),30

getNFrontierPoints.fPORTFOLIO(PortfolioClassExtractors),10

getNumberOfAssets (Extractors), 3getNumberOfAssets.fPFOLIODATA

(PortfolioDataExtractors),16

getNumberOfAssets.fPORTFOLIO(PortfolioClassExtractors),10

getParams (Extractors), 3getParams.fPFOLIOSPEC

(PortfolioSpecExtractors),30

getParams.fPORTFOLIO(PortfolioClassExtractors),10

getPortfolio (Extractors), 3getPortfolio.fPORTFOLIO

(PortfolioClassExtractors),10

getRiskFreeRate (Extractors), 3getRiskFreeRate.fPFOLIOSPEC

(PortfolioSpecExtractors),30

getRiskFreeRate.fPORTFOLIO(PortfolioClassExtractors),10

getSeries (Extractors), 3getSeries.fPFOLIODATA

(PortfolioDataExtractors),16

getSeries.fPORTFOLIO(PortfolioClassExtractors),10

getSigma (Extractors), 3getSigma.fPFOLIODATA

(PortfolioDataExtractors),16

getSolver (Extractors), 3getSolver.fPFOLIOSPEC

(PortfolioSpecExtractors),30

getSolver.fPORTFOLIO(PortfolioClassExtractors),10

getSpec (Extractors), 3getSpec.fPORTFOLIO

(PortfolioClassExtractors),10

getStatistics (Extractors), 3getStatistics.fPFOLIODATA

(PortfolioDataExtractors),16

getStatistics.fPORTFOLIO(PortfolioClassExtractors),10

getStatus.fPORTFOLIO(PortfolioClassExtractors),10

getTailRisk (Extractors), 3getTailRisk.fPFOLIODATA

(PortfolioDataExtractors),16

getTailRisk.fPFOLIOSPEC(PortfolioSpecExtractors),30

46 INDEX

getTailRiskBudgets (Extractors), 3getTailRiskBudgets.fPORTFOLIO

(PortfolioClassExtractors),10

getTargetAlpha (Extractors), 3getTargetAlpha.fPFOLIOSPEC

(PortfolioSpecExtractors),30

getTargetAlpha.fPORTFOLIO(PortfolioClassExtractors),10

getTargetReturn (Extractors), 3getTargetReturn.fPFOLIOSPEC

(PortfolioSpecExtractors),30

getTargetReturn.fPORTFOLIO(PortfolioClassExtractors),10

getTargetRisk (Extractors), 3getTargetRisk.fPFOLIOSPEC

(PortfolioSpecExtractors),30

getTargetRisk.fPORTFOLIO(PortfolioClassExtractors),10

getTrace (Extractors), 3getTrace.fPFOLIOSPEC

(PortfolioSpecExtractors),30

getTrace.fPORTFOLIO(PortfolioClassExtractors),10

getType (Extractors), 3getType.fPFOLIOSPEC

(PortfolioSpecExtractors),30

getType.fPORTFOLIO(PortfolioClassExtractors),10

getWeights (Extractors), 3getWeights.fPFOLIOSPEC

(PortfolioSpecExtractors),30

getWeights.fPORTFOLIO(PortfolioClassExtractors),10

jobstCov (PortfolioDataSets), 17

lambdaCVaR (VaRModelling), 34largecap.ts (PortfolioDataSets),

17LPP2005REC (PortfolioDataSets), 17

maxddStats (DrawdownStatistics), 1microcap.ts (PortfolioDataSets),

17midcap.ts (PortfolioDataSets), 17midcapD.ts (PortfolioDataSets), 17minvariancePortfolio

(PortfolioClass), 5

pfolioCVaR (VaRModelling), 34pfolioCVaRplus (VaRModelling), 34pfolioHist (VaRModelling), 34pfolioMaxLoss (VaRModelling), 34pfolioReturn (VaRModelling), 34pfolioSigma (VaRModelling), 34pfolioTargetReturn

(VaRModelling), 34pfolioTargetRisk (VaRModelling),

34pfolioVaR (VaRModelling), 34plot.fPORTFOLIO (PortfolioClass),

5pmaxdd (DrawdownStatistics), 1points, 8, 22Portfolio, 41portfolio (Portfolio), 41portfolioBacktesting

(RollingPortfolio), 31portfolioBacktestingStats

(RollingPortfolio), 31PortfolioClass, 5, 23, 34PortfolioClassExtractors, 10PortfolioConstraints, 9, 12, 16, 20,

23, 25, 29, 34portfolioConstraints

(PortfolioConstraints), 12PortfolioData, 9, 14, 14, 20, 23, 25, 29,

34portfolioData (PortfolioData), 14PortfolioDataExtractors, 16PortfolioDataSets, 17portfolioFrontier

(PortfolioClass), 5PortfolioPlots, 9, 14, 16, 18, 23, 29PortfolioSlider, 21

INDEX 47

PortfolioSolver, 24PortfolioSpec, 6, 7, 9, 14, 16, 20, 23, 25,

25, 33, 34portfolioSpec (PortfolioSpec), 25PortfolioSpecExtractors, 30portfolioStatistics

(PortfolioData), 14

rdonlp2, 41rdonlp2 (donlp2), 37rdonlp2Control, 38–40rdonlp2Control (donlp2Control), 40returns.three.ts

(PortfolioDataSets), 17rmaxdd (DrawdownStatistics), 1rollingCmlPortfolio

(RollingPortfolio), 31rollingMinvariancePortfolio

(RollingPortfolio), 31RollingPortfolio, 31rollingPortfolioFrontier

(RollingPortfolio), 31rollingTangencyPortfolio

(RollingPortfolio), 31rollingWindows

(RollingPortfolio), 31

setEstimator<- (PortfolioSpec), 25setNFrontierPoints<-

(PortfolioSpec), 25setParams<- (PortfolioSpec), 25setRiskFreeRate<-

(PortfolioSpec), 25setSolver<- (PortfolioSpec), 25setTailRisk<- (PortfolioSpec), 25setTargetAlpha<- (PortfolioSpec),

25setTargetReturn<-

(PortfolioSpec), 25setTrace<- (PortfolioSpec), 25setType<- (PortfolioSpec), 25setWeights<- (PortfolioSpec), 25show,fPFOLIODATA-method

(PortfolioData), 14show,fPFOLIOSPEC-method

(PortfolioSpec), 25show,fPORTFOLIO-method

(PortfolioClass), 5

show.fPFOLIODATA (PortfolioData),14

show.fPFOLIOSPEC (PortfolioSpec),25

show.fPORTFOLIO (PortfolioClass),5

smallcap.ts (PortfolioDataSets),17

solveRDonlp2 (PortfolioSolver), 24solveRlpSolve (PortfolioSolver),

24solveRQuadprog (PortfolioSolver),

24summary.fPORTFOLIO

(PortfolioClass), 5SWXLP (PortfolioDataSets), 17

tailRiskBudgetsPie(PortfolioPlots), 18

tailRiskBudgetsPlot(PortfolioPlots), 18

tangencyPortfolio(PortfolioClass), 5

vanIndices (PortfolioDataSets), 17VaRModelling, 34

weightsPie (PortfolioPlots), 18weightsPlot (PortfolioPlots), 18weightsSlider (PortfolioSlider),

21