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

From |
"Rajesh Tharyan" <R.Tharyan@exeter.ac.uk> |

To |
<statalist@hsphsun2.harvard.edu> |

Subject |
st: ado coding help needed |

Date |
Thu, 6 Mar 2008 10:24:53 -0000 |

Hi, 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)): skewt is there a way to say something like (int(_N/`x')), and get the value of x from the user. My programs follow... ************start********************* 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 calculated." } return scalar ratio= $S_1 } } End ************end******************** To bootstrap the t statistic I need another program *********start****************** preserve capture program drop skewt program define skewt, rclass rtskew mpg return scalar ratio= $S_1 end bootstrap r(ratio), saving(C:\mydata, replace) reps(1000) size(int(_N)): skewt estat bootstrap, all use C:\mydata,clear histogram _bs_1 centile _bs_1, centile(.5,99.5, 2.5, 97.5, 5,95) restore ***********end******************* Thank you very much rajesh * * For searches and help try: * http://www.stata.com/support/faqs/res/findit.html * http://www.stata.com/support/statalist/faq * http://www.ats.ucla.edu/stat/stata/

**Follow-Ups**:**st: RE: ado coding help needed***From:*"Nick Cox" <n.j.cox@durham.ac.uk>

- Prev by Date:
**st: dtobit** - Next by Date:
**st: char extraction** - Previous by thread:
**st: dtobit** - Next by thread:
**st: RE: ado coding help needed** - Index(es):

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