[R-SIG-Finance] Some problems while reading Diethelm Würtz's Portfolio Optimization with R book
Baki UNAL
bakiunal at yahoo.com
Sun Aug 27 15:35:27 CEST 2017
Hello
I am reading Diethelm Würtz's Portfolio Optimization with R book. I encountered a problem at "17.2 How to Compute a Minimum Risk Efficient Portfolio" part. I entered the commands:
> minriskSpec <- portfolioSpec()> targetReturn <- getTargetReturn(ewPortfolio at portfolio)["mean"]> setTargetReturn(minriskSpec) <- targetReturn
> minriskPortfolio <- efficientPortfolio(data = lppData,spec = minriskSpec,constraints = "LongOnly")> print(minriskPortfolio)
But I got the following output:
Title: MV Efficient Portfolio Estimator: covEstimator Solver: solveRquadprog Optimize: minRisk Constraints: LongOnly
Portfolio Weights:SBI SPI SII LMI MPI ALT 0 0 0 0 0 0
Covariance Risk Budgets:SBI SPI SII LMI MPI ALT
Target Returns and Risks:mean Cov CVaR VaR 0 0 0 0
Description: Sun Aug 27 16:00:42 2017 by user: win7120
As you notice R does not compute Portfolio Weights, Target Returns and Risks... etc.
I also tried to run the code at "17.3 How to Compute the Global Minimum Variance Portfolio" which is:
> globminSpec <- portfolioSpec()> globminPortfolio <- minvariancePortfolio(data = lppData,spec = globminSpec,constraints = "LongOnly")> print(globminPortfolio)
But I got the following output:
Title:
MV Minimum Variance Portfolio
Estimator: covEstimator
Solver: solveRquadprog
Optimize: minRisk
Constraints: LongOnly
Portfolio Weights:
SBI SPI SII LMI MPI ALT
0 0 0 0 0 0
Covariance Risk Budgets:
SBI SPI SII LMI MPI ALT
Target Returns and Risks:
mean Cov CVaR VaR
0 0 0 0
Description:
Sun Aug 27 16:12:21 2017 by user: win7120
As you see R does not make computations again.
I also tried to run the code at "17.4 How to Compute the Tangency Portfolio" which is:
> tgSpec <- portfolioSpec()> setRiskFreeRate(tgSpec) <- 0
> tgPortfolio <- tangencyPortfolio(data = lppData,spec = tgSpec,constraints = "LongOnly")
This time I got the following error:
Error in if (STATUS != 0) { : argument is of length zero
What may be the problem? Could you help?
Thanks
[[alternative HTML version deleted]]
More information about the R-SIG-Finance
mailing list