liquidity measure, Pastor and Stambough (2003)
//////////////////////////////////////
Objectives: 
    1) Understand the logic of the measure
    2) Learn how to download and process data from Yahoo!Finance
    3) estimate individual stock s liquidity 

  Basic logic:Pastor and Stambaugh (2003) design the following 
        regression to estimate individual stock s liquidity.  

            y(t)=alha + 1*x1(t-1)+  2*x2(t-1)+error(t)           (1)

    where,y(t) is the excess stock return on day t, the excess return is 
          defined as R(t)-Rm(t),  R(t) is the stock return, Rm(t) is the 
          market return at time t; x1(t-1) is the lagged stock return, 
          i.e., R(t-1), X2(t-1) is the lagged dollar trading volume, i.e., 
          x2(t-1)=P(t-1)*V(t-1), P(t-1) is the daily closing price of the stock 
          at t-1 and V(t-1) is the daily trading volume at t-1. 
          
    The regression is based on the daily data within each month with a 
         minimum number of observations of 15. The liquidity measure for an 
         individual stock in each month is defined as:
 
            	liquidity measure=beta2       (2)

     For the first trial, we ignore other constraints.  The Market liquidity 
         is the equally weighted individual stock's liquidity and scaled by 
         the market capitalization.
Procedure:
	Step 1: Retrieve daily data
	Step 2: generate y, x1, x2 for each stocks 
	Step 3: Run regression (1) to estimate  2 for each month
References
    Pastor, L. & Stambaugh, R., 2003, Liquidity risk and expected stock returns. 
    Journal of Political Economy 111, 642-685.

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

Method #1 to calculate VaR (assume a normal distribution)
///////////////////////////
   VaR  =  p * (mean - z * std )            (1)
   VaR  : is our var
    P   : is our position, such as value of our portfolio 
   mean : is our period mean return 
   z    : depend on confidence level
  std   : is the period standard deviation 

    z=2.326 when the confidence is 99%
     =1.64  When the confidence is 5%
Sign issue
----------
   VaR  =  p * (mean - z * std )            (2)
     z  = 
      
    > qnorm(1-0.01)    
        [1] 2.326348

    > qnorm(1-0.05)
          [1] 1.644854
///////////////////////////