Hi, package PortfolioAnalytics doesn’t work when try to plot charts…
Anyone have idea of the problem? Thanks Diego > PortfolioAnalytics::chart.RiskReward(object=minSD.opt, + risk.col="ES", return.col="mean", chart.assets=FALSE) Error in applyFUN(R = R, weights = wts, FUN = return.col) : argument "arguments" is missing, with no default In addition: Warning message: In chart.RiskReward.optimize.portfolio.random(object = minSD.opt, : mean or ES do not match extractStats output of $objective_measures slot > plot(minSD.opt, risk.col="StdDev", chart.assets=F, + main="Min SD Optimization", + ylim=c(0, 0.0083), xlim=c(0, 0.06)) Error in applyFUN(R = R, weights = wts, FUN = return.col) : argument "arguments" is missing, with no default In addition: Warning message: In chart.Scatter.RP(object = RP, risk.col = risk.col, return.col = return.col, : mean or StdDev do not match extractStats output of $objective_measures slot --------------------------------------------------------- Here a standard working example to check --------------------------------------------------------- library(PortfolioAnalytics) data(edhec) returns <- edhec[, 1:6] funds <- colnames(returns) init.portfolio <- portfolio.spec(assets=funds) print.default(init.portfolio) init.portfolio <- add.constraint(portfolio = init.portfolio, type = "full_investment") init.portfolio <- add.constraint(portfolio = init.portfolio, type = "long_only") # Add objective for portfolio to minimize portfolio standard deviation minSD.portfolio <- add.objective(portfolio=init.portfolio, type="risk", name="StdDev") print(minSD.portfolio) # Run the optimization for the minimum standard deviation portfolio minSD.opt <- optimize.portfolio(R=returns, portfolio = minSD.portfolio, optimize_method = "random", trace = TRUE) print(minSD.opt) PortfolioAnalytics::chart.RiskReward(object=minSD.opt, risk.col="ES", return.col="mean", chart.assets=FALSE) PortfolioAnalytics::extractWeights(minSD.opt) PortfolioAnalytics::chart.Weights(minSD.opt) plot(minSD.opt, risk.col="StdDev", chart.assets=F, main="Min SD Optimization", ylim=c(0, 0.0083), xlim=c(0, 0.06)) --------------------------------------------------------- My current configuration is: > sessionInfo() R version 4.1.2 (2021-11-01) Platform: x86_64-pc-linux-gnu (64-bit) Running under: CentOS Linux 7 (Core) Matrix products: default BLAS/LAPACK: /usr/lib64/libopenblasp-r0.3.3.so locale: [1] LC_CTYPE=en_US.UTF-8 LC_NUMERIC=C LC_TIME=en_US.UTF-8 [4] LC_COLLATE=en_US.UTF-8 LC_MONETARY=en_US.UTF-8 LC_MESSAGES=en_US.UTF-8 [7] LC_PAPER=en_US.UTF-8 LC_NAME=C LC_ADDRESS=C [10] LC_TELEPHONE=C LC_MEASUREMENT=en_US.UTF-8 LC_IDENTIFICATION=C attached base packages: [1] stats graphics grDevices utils datasets methods base other attached packages: [1] PortfolioAnalytics_1.1.0 PerformanceAnalytics_2.0.4 foreach_1.5.2 [4] xts_0.12.2 zoo_1.8-11 loaded via a namespace (and not attached): [1] httr_1.4.4 pkgload_1.3.2 tidyr_1.2.1 jsonlite_1.8.4 [5] viridisLite_0.4.1 microbenchmark_1.4.9 shiny_1.7.4 assertthat_0.2.1 [9] TTR_0.24.3 cellranger_1.1.0 remotes_2.4.2 sessioninfo_1.2.2 [13] pillar_1.8.1 lattice_0.20-45 glue_1.6.2 quadprog_1.5-8 [17] digest_0.6.31 promises_1.2.0.1 colorspace_2.0-3 htmltools_0.5.4 [21] httpuv_1.6.7 plyr_1.8.8 pkgconfig_2.0.3 devtools_2.4.5 [25] purrr_1.0.1 xtable_1.8-4 scales_1.2.1 processx_3.8.0 [29] later_1.3.0 tzdb_0.3.0 timechange_0.1.1 tibble_3.1.8 [33] generics_0.1.3 ggplot2_3.4.0 usethis_2.1.6 ellipsis_0.3.2 [37] cachem_1.0.6 lazyeval_0.2.2 cli_3.6.0 magrittr_2.0.3 [41] crayon_1.5.2 readxl_1.4.1 mime_0.12 memoise_2.0.1 [45] ps_1.7.2 fs_1.5.2 fansi_1.0.3 pkgbuild_1.4.0 [49] profvis_0.3.7 tools_4.1.2 data.table_1.14.6 prettyunits_1.1.1 [53] hms_1.1.2 lifecycle_1.0.3 stringr_1.5.0 plotly_4.10.1 [57] munsell_0.5.0 writexl_1.4.2 callr_3.7.3 compiler_4.1.2 [61] IBrokers_0.10-2 rlang_1.0.6 grid_4.1.2 iterators_1.0.14 [65] rstudioapi_0.14 htmlwidgets_1.6.1 miniUI_0.1.1.1 codetools_0.2-18 [69] gtable_0.3.1 DBI_1.1.3 curl_4.3.3 R6_2.5.1 [73] quantF_0.1.1 lubridate_1.9.0 dplyr_1.0.10 fastmap_1.1.0 [77] utf8_1.2.2 readr_2.1.3 stringi_1.7.12 parallel_4.1.2 [81] Rcpp_1.0.9 vctrs_0.5.1 tidyselect_1.2.0 urlchecker_1.0.1 [[alternative HTML version deleted]] _______________________________________________ R-SIG-Finance@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-sig-finance -- Subscriber-posting only. If you want to post, subscribe first. -- Also note that this is not the r-help list where general R questions should go.