Re: [R] Value at Risk Hi Saore ***Please always mark a copy to the R-help list, it may be helpfull to  many, you have forgotten twice*** *** Do Reply to all with history ***  :-) cheers YOU ARE THE BEST :) I have some problems understanding R, but R and I will be friends in the  future hehe :) I have another problem with investing in one of this stockfonds. Lets say I would invest in the europe stockfonds on 2.5.2006 1000 dollar.  What would be the 99%VaR/1 day under historical simulation? The same as  above? @@@ So what do you think, -2.86 number means Lets investigate suppose you have invested 1000, one way to realize is  100*ln(Tommorow/Todays) = -2.86 (out return) where Todays = 1000 hence Tommorow = 1000*exp(-2.86/100) = 971.8051 , therefore Loss = 1000 -  971.8051 = 28.19489 I hope this would make your understanding much better and clear about VaR  :-)  HTH KR, Alin 2007/5/11, gyadav@ccilindia.co.in : reply is inline  Hello Gaurav, The function: > VaR(tstock[,2],alpha=0.01) # gives the same VaR as above with historical  simulation VaR  -2.86  but i tried this function for normal distribution:  > VaR.norm (tstock[,2],p=0.99)$VaR Error in VaR.norm(tstock[, 2], p = 0.99) :         Negative value in parameter 'ydat' @@@ if you have seen the help manual then you mus have got that you dont  need to give the retun series.  R is trying to calucate the logarithm of a negative number which is why it  is throwing you error.  try this instead  > XXX<-VaR.norm(stock$ESPA.STOCK.EUROPE,p=0.01)  > XXX$VaR  [1] -3.11079  >  I dont understand the way with the normal distribution :( Maybe you can  help me a littble bit.  Cheers :-) KR, Alin Soare 2007/5/11, gyadav@ccilindia.co.in :  reply is inline  -  Regards,         \\\\\\|||||///      \\\\   -    -   //       (  o   o  ) oOOo-(_)-oOOo-------- | | Gaurav Yadav | Assistant Manager, CCIL, Mumbai (India) | Mob: +919821286118 Email: emailtogauravyadav@gmail.com  | Man is made by his belief, as He believes, so He is. |                                           --- Bhagavad Gita  |_______Oooo________        oooO(      )        (      )   )   /         \\   (    (_/           \\_ ) Hello Mr. Gaurav Yadav, Hi Soare,  1. I want to calculate the 99%VaR/1 day for the stock fonds, after sorting  the values the 5th or 6th value is it? In Historical simulation it is the 5th value...... because it tells you to  be more cautious that a higher loss 'may' be there, secondly VaR only  shows the possibility and not the maximum loss which you can incur :-)  cheers 2. How do I calculate it under normal distribution aproximation?  Well there is also a normal method or variance - covariance method which  assumes normal distribution :-)  if you want to incorporate recency effect then you can also see boudhouks  method  try this  paper which will give you very good understanding of various  methods of VaR  http://papers.ssrn.com/sol3/papers.cfm?abstract_id=51420#PaperDownload  ++++++++++++++++++ apply(tstock,2,function(x) VaR(x,alpha=0.01)) # are these the right VaR's for the stockfonds? @@@ you can yourself see it, you have around 579 observation and 1% of it  mean 5.79th observation  Thus if you become risk averse then you take the 5th smallest value and  otherwise 6th value.  So just sort the returns in ascending order and then see the 5th and the  6th values  > sorted_espa_stock_europe<-sort(tstock[,2])  > sorted_espa_stock_europe[5]  [1] -2.86  > sorted_espa_stock_europe[6]  [1] -2.74  >  your code gives -2.86 thus you can get the rest :-) cheers  ============================================================================================ DISCLAIMER AND CONFIDENTIALITY CAUTION: This message and any attachments with it (the "message") are confidential  and intended solely for the addressees. Unauthorized reading, copying, dissemination,  distribution or disclosure either whole or partial, is prohibited. If you receive this  message in error, please delete it and immediately notify the sender. Communicating through  email is not secure and capable of interception, corruption and delays. Anyone  communicating with The Clearing Corporation of India Limited (CCIL) by email accepts the risks  involved and their consequences. The internet can not guarantee the integrity of this  message. CCIL shall (will) not therefore be liable for the message if modified. The recipient  should check this email and any attachments for the presence of viruses. CCIL accepts no  liability for any damage caused by any virus transmitted by this email. ============================================================================================ DISCLAIMER AND CONFIDENTIALITY CAUTION: This message and any attachments with it (the "message") are confidential  and intended solely for the addressees. Unauthorized reading, copying, dissemination,  distribution or disclosure either whole or partial, is prohibited. If you receive this  message in error, please delete it and immediately notify the sender. Communicating through  email is not secure and capable of interception, corruption and delays. Anyone  communicating with The Clearing Corporation of India Limited (CCIL) by email accepts the risks  involved and their consequences. The internet can not guarantee the integrity of this  message. CCIL shall (will) not therefore be liable for the message if modified. The recipient  should check this email and any attachments for the presence of viruses. CCIL accepts no  liability for any damage caused by any virus transmitted by this email. ============================================================================================ DISCLAIMER AND CONFIDENTIALITY CAUTION: This message and any attachments with it (the "message") are confidential and intended solely for the addressees. Unauthorized reading, copying, dissemination, distribution or disclosure either whole or partial, is prohibited. If you receive this message in error, please delete it and immediately notify the sender. Communicating through email is not secure and capable of interception, corruption and delays. Anyone communicating with The Clearing Corporation of India Limited (CCIL) by email accepts the risks involved and their consequences. The internet can not guarantee the integrity of this message. CCIL shall (will) not therefore be liable for the message if modified. The recipient should check this email and any attachments for the presence of viruses. CCIL accepts no liability for any damage caused by any virus transmitted by this email. 	[[alternative HTML version deleted]] ______________________________________________ R-help@stat.math.ethz.ch 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.