1

I have some troubles using the function AdjustedSharpeRatio() from the package PerformanceAnalytics, the following code sample in R 3.0.0:

library(PerformanceAnalytics)
logrets = array(dim=c(3,2),c(1,2,3,4,5,6))
weights = c(0.4,0.6)
AdjustedSharpeRatio(rowSums(weights*logrets),0.01)

gives the following error:

Error in checkData(R) : 
  The data cannot be converted into a time series.  If you are trying to pass in 
names from a data object with one column, you should use the form 'data[rows, 
columns, drop = FALSE]'.  Rownames should have standard date formats, such as 
'1985-03-15'. 

Replacing the last line with zoo gives the same error:

AdjustedSharpeRatio(zoo(rowSums(weights*logrets)),0.01)

Am I missing something obvious ?

4

2 回答 2

2

嗯......不太确定你想用那里的logretsweights对象实现什么......但如果logrets已经是百分比。那么也许是这样的......

AdjustedSharpeRatio(xts(rowSums(weights*logrets)/100,Sys.Date()-(c(3:1)*365)), Rf=0.01)
于 2013-06-07T14:09:39.643 回答
1

这可能有效:

a <- rowSums(weights*logrets)
names(a) <- c('1985-03-15', '1985-03-16', '1985-03-17')
AdjustedSharpeRatio(a,0.01)
于 2013-06-07T12:50:05.417 回答