Error in using PerformanceAnalytics package.

Previous Topic Next Topic
 
classic Classic list List threaded Threaded
1 message Options
Reply | Threaded
Open this post in threaded view
|

Error in using PerformanceAnalytics package.

Rmetrics mailing list
Apologies that data file was not attached in the previous mail

Dear Joshua Sir
Here is my data and my code:

R Version 3.4.2

1. Data:
File:data.csv
Monthly returns of 210 assets from April 2006 till March 2015

2. Code:
#Reading file
dat1<-read.csv("data.csv",header=TRUE,stringsAsFactors=FALSE)
#Load zoo
library(zoo)
#Creating a zoo object
dat1.z<-read.zoo(dat1, header = TRUE, FUN =function(x) as.yearmon(format(x, nsmall = 2),"%b-%y"))
#Subseting data
testdata<-window(dat1.z,start=as.yearmon("Apr 2006"),end=as.yearmon("Mar 2010"))
#Computing VaR
library(PerformanceAnalytics)
library(PortfolioAnalytics)
VaR(as.matrix(testdata)/100,p=0.95,method="modified")

Problem:
The last command gives the following output:

Error in dimnames(cd) <- list(as.character(index(x)), colnames(x)) : 
  'dimnames' applied to non-array

Kindly advise how to resolve it. 



Regards,
Pankaj K Agarwal

+91-98397-11444

_______________________________________________
[hidden email] mailing list
https://stat.ethz.ch/mailman/listinfo/r-sig-finance
-- Subscriber-posting only. If you want to post, subscribe first.
-- Also note that this is not the r-help list where general R questions should go.

data.csv (322K) Download Attachment