I am trying to replicate this example as I am new to portfolio optimization through R:
http://economistatlarge.com/portfolio-theory/r-optimized-portfolio
However, I keep getting the following error:
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.
I have no idea how to troubleshoot this, any suggestions?