I'm attempting a very basic optimization with fPortfolio using the default constraints. Yet, the portfolio frontier that is generated is nonsense. As the return increases, the risk decreases! Any help would be greatly appreciated. Below is my code:
library(fPortfolio)
#Gets date,price, and return data from excel spreadsheet
#------------------------------------------------------------
sp500Reuters<-read.csv("C:\\data\\sp500Reuters.csv")
spgsciReuters<-read.csv("C:\\data\\spgsciReuters.csv")
msciWorldReuters<-read.csv("C:\\data\\msciWorldReuters.csv")
cshfReuters<-read.csv("C:\\data\\cshfReuters.csv")
# Creates return Matrix, timeDate object, and timeSeries object
#------------------------------------------------------------
returnMatrix<-cbind(sp500Reuters[(2:185),3],msciWorldReuters[(2:185),3],spgsciReuters[(2:185),3],cshfReuters[(2:185),3])
colNames<-c("US Equity","World Equity","Commodities","Hedge Fund")
colnames(returnMatrix)<-colNames
returnSeries<-as.timeSeries(returnMatrix)
timeObject<-timeSequence(from="1994-1-31",to="2009-4-30",by="month",format="%Y-%m-%d",FinCenter="GMT")
dataSet<-timeSeries(returnSeries,timeObject,units=NULL,format=NULL,zone="GMT",FinCenter="GMT")
------------------------------------------------------------
# Creates portfolioData object and generates frontier
portfolioData<-portfolioData(dataSet,spec=portfolioSpec())
newFrontier<-portfolioFrontier(portfolioData)
#Note that I've also tried
newFrontier<-portfolioFrontier(dataSet)
In both cases I get an output such as the following:
Target Return and Risks:
mean mu Cov Sigma CVaR VaR
1 0.0380 0.0380 0.5285 0.5285 1.3375 0.9721
13 0.0500 0.0500 0.4391 0.4391 1.0920 0.7691
25 0.0620 0.0620 0.3609 0.3609 0.8590 0.5488
37 0.0740 0.0740 0.3014 0.3014 0.6797 0.3874
50 0.0869 0.0869 0.2732 0.2732 0.6036 0.4280
Thanks for any help in advance.
portfolioFrontier nonsense
2 messages · ssmith88 at umd.edu, Diethelm Wuertz
ssmith88 at umd.edu wrote:
I'm attempting a very basic optimization with fPortfolio using the default constraints. Yet, the portfolio frontier that is generated is nonsense. As the return increases, the risk decreases!
Let me start with a comparison: When you fill up your Ferrari with water instead of gas, then the "return in speed decreases" and the "risk of damage increases". This is a problem arising from the kind of fuel you use and not of the Ferrari. I think it is a data problem - when you send me your data, I will try to fnd out what was possibly going wrong. Kind regards Diethelm
Any help would be greatly appreciated. Below is my code:
library(fPortfolio)
#Gets date,price, and return data from excel spreadsheet
#------------------------------------------------------------
sp500Reuters<-read.csv("C:\\data\\sp500Reuters.csv")
spgsciReuters<-read.csv("C:\\data\\spgsciReuters.csv")
msciWorldReuters<-read.csv("C:\\data\\msciWorldReuters.csv")
cshfReuters<-read.csv("C:\\data\\cshfReuters.csv")
# Creates return Matrix, timeDate object, and timeSeries object
#------------------------------------------------------------
returnMatrix<-cbind(sp500Reuters[(2:185),3],msciWorldReuters[(2:185),3],spgsciReuters[(2:185),3],cshfReuters[(2:185),3])
colNames<-c("US Equity","World Equity","Commodities","Hedge Fund")
colnames(returnMatrix)<-colNames
returnSeries<-as.timeSeries(returnMatrix)
timeObject<-timeSequence(from="1994-1-31",to="2009-4-30",by="month",format="%Y-%m-%d",FinCenter="GMT")
dataSet<-timeSeries(returnSeries,timeObject,units=NULL,format=NULL,zone="GMT",FinCenter="GMT")
------------------------------------------------------------
# Creates portfolioData object and generates frontier
portfolioData<-portfolioData(dataSet,spec=portfolioSpec())
newFrontier<-portfolioFrontier(portfolioData)
#Note that I've also tried
newFrontier<-portfolioFrontier(dataSet)
In both cases I get an output such as the following:
Target Return and Risks:
mean mu Cov Sigma CVaR VaR
1 0.0380 0.0380 0.5285 0.5285 1.3375 0.9721
13 0.0500 0.0500 0.4391 0.4391 1.0920 0.7691
25 0.0620 0.0620 0.3609 0.3609 0.8590 0.5488
37 0.0740 0.0740 0.3014 0.3014 0.6797 0.3874
50 0.0869 0.0869 0.2732 0.2732 0.6036 0.4280
Thanks for any help in advance.
_______________________________________________ R-SIG-Finance at stat.math.ethz.ch mailing list https://stat.ethz.ch/mailman/listinfo/r-sig-finance -- Subscriber-posting only. -- If you want to post, subscribe first.