【发布时间】:2014-08-28 05:48:43
【问题描述】:
我正在尝试复制此示例,因为我是通过 R 进行投资组合优化的新手:
http://economistatlarge.com/portfolio-theory/r-optimized-portfolio
但是,我不断收到以下错误:
R version 3.0.2 (2013-09-25) -- "Frisbee Sailing"
Copyright (C) 2013 The R Foundation for Statistical Computing
Platform: x86_64-w64-mingw32/x64 (64-bit)
R is free software and comes with ABSOLUTELY NO WARRANTY.
You are welcome to redistribute it under certain conditions.
Type 'license()' or 'licence()' for distribution details.
Natural language support but running in an English locale
R is a collaborative project with many contributors.
Type 'contributors()' for more information and
'citation()' on how to cite R or R packages in publications.
Type 'demo()' for some demos, 'help()' for on-line help, or
'help.start()' for an HTML browser interface to help.
Type 'q()' to quit R.
> library(stockPortfolio)
Warning message:
package ‘stockPortfolio’ was built under R version 3.1.1
> library(quadprog)
Warning message:
package ‘quadprog’ was built under R version 3.1.1
> stocks <- c(
+ "SPY" = .30,
+ "EFA" = .20,
+ "IWM" = .15,
+ "VWO" = .10,
+ "LQD" = .15,
+ "HYG" = .10)
> returns <- getReturns(names(stocks), freq="week")
Error in file(file, "rt") : cannot open the connection
In addition: Warning message:
In file(file, "rt") :
unable to connect to 'ichart.finance.yahoo.com' on port 80.
我不知道如何解决这个问题,有什么建议吗?
【问题讨论】:
-
我知道这是一篇旧帖子,您现在可能已经想通了,但以防万一您没有...为了他人的利益...股票
-
因此,代码应如下所示: library(stockPortfolio) library(quadprog) stock
-
我无法弄清楚为什么所有内容都连接在一起。当一切都被包装起来并挤在一起时,很难阅读这个......无论如何,看看这个:economistatlarge.com/portfolio-theory/r-optimized-portfolio
标签: r optimization