PortfolioSpec {fPortfolio}R Documentation

Specification of Portfolios

Description

A collection and description of functions to specify a portfolio. Typical specifications include model settings, 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) <- value
setEstimator(spec) <- value
setParams(spec) <- value

setWeights(spec) <- value
setTargetReturn(spec) <- value
setTargetAlpha(spec) <- value
setRiskFreeRate(spec) <- value
setNFrontierPoints(spec) <- value
setTailRisk(spec) <- value

setSolver(spec) <- value
setTrace(spec) <- value

Arguments

estimator [setEstimator] -
a character string vector, determining which estimation type should be used calculating mean and covariance matrix, by default "mean" and "cov" meaning functions mean() and cov(). Other estimators are "mcd", using an mcd estimator, and "shrink", using an shrinkage estimator. See section details for further information.
model [portfolioSpec] -
a list, containing different arguments: type, estimator, params. See these arguments for further explanation.
nFrontierPoints [setNFrontierPoints] -
a numeric, determining the number of equidistant steps on the frontier, by default 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, nFrontierPoints. See these arguments for further explanation.
riskFreeRate [setRiskFreeRate] -
a integer value, determining the percentage of the yearly return for a risk free asset.
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 default 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 the tangency portfolio.
targetRisk [setTargetRisk] -
a numerical value, setting the desired portfolio risk, only for the dual portfolio calculation.
type [setType] -
a character string, determining which risk measure should be taken, by default "MV" meaning mean-variance. Other types are "CVaR" and "LPM".
value a value for that component of spec to be set.
weights [setWeights] -
a numerical vector, containing the weights of the desired optimal portfolio. Note that 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 estimator to 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 character strings, the first denoting the mean estimator, and the second the covariance estimator. Additional meaningful selections include robust covariance estimators, e.g. c("mean","mcd"), or c("mean","shrink").
params=list() a list of optional model parameters, currently not used.
@portfolio
a list, settings portfolio parameters including predefined weights, target return, risk free rate, number of frontier points:
weights=NULL a numeric vector specifying the portfolio weights.
targetReturn=NULL a numeric value specifying the target return. The default value sets the target return.
targetAlpha=NULL a numeric value specifying the target alpha confidence level for CVaR portfolio optimization. The default value sets 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 efficient frontier.
@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 default 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 measures are mean-variance/Markowitz "MV", later we will add lower partial moments LPM and conditional value at risk "CVaR".
Estimators: The estimator(s) for the mean vector and covariance matrix are determined by the argument model$type, which is a character vector with two elements, the first for the mean and the second for the covariance matrix. Valid pairs for example are c("mean","cov"), c("mean","shrink"), or c("mean","mcd"). The latter two covariance estimators are robust covariance estimators which are recommended to be used for portfolios with many assets and few number of data records.

Portfolio:

This slot sets portfolio parameters including weights, target return, risk free rate, and number of frontier points. Note, only one of portfolio$weights or targetReturn can be set exclusively. 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 implemented in the contributed R package Rdonlp2. Note, this package is not part of the Rmetrics software and has to be installed separately. In the case of non-linear risk budget constraints which can can be handled by quadprog, one has to use Rdonlp2.

Value

portfolioSpec

returns an S4 object of class "fPFOLIOSPEC".
setType
setEstimator

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

setWeights
setTargetReturn
setRiskFreeRate
setNFrontierPoints
setReturnRange
setRiskRange

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

setSolver

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

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 Rate
   setRiskFreeRate(Spec) = 3
   Spec

## 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 MCD
   portfolioStatistics(Data, Spec)

[Package fPortfolio version 260.72 Index]