[Date Prev][Date Next][Thread Prev][Thread Next][Date index][Thread index]

st: ado coding help needed

From   "Rajesh Tharyan" <>
To   <>
Subject   st: ado coding help needed
Date   Thu, 6 Mar 2008 10:24:53 -0000


Following the recent discussion on the bootstrapped skewness adjusted t
statistic. This is my attempt at a program to implement this. The following
ado calculates the skewness adjusted t statistic based on Johnson(1978) and
made very popular in finance area by LBT(1999). As I mentioned in an earlier
post  there is an ado called Johnson which implements this test. But somehow
the skewnesss adjusted t stat values are different when I use that program.
I have double checked the calculation for this  by manually calculating the
skewness adjusted t-stats.

I have two programs One to calculate the skewness adjusted t stats
(rtskew.ado) and the other to do the bootstrap (skewt.ado) 

Could someone please tell me If I can do this with one program and how?

Ideally what I would want is for the user to say 

. skewt varname 

And the varname feeds into the rtskew program.

In the following line in the skewt program

bootstrap r(ratio), saving(C:\mydata, replace) reps(1000) size(int(_N/4)):

is there a way to say something like (int(_N/`x')), and get the value of x
from the user.  

My programs follow...

capture program drop rtskew
program define rtskew, rclass
mac def S_1                     /* the skewness adjusted t stats */
foreach var of local 0 {
capture confirm numeric variable `var'
if _rc==0 {
drop if `var'==.
quietly sum `var',detail
local n = sqrt(r(N))
local u = r(mean)
local v = r(sd)
local g = r(skewness)
local s= _result(3)/r(sd)

di in gr _col(20)  "stats from the sample"
di ""
di in gr _col(20) "N coefficient  = `n'"
di in gr _col(20) "S-coefficient  =  `s'"
di in gr _col(20) "G-coefficient  =   `g'"
di in gr _col(20) "Sample mean    =  `u'"

mac def S_1 = (`n') * ((`s') + ((1/3) * (`g') * ((`s')^2)) +
((1/(6*((`n')^2)))* (`g'))) 
else {
di "`var' is not a numeric variable skewness adjusted t-statistic cannot be
return scalar ratio= $S_1

To bootstrap the t statistic I need another program

capture program drop skewt
program define skewt, rclass
rtskew mpg
return scalar ratio= $S_1
bootstrap r(ratio), saving(C:\mydata, replace) reps(1000) size(int(_N)):
estat bootstrap, all 
use C:\mydata,clear histogram  _bs_1 
centile _bs_1, centile(.5,99.5, 2.5, 97.5, 5,95) 

Thank you very much

*   For searches and help try:

© Copyright 1996–2014 StataCorp LP   |   Terms of use   |   Privacy   |   Contact us   |   What's new   |   Site index