修改下面这串代码的问题##fPortfolio绘制有效边界曲线图 mySpec1= portfolioSpec() setNFrontierPoints(mySpec1) = 30 Frontier1 = portfolioFrontier(datan, mySpec1) win.graph(width=7,height=6.5) par(mfrow=c(3,1)) weightsPlot(Frontier1,mtext = FALSE) text = "Mean-Variance Portfolio - Long Only Constraints" mtext('text', side = 3, line = 3, font = 2, cex = 0.9) weightedReturnsPlot(Frontier1, mtext = F) covRiskBudgetsPlot(Frontier1, mtext = F) win.graph(width=7,height=6.5) par(mfrow=c(1,1)) tailoredFrontierPlot(object = Frontier1, mText = "MV Portfolio - LongOnlyConstraints",risk = "Cov") tailoredFrontierPlot(object = Frontier1, mText = "MV Portfolio - LongOnlyConstraints",risk = "CVaR")
时间: 2023-06-20 12:08:26 浏览: 135
通信与网络中的Frontier发布高集成度DVB-H接收器Paradiso1H
下面是修改后的代码,主要是针对第二行的语法问题进行了修改:
```{r}
mySpec1 <- portfolioSpec()
setNFrontierPoints(mySpec1) <- 30
Frontier1 <- portfolioFrontier(datan, mySpec1)
win.graph(width=7,height=6.5)
par(mfrow=c(3,1))
weightsPlot(Frontier1,mtext = FALSE)
text <- "Mean-Variance Portfolio - Long Only Constraints"
mtext(text, side = 3, line = 3, font = 2, cex = 0.9)
weightedReturnsPlot(Frontier1, mtext = FALSE)
covRiskBudgetsPlot(Frontier1, mtext = FALSE)
win.graph(width=7,height=6.5)
par(mfrow=c(1,1))
tailoredFrontierPlot(object = Frontier1, mText = "MV Portfolio - LongOnlyConstraints",risk = "Cov")
tailoredFrontierPlot(object = Frontier1, mText = "MV Portfolio - LongOnlyConstraints",risk = "CVaR")
```
主要修改是将 `setNFrontierPoints(mySpec1)` 改为 `setNFrontierPoints(mySpec1) <- 30`,并将 `text = "Mean-Variance Portfolio - Long Only Constraints"` 改为 `text <- "Mean-Variance Portfolio - Long Only Constraints"`。此外,`mtext('text', side = 3, line = 3, font = 2, cex = 0.9)`也被修改为 `mtext(text, side = 3, line = 3, font = 2, cex = 0.9)`。同时,`weightsPlot`、`weightedReturnsPlot` 和 `covRiskBudgetsPlot`函数中的 `mtext` 参数也被修改为 `FALSE`。
阅读全文