| pputil.value {pprobeSup} | R Documentation |
Returns a "utility" based on the scenarios of the portfolio value – one number for each random portfolio.
pputil.value(rp, scenarios, level = NULL, verbose = FALSE) pputil.valueWt(rp, scenarios, sweights, level = NULL, verbose = FALSE)
rp |
a random portfolio object. |
scenarios |
a three-dimensional array: times in rows, assets in columns and scenarios in the third dimension. |
sweights |
a vector of weights for the scenarios.
This needs to have the same length as the number of scenarios
in the |
level |
if Otherwise, should be a number between 0 and 1 giving the quantile of the utility to return. |
verbose |
logical value, if |
a numeric vector as long as the number of random portfolios. The utility for each portfolio and scenario is the portfolio value.
For pputil.value the mean or level quantile of the
portfolio values (across scenarios) is returned for each random
portfolio.
For pputil.valueWt the weighted mean or level
weighted quantile of the portfolio values (across scenarios)
is returned for each random portfolio.
if verbose is TRUE, then printing is done.
In test suite, mildly tested.
This help file was last revised 2013 May 02.
scenario.optimizer, pputil.fourmoments,
pputil.meanvar, pputil.omega.
# maximize expected value
meanvalueOpt <- scenario.optimizer(scenWith1timepoint,
utility=pputil.value, prices=currentPrices,
max.weight=.07, gross=1e7, long.only=TRUE,
existing=currentPositions, port.size=c(20,30))
# maximize 20th percentile of value
q20valueOpt <- scenario.optimizer(scenWith1timepoint,
utility=pputil.value, extraArgs=list(level=.2),
prices=currentPrices,
max.weight=.07, gross=1e7, long.only=TRUE,
existing=currentPositions, port.size=c(20,30))
# weight scenarios, maximize 30th percentile
weightValueOpt <- scenario.optimizer(scenWith1timepoint,
utility=pputil.valueWt,
extraArgs=list(level=.3, sweights=vectorLengthNumScenarios),
prices=currentPrices,
max.weight=.07, gross=1e7, long.only=TRUE,
existing=currentPositions, port.size=c(20,30))
# load data
require(pprobeData)
# create a scenario for monthly values
monScen <- pp.historyScenarios(xassetPrices[,1:50],
template=c(0,21), number=100)
# use the scenario (as a matrix)
monOPt <- scenario.optimizer(monScen[2,,], utility=pputil.value,
prices=monScen[1,,1],
max.weight=.07, gross=1e7, long.only=TRUE,
existing=NULL, port.size=c(20,30)
# use the scenario (as a one-row 3D array)
monOPt <- scenario.optimizer(monScen[2,,, drop=FALSE],
utility=pputil.value, prices=monScen[1,,1],
max.weight=.07, gross=1e7, long.only=TRUE,
existing=NULL, port.size=c(20,30)