[R-SIG-Finance] Skewness function for intraday data return distribution

Roupell, Darko Darko.Roupell at cba.com.au
Mon Oct 31 06:18:16 CET 2011


Hi All,

I have written a skew function to calculate stock skewness using intraday 5 min data. However, going through literature I have come across two very similar formulas, though they produce different skewness coefficient and wonder if anyone else has used similar formulas and know which one is the correct one.

mq_skewness = function(data){
data = dataformatc(data);
  #returns midquote log returns as xts object
  mq_ret = mq_return(data);  
  #returns midquote log returns as xts object
  mq_ret_sqr = mq_ret^2;
  #returns realized daily volatility as xts object
  RVar=sum(  mq_ret_sqr)
  n = length(mq_ret);
  
  #first formula to measure skewness 
  mq_skewness = sqrt(n) * (sum(mq_ret^3))/sum(mq_ret_sqr)^(2/3)
 
 # second formula to measure skewness 
  mq_skewness = sqrt(n) * sum((mq_ret/sqrt(RVar))^3)
  
  return(mq_skewness);
}

  #first formula to measure skewness 
  mq_skewness = sqrt(n) * (sum(mq_ret^3))/sum(mq_ret_sqr)^(2/3)
[1] 0.0003991095
  # second formula to measure skewness 
  mq_skewness = sqrt(n) * sum((mq_ret/sqrt(RVar))^3)
[1] 0.09759751
# this is output from base package function but this may not be appropriate to use for intraday data
skewness(mq_ret)
[1] 0.3035787
__________________________________________________
Darko Roupell 



************** IMPORTANT MESSAGE *****************************       
This e-mail message is intended only for the addressee(s) and contains information which may be
confidential. 
If you are not the intended recipient please advise the sender by return email, do not use or
disclose the contents, and delete the message and any attachments from your system. Unless
specifically indicated, this email does not constitute formal advice or commitment by the sender
or the Commonwealth Bank of Australia (ABN 48 123 123 124) or its subsidiaries. 
We can be contacted through our web site: commbank.com.au. 
If you no longer wish to receive commercial electronic messages from us, please reply to this
e-mail by typing Unsubscribe in the subject line. 



More information about the R-SIG-Finance mailing list