[R-SIG-Finance] a problem with stockPortfolio without short selling
aschmid1
aschmid1 at stevens.edu
Tue Oct 14 03:35:28 CEST 2014
Hi,
Here is my script:
> library(stockPortfolio)
> ticker<-c("SPY", "XLK", "XLE", "XLY", "XLU")
> stockData <- getReturns(ticker, freq="day", get="overlapOnly",
> start='2010-01-02', end='2012-12-31')
> modelS<-stockModel(stockData, model='SIM', index=1)
> opS<-optimalPort(modelS)
So far, so good... Then I do the same without short selling:
> modelL<-stockModel(stockData, model='SIM', index=1, shortSelling="n")
> opL<-optimalPort(modelL)
... and get an error message: "Error in model$COV[these, these] :
incorrect number of dimensions"
Note that covariances of modelS and modelL are equal:
> modelS$COV==modelL$COV
[,1] [,2] [,3] [,4]
[1,] TRUE TRUE TRUE TRUE
[2,] TRUE TRUE TRUE TRUE
[3,] TRUE TRUE TRUE TRUE
[4,] TRUE TRUE TRUE TRUE
Thanks! Alec
More information about the R-SIG-Finance
mailing list