[R] error in VaR calculation

2013-06-25 Thread G Girija
Hi,
I am your member. Pl help me with the solution.

rgds

[[alternative HTML version deleted]]

__
R-help@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
and provide commented, minimal, self-contained, reproducible code.


[R] error in VaR calculation

2013-06-25 Thread G Girija
The code is as follows:



monthreturns-read.zoo('monthlyReturn date.csv',sep=,,header=T)

monthreturns-as.xts(monthreturns,order.by
=index(monthreturns),frequency=NULL)*W0

head(monthreturns)

dim(monthreturns)



portnames-c('acc','cipla','cmc','idbi','ifci')  portfolio names (5
stocks)

mu.vec-c(0.1,0.2,0.2,0.4,0.1)

names(mu.vec)-portnames

covmatr-cov(monthreturns,use='complete')

sigma.matr-sqrt(covmatr)

head(sigma.matr)

dim(sigma.matr)



library(PerformanceAnalytics)

VaR(r=monnthreturns,p=0.99,method='historical',mu=mu.vec,sigma=sigma.matr,weights=NULL)*W0



*But here I am getting the following error: *


VaR(r=monnthreturns,p=0.99,method='historical',mu=mu.vec,sigma=sigma.matr,weights=NULL)*W0

Error in VaR(r = monnthreturns, p = 0.99, method = historical, mu =
mu.vec,  :

  number of items in weights not equal to number of items in the mean vector

* *

*could anyone help*

[[alternative HTML version deleted]]

__
R-help@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
and provide commented, minimal, self-contained, reproducible code.


Re: [R] error in VaR calculation

2013-06-25 Thread Joshua Ulrich
r != R (you mis-typed the first argument to VaR).  This works:

library(PerformanceAnalytics)
data(sample_matrix)
x - Return.calculate(as.xts(sample_matrix))
VaR(R=x, p=0.99, method=historical)

Best,
--
Joshua Ulrich  |  about.me/joshuaulrich
FOSS Trading  |  www.fosstrading.com


On Tue, Jun 25, 2013 at 7:35 AM, G Girija girija...@gmail.com wrote:
 The code is as follows:



 monthreturns-read.zoo('monthlyReturn date.csv',sep=,,header=T)

 monthreturns-as.xts(monthreturns,order.by
 =index(monthreturns),frequency=NULL)*W0

 head(monthreturns)

 dim(monthreturns)



 portnames-c('acc','cipla','cmc','idbi','ifci')  portfolio names (5
 stocks)

 mu.vec-c(0.1,0.2,0.2,0.4,0.1)

 names(mu.vec)-portnames

 covmatr-cov(monthreturns,use='complete')

 sigma.matr-sqrt(covmatr)

 head(sigma.matr)

 dim(sigma.matr)



 library(PerformanceAnalytics)

 VaR(r=monnthreturns,p=0.99,method='historical',mu=mu.vec,sigma=sigma.matr,weights=NULL)*W0



 *But here I am getting the following error: *


 VaR(r=monnthreturns,p=0.99,method='historical',mu=mu.vec,sigma=sigma.matr,weights=NULL)*W0

 Error in VaR(r = monnthreturns, p = 0.99, method = historical, mu =
 mu.vec,  :

   number of items in weights not equal to number of items in the mean vector

 * *

 *could anyone help*

 [[alternative HTML version deleted]]

 __
 R-help@r-project.org mailing list
 https://stat.ethz.ch/mailman/listinfo/r-help
 PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
 and provide commented, minimal, self-contained, reproducible code.

__
R-help@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
and provide commented, minimal, self-contained, reproducible code.