Learn R Programming

fPortfolio (version 280.73)

frontierPlot: Efficient Frontier Plot

Description

Plots the efficient frontier of an optimized portfolio and allows to add points and lines from specif portfolios The functions are: ll{ frontierPlot Plots efficient frontier, minvariancePoints Adds minimum variance point, cmlPoints Adds market portfolio, cmlLines Adds capital market Line, tangencyPoints Adds tangency portfolio point, tangencyLines Adds tangency line, equalWeightsPoints Adds point of equal weights portfolio, singleAssetPoints Adds points of single asset portfolios, twoAssetsLines Adds EF for all combinations of two assets, sharpeRatioLines Adds Sharpe ratio line, monteCarloPoints Adds randomly produced feasible portfolios. }

Usage

frontierPlot(object, frontier = c("both", "lower", "upper"),
    col = c("black", "grey"), add = FALSE, labels = TRUE,
    return = c("mean", "mu"), risk = c("Cov", "Sigma", "CVaR", "VaR"),
    auto = TRUE, title = TRUE, ...) 

minvariancePoints(object, return = c("mean", "mu"), risk = c("Cov", "Sigma", "CVaR", "VaR"), auto = TRUE, ...) cmlPoints(object, return = c("mean", "mu"), risk = c("Cov", "Sigma", "CVaR", "VaR"), auto = TRUE, ...) cmlLines(object, return = c("mean", "mu"), risk = c("Cov", "Sigma", "CVaR", "VaR"), auto = TRUE, ...) tangencyPoints(object, return = c("mean", "mu"), risk = c("Cov", "Sigma", "CVaR", "VaR"), auto = TRUE, ...) tangencyLines(object, return = c("mean", "mu"), risk = c("Cov", "Sigma", "CVaR", "VaR"), auto = TRUE, ...) equalWeightsPoints(object, return = c("mean", "mu"), risk = c("Cov", "Sigma", "CVaR", "VaR"), auto = TRUE, ...) singleAssetPoints(object, return = c("mean", "mu"), risk = c("Cov", "Sigma", "CVaR", "VaR"), auto = TRUE, ...) twoAssetsLines(object, return = c("mean", "mu"), risk = c("Cov", "Sigma", "CVaR", "VaR"), auto = TRUE, ...) sharpeRatioLines(object, return = c("mean", "mu"), risk = c("Cov", "Sigma", "CVaR", "VaR"), auto = TRUE, ...)

monteCarloPoints(object, mcSteps = 5000, return = c("mean", "mu"), risk = c("Cov", "Sigma", "CVaR", "VaR"), auto = TRUE, ...)

Arguments

object
an S4 object of class fPORTFOLIO, containing slots call, data, specification, constraints, portfolio, title, description.
frontier
a character string, determining which part of the frontier should be extracted. "both" stands for the full hyperbola, "lower" for all points below the minimum variance return and "upper" for t
col
a character string vector, setting the color. For frontierPlot it is a two dimensional a vector; first entry is the upper part of the frontier, second entry the lower, by default "black" and "grey". For the other functions th
add
a logical value, determining whether the frontier should be added to an existing plot, by default FALSE.
return
a character string denoting which type of return should be plotted. Allowed values for the return are either "mean", or "mu".
risk
a character string denoting which type of risk should be plotted. Allowed values for the risk measure are either "cov", "sigma", "VaR", or "CVaR".
auto
a logical flag denoting if the type of return and risk to be plotted should be selected automatically, by default TRUE.
labels
a logical flag, should the plot be automatically labeled and decorated? By default TRUE.
title
a logical flag, should the plot obtain a default main title and x- and y-labels? By default TRUE.
mcSteps
an integer value, the number of Monte Carlo steps.
...
optional arguments to be passed.

Details

Frontier Plot: The frontierPlot function allows to plot the efficient frontier. Selecting the upper and/or lower part of the frontier: One can choose one from three different plot options selectable by the argument frontier. The part superior to the minimum variance portfolio is plotted with argument frontier="upper". The part below is plotted with frontier="lower". Both parts are plotted with frontier="both", which is default. Selecting the color of the frontier points: Different colors for the lower and upper part are selected from the argument col, the defaults are grey and black, the first for the lower part of the frontier, thye second for the upper part. Plotting the frontiers for several portfolios in one plot: The function comes with an argument add. If add=FALSE then a new plot is opended displaying the frontier for the selected portfolio. On the other hand setting add=TRUE allows to add new efficient frontiers from other portfolios to the same plot. Removing labels from the plot: By default we have labels=TRUE and thus additional information is plotted on the third side of the graph. To discard this information one has to set labels = FALSE. Adding user supplied title and axis-labels: By default we have title=TRUE and thus a default main title and default x- and y-labels are automatically added. To discard this kind of decoration set title=FALSE. Then using the function title allows to add user specified titles and axis-labels. The dot arguments: With the ... arguments one can pass additional arguments to the internal plot and points functions.

Examples

Run this code
## data -
   # Load Data:
   Data = as.timeSeries(data(smallcap.ts))
   Data = Data[, c("BKE", "GG", "GYMB", "KRON")]
   Data

## portfolioFrontier -
   # Compute Long Only Efficient Frontier
   Frontier = portfolioFrontier(Data)
   Frontier
   
## frontierPlot -  
   # Plot Upper Part of Frontier:
   frontierPlot(Frontier, pch = 19, xlim = c(0, 0.25), ylim = c(0, 0.035))
   grid()
   abline(h = 0, col = "grey")
   abline(v = 0, col = "grey")
   
## Plot Addons:
   minvariancePoints(Frontier, pch = 19, col = "red")
   tangencyPoints(Frontier, pch = 19, col = "blue")
   tangencyLines(Frontier, col = "blue")
   equalWeightsPoints(Frontier, pch = 15, col = "grey")
   singleAssetPoints(Frontier, pch = 19, cex = 1.5, col = topo.colors(6))
   twoAssetsLines(Frontier, lty = 3, col = "grey")
   sharpeRatioLines(Frontier, col = "orange", lwd = 2)

## Feasible Portfolios:
   frontierPlot(Frontier, col = c("orange", "orange"), pch = 19)
   monteCarloPoints(Frontier, mcSteps = 5000, cex = 0.25, pch = 19)
   twoAssetsLines(Frontier, lwd = 2, col = "orange")

Run the code above in your browser using DataLab