Critical value of a Chi square test 
///////////////////////////

  =CHISQ.INV.RT(probability,deg_freedom)

   input #1: probability is the probability
         #2: deg_freedom is the degree of freedom
                        n-1

 For example, 
     =CHISQ.INV.RT(0.05,8)  -> 15.50731306
///////////////////////////

Decision rule 
///////////////////////////
  Hypothesis: the returns follow a specific distribution 

  If Chi square > critical value  -> Reject the null
 
     Chi square < critical value  -> Accept the null

///////////////////////////

R functions for 4 moments 
///////////////////////////
Excel 4 moments

  1) the 1st moment: mean      -> =average()
  2) the 2nd moment: std       -> =stdev()
  3) the 3rd moment: skewness  -> =skew()
  4) the 4th moment: kurtosis  -> =kurt()

///////////////////////////

Modified VaR (non-normal distribution)
///////////////////////////
VaR consider the first two moments
----------------------------------
   VaR = P * (mean - z *sigma)            (1)

    where P : position 
        mean: mean period return 
         z  : =abs(NORMSINV(1-confidence))
       sigma: volatility of period returns

 Note: a sign issue

    VaR = P * (mean + z *sigma)           (2)

         z  : =NORMSINV(1-confidence)

mVaR (VaR consider the first 4 moments)
----------------------------------
   VaR = P * (mean - tt*sigma)            (3)

   where P  : position 
        mean: mean period return 
         z  : =abs(NORMSINV(1-confidence))
         tt : =z + 1/6*(z^2-1)S +1/24*(z^3-3z)K -1/36*(2*z^3-5z)S^2
         S  : skewness of returns
         K  : kurtosis of returns
       sigma: volatility of period returns

///////////////////////////

An easy way to download daily/monthly data
///////////////////////////
For example, to get daily price data for IBM
--------------------------------------------
    > x<-getDailyPrice("ibm")

    > saveYan(x,"c:/temp/ibmDaily.csv")
	
       [1] "Your saved file is ==>c:/temp/ibmDaily.csv"


To get monthly price data for Walmart
-------------------------------------

    > x<-getDailyPrice("wmt")

    > saveYan(x,"c:/temp/wmt.csv")

     [1] "Your saved file is ==>c:/temp/wmt.csv"

///////////////////////////