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. }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
fPFOLIOSPEC
, having slots call, model,
portfolio, title, description. See value
for slot description.fPFOLIOSPEC
, the specification to be
modified, by default the default of the function portfolioSpec()
.spec
to be set.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.
fPFOLIOSPEC
specifies the portfolio. The slots
are:
[object Object],[object Object],[object Object],[object Object],[object Object],[object Object]
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
.PortfolioData
,
PortfolioConstraints
,
fPORTFOLIO
,
PortfolioPlots
.## 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)
Run the code above in your browser using DataLab