Performance Analytics: table.CAPM
Thank you Joshua, Yes you are right I get also no error running the same code in a second attempt. But the day after, I ran the same code and I got the same error message so I'm confused. In order to make the estimation work, I directly define the xts object in the formula as in the following table.CAPM(as.xts(al[,1,drop=FALSE]),as.xts(al[,2,drop=FALSE]),Rf=as.xts(al[,3,drop=FALSE])) where "al" is a multivariate xts class object. This is the only way I get it to work while the day before, I didn't have any problem running more simply table.CAPM (p1,p2 ,p3) where p1,p2,p3 where previously defined as univariate xts object. There's something in these functions that seems to be sensitive to the way the "xts" is entered or specified. I noticed the problem occur more often when passing the xts in the risk free rate parameter "Rf". I don't think it's critical as I found a way to overcome but a little less straightforward. Sorry for the code, I will try making it simpler next time Regards, -----Original Message----- From: Joshua Ulrich [mailto:josh.m.ulrich at gmail.com] Sent: Thursday, October 16, 2014 7:34 PM To: Charles Duranceau Cc: r-sig-finance at r-project.org Subject: Re: [R-SIG-Finance] Performance Analytics: table.CAPM I get no errors when running your code with the most recent versions of xts and PerformanceAnalytics on CRAN. Here's a simplified version of your example: library(PerformanceAnalytics) ind <- as.yearmon(Sys.Date())-(4:1)/12 Ra <- xts(c(0.1,0.11,0.09,0.1), ind) Rb <- xts(c(0.25,0.2,-0.4,0.01), ind) CAPM.alpha(Ra, Rb) table.CAPM(Ra, Rb) Best, -- Joshua Ulrich | about.me/joshuaulrich FOSS Trading | www.fosstrading.com
On Wed, Oct 15, 2014 at 4:28 PM, Charles Duranceau <cduranceau at nial.ky> wrote:
Hi,
I noticed a problem with the function : table.CAPM when it return following error message: "Error in NextMethod(.Generic) : dims [product 4] do not match the length of object [0]"
I noticed in a previous post the solution is to transform series in xts, but in this case the series is already a xts object.
I don't understand as other similar functions works well as the
following code shows
library("xts",
lib.loc="C:/Users/cduranceau/Documents/R/win-library/3.1")
library("PerformanceAnalytics",
lib.loc="C:/Users/cduranceau/Documents/R/win-library/3.1")
# Define Returns
pf1<-c(0.1,0.11,0.09,0.1)
bm<-c(0.25,0.2,-0.4,0.01)
time_index<-seq(as.Date("2003/05/01"), by = "month", length.out = 4)-1
# last day of the month
pf1x<-as.xts(pf1,time_index)
bmx<-as.xts(bm,time_index)
CAPM.alpha(pf1x, bmx, Rf = 0) # works [1] 0.09965609
table.CAPM(pf1x,bmx,Rf=0) # error
Is there a way to solve the issue?
Thank you
Best Regards,
Version info
platform x86_64-w64-mingw32
arch x86_64
os mingw32
system x86_64, mingw32
status
major 3
minor 1.0
year 2014
month 04
day 10
svn rev 65387
language R
version.string R version 3.1.0 (2014-04-10)
nickname Spring Dance
package:
Package:
"PerformanceAnalytics" VERSION 1.4.3541 from CRAN ---- project.org/bin/windows/contrib/3.1/PerformanceAnalytics_1.4.3541.zip
Charles