Learn R Programming

fPortfolio (version 240.10068)

MarkowitzPortfolio: Markowitz Portfolio

Description

A collection and description of functions to investigate the efficient frontier for a Markowitz portfolio from a given return series in the mean-variance sense when short selling is forbidden. Tangency, equal weigths, and Monte Carlo portfolios can also be evaluated. The functions are: ll{ portfolioMarkowitz Optimize mean variance Markowitz portfolio, frontierMarkowitz computes efficient frontier of portfolio, montecarloMarkowitz creates randomly created portfolios. }

Usage

portfolioMarkowitz(x, targetReturn, title = NULL, description = NULL)
frontierMarkowitz(data, Rf = 0, short = FALSE, length = 300, r.range = NULL, 
    s.range = NULL, title = NULL, description = NULL, ...)
montecarloMarkowitz(object, mc = 5000, doplot = FALSE, add = TRUE, ...)

## S3 method for class 'fPFOLIO': print(x, \dots) ## S3 method for class 'fPFOLIO': plot(x, alpha = 0.05, mc = 500, which = "ask", \dots) ## S3 method for class 'fPFOLIO': summary(object, \dots)

Arguments

alpha
a numeric value, the confidence interval, by default 0.05.
data
[frontierMarkowitz] - either a rectangular time series object which can be transformed into a matrix, or a list with two named entries, mu, the returns of the multivariate series, and Sigma, the covarianc
description
[portfolioMarkowitz][frontierMarkowitz] - a character string, assigning a brief description to an "fPFOLIO" object.
doplot, add
[frontierMarkowitz] - logical values. Should the results be plotted and/or added to the frontier plot?
length
[frontierMarkowitz] - the number of equidistand return points on the efficient frontier.
mc
the number of Monte Carlo portfolios.
method
[portfolioMarkowitz] - the optimization method.
object
a object of class "fPFOLIO" representing a portfolio. A list with with elemets listed in the "Value" section.
r.range, s.range
[frontierMarkowitz] - the range of returns and standardard deviations on the efficient frontier. If set to NULL, the default value, then the whole efficient frontier will be investigated.
Rf
[frontierMarkowitz] - the number of random portfolios to be generated.
short
[frontierMarkowitz] - a logical flag, if set to TRUE short selling would be allowed otherwise not wich is the default setting.
targetReturn
[portfolioMarkowitz] - the target return, a numeric value.
title
[portfolioMarkowitz][frontierMarkowitz] - a character string, assigning a title to an "fPFOLIO" object.
which
which of the five 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 6 logical
x
[frontierMarkowitz] - a numeric matrix or multivariate time series consisting of a series of returns. [print][plot] - an object of class "fPFOLIO" representing a portfolio. A list with with elemets listed in the "Value" se
...
parameters to be passed.

Value

  • portfolioMarkowitz frontierMarkowitz return a S4 object class of class "fPFOLIO", with the following slots:
  • @callthe matched function call.
  • @datathe input data in form of a data.frame.
  • @descriptionallows for a brief project description.
  • @pfoliothe results as a list returned from the underlying optimization process.
  • @methodthe selected method used by the optimization algorithm, here "Quadratic Programming".
  • @modelthe model used for the optimization, here "Mean variance Portfolio Optimization".
  • @titlea title string.
  • The @pfolio slot is a list with the following compontents: (Note, not all are documented here).
  • pm, psthe portfolios mean (the return) and standard deviation (the risk) values .
  • returns, covthe returns vector and the covariance matrix of the assets.
  • r.range, s.rangethe range of returns and of the standard deviations on the efficient frontier.
  • Rfthe risk free rate.
  • Rm, Smreturn and standard deviation of the tangency portfolio.
  • t.weightsthe weights of the tangency portfolio.
  • Rew, SewReturn and standard deviation of the equal weights portfolio.
  • diversificationthe number of assets contributing with more than one percent to the efficient frontier portfolio as function of expected returns.
  • montecarloMarkowitz is a functions which adds random generated portfolios to frontier plot. print is the S3 print method for objects of class "fPFOLIO" returned from the function mvFit. If shows a summary report of the optimization results. plot is the S3 plot method for objects of class "fPFOLIO". Six plots are produced. The first plot produces a Risk-Return-Graph with the individual assets, the efficient frontier, the market line, tangency portfolio and the equal weights portfolio. The second plot is the same as the first, however, the risk and return values for random generated portfolios are added. The third plot generates a pie chart of weights for the tangency portfolio. The third plot generates a pie chart of weights for the tangency portfolio. The fourth plot shows the effect of diversification. The fivth plot shows the cumulated returns for the tangency portfolio. The sixth plot shows a histogram of the tangency portfolio returns together with the maximum loss, the condition Value-at-Risk and the upper CVaR. summary is the S3 summary method for objects of class "fPFOLIO". The summary method prints and plots in one step the results as done by the print and plot methods.

References

Elton E.J., Gruber M.J. (1991); Modern Portfolio Theory and Investment Analysis, 4th Edition, Wiley, NY, pp. 65--93.

Huang C.J., Litzenberger R.H. (1988); Foundations for Financial Economics, Elsevier, NY, pp. 59--82.

Examples

Run this code
## SOURCE("fPortfolio.102C-MarkowitzPortfolio")

## berndtInvest -
   data(berndtInvest)
   # Exclude Date, Market and Interest Rate columns from data frame,
   # then multiply by 100 for percentual returns ...
   berndtAssets = berndtInvest[, -c(1, 11, 18)]
   rownames(berndtAssets) = berndtInvest[, 1]
   head(berndtAssets)
   
## portfolioMarkowitz - 
   myPortfolio = portfolioMarkowitz(x = berndtAssets, targetReturn = 20/100/12)
   print(myPortfolio)
   
## pfolioTargetReturn -
## pfolioTargetRisk -
   pfolioTargetReturn(x = berndtAssets, weights = myPortfolio@pfolio$pw)
   pfolioTargetRisk(x = berndtAssets, weights = myPortfolio@pfolio$pw)

Run the code above in your browser using DataLab