Description Usage Arguments Value Examples
Implements the quadratic portfolio optimization algorithm using the partial co-moments symmetric expectations matrix
1 | pmSolver(pcmExpectation, userConstraints, npoints=200, type=c("I","II","III","IV"))
|
pcmExpectation |
The symmetric co-partial moments. An |
userConstraints |
The portfolio constraints object ( |
npoints |
(Optional) No of frontier points. |
type |
Optimization type required. Valid methods are “I” for the Minimum Risk Portfolio, “II” for the Minimizing risk for a given level of return, “III” for maximizing the risk adjusted return for a given risk aversion coefficient, and “IV” for the efficient frontier. |
An object of class PMSOLVER
.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 | ## Not run:
data(djiaret)
# calculate sample lower partial moments by bootstrap
# REM: for optimization you should use standardized moments
# (standardize=TRUE)
sample.lpm<-pmExpectation(data=as.matrix(djiaret), method=rep("boot",30),
threshold=-0.01, moment=2, type="lower", standardize=TRUE)
# calculate sample lower partial co-moment matrix
sample.spcm<-pcmExpectation(sample.lpm, corr=cor(as.matrix(djiaret)), tail="lower")
##############################################
# Lower Partial Moments Portfolio Optimization
##############################################
# Test13: Constraints Setup
cst<-constraints(forecasts=apply(as.matrix(djiaret),2,FUN=function(x) mean(x)),
portfolioReturn=0.1/252, riskAversion = 2, riskFree=0.05/252,
budget = 1, assetsUB = rep(0.25,30),assetsLB=rep(0,30))
# Test14: Minimum Risk Solver (I)
port3<-pmSolver(sample.spcm, cst, type="I")
show(port3)
weightsPie(port3)
# Test15: Minimize Risk for given level of Return (II)
# REM portfolioReturn=0.1/252 (in constraints)
port4<-pmSolver(sample.spcm, cst, type="II")
show(port4)
weightsPie(port4)
# Test16: Maximize the risk adjusted return for a given risk aversion
# coefficient (III)
getriskAversion(cst)
setriskAversion(cst) = 0.1
port5<-pmSolver(sample.spcm, cst, type="III")
show(port5)
weightsPie(port5)
getriskAversion(cst)
setriskAversion(cst) = 40
port6<-pmSolver(sample.spcm, cst, type="III")
show(port6)
weightsPie(port6)
# Test17: Efficient Frontier (IV)
port7<-pmSolver(sample.spcm, cst, npoints=200, type="IV")
plot(port7)
dev.new(2)
weightsPlot(port7)
## End(Not run)
|
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.