1

i've following problem using the CAPM funcitons within the performanceanalytics package.

The code as follows:

LI <- apply(FP.CAR,1,mean, na.rm=TRUE)) 
LA <- window(datensatz_Markt.GGI.D, start=as.Date("2009-06-01"), end=as.Date("2009-11-01")))
#LI and LA are both simple zoo-objects with the content:

> LI
                   [,1]
2009-06-01 -0.031655213
2009-07-01  0.021612896
2009-08-01 -0.078864013
2009-09-01  0.012067940
2009-10-01 -0.028619972
2009-11-01 -0.006347962
> LA
                   [,1]
2009-06-01  0.076531901
2009-07-01  0.047163872
2009-08-01  0.041954638
2009-09-01  0.027973415
2009-10-01  0.046670947
2009-11-01 -0.007938671

by appling the functions for calculating the CAPM I get - at least for two out of four - an error or no result:

> CAPM.beta(LI,LA,0)
[1] NA

> CAPM.alpha(LI,LA,0)
Fehler in `[.data.frame`(merged, , 2) : undefined columns selected

> CAPM.CML(LI,LA,0)
[1] -0.02594791

> CAPM.RiskPremium(LI,0)
                            [,1]
Risk Premium (Rf=0%) -0.01863439

Have you any suggestions where might be the error?

4

1 回答 1

1

我通过重新创建时间序列对象(在本例中为 xts)解决了这个问题。请参阅随附的代码。

LI <- data.frame(apply(HP.CAR,1,mean, na.rm=TRUE)) 
LA <- data.frame(window(datensatz_Markt.GGI.D, start=as.Date("2009-06-01"), end=as.Date("2009-11-01")))
LI.xts <- xts(LI,as.Date(rownames(LI)))
LA.xts <- xts(LA,as.Date(rownames(LA)))

但这不可能是真正的解决方案?!?

我会非常感激进一步的评论。

于 2013-05-31T13:14:54.293 回答