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?

elJorge
  • 153
  • 1
  • 2
  • 9
  • Your examples are not [reproducible](http://stackoverflow.com/questions/5963269/how-to-make-a-great-r-reproducible-example), so it's very difficult for anyone to help you. – Joshua Ulrich May 31 '13 at 16:40

1 Answers1

1

I've solved the issue by recreating a time-series-object (in this case xts). See the code attached.

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)))

But this can't be the real solution?!?

I'd be very greatful for further comments.

elJorge
  • 153
  • 1
  • 2
  • 9