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

From |
"Nick Cox" <n.j.cox@durham.ac.uk> |

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

Subject |
st: RE: Descriptive statistics and normality tests |

Date |
Tue, 21 Sep 2004 15:23:02 +0100 |

You will need to do some programming, I believe. The other day I wrote a -moments- for my own use. This may look quite redundant given -tabstat- but it has more deliberate defaults and better controls on format than -tabstat- _for this particular purpose_. You'd need to add in a call to -sktest-. That said, -sktest- is yet another example of something often used automatically when thought is generally preferable. As often pointed out on this list, it may easily produce low P-values even when the degree of non-normality is trivial practically. It does what it is designed to do, of course, which is part of the problem. Nick n.j.cox@durham.ac.uk *! 1.0.0 NJC 13 September 2004 program moments, byable(recall) version 8.0 syntax [varlist(numeric)] [if] [in] /// [, Matname(str) Format(str) ALLobs * ] local nvars : word count `varlist' if `nvars' > _N { preserve qui set obs `nvars' } if "`allobs'" != "" marksample touse, novarlist else marksample touse tempvar a group id n mean SD skewness kurtosis which tempname mylbl qui { gen long `which' = _n compress `which' gen `n' = "" label var `n' "n" foreach s in mean SD skewness kurtosis { gen ``s'' = . label var ``s'' "`s'" } } if "`matname'" != "" mat `matname' = J(`nvars',5,0) local I = 1 qui foreach v of local varlist { su `v' if `touse', detail replace `n' = string(r(N)) in `I' replace `mean' = r(mean) in `I' replace `SD' = r(sd) in `I' replace `skewness' = r(skewness) in `I' replace `kurtosis' = r(kurtosis) in `I' if "`matname'" != "" { mat `matname'[`I',1] = r(N) mat `matname'[`I',2] = r(mean) mat `matname'[`I',3] = r(sd) mat `matname'[`I',4] = r(skewness) mat `matname'[`I',5] = r(kurtosis) } label def `mylbl' `I' "`v'", modify local `I++' } if "`matname'" != "" { mat colnames `matname' = n mean SD skewness kurtosis mat rownames `matname' = `varlist' } label val `which' `mylbl' if "`allobs'" != "" label var `which' "Variable" else label var `which' "n = `r(N)'" local fmt "format(%9.3f)" if "`format'" != "" { tokenize `format' if "`4'" != "" { tempvar skurtosis gen `skurtosis' = string(`kurtosis', "`4'") label var `skurtosis' "kurtosis" local kurtosis "`skurtosis'" } if "`3'" != "" { tempvar sskewness gen `sskewness' = string(`skewness', "`3'") label var `sskewness' "skewness" local skewness "`skewness'" } if "`2'" != "" { tempvar sSD gen `sSD' = string(`SD', "`2'") label var `sSD' "SD" local SD "`sSD'" } tempvar smean gen `smean' = string(`mean', "`1'") label var `smean' "mean" local mean "`smean'" } if "`allobs'" != "" local shown "`n'" tabdisp `which' if `which' < `I', /// c(`shown' `mean' `SD' `skewness' `kurtosis') `options' `fmt' end Herve STOLOWY > Is there an easy way to display in the same table a few > summary statistics with a normality test for each variable? I > know how to do separately (with tabstat and sktest) but have > some difficulties to get it automatically in the same table. * * 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/

- Prev by Date:
**Re: st: RE: Nested loops?** - Next by Date:
**Re: st: Descriptive statistics and normality tests** - Previous by thread:
**Rép. : RE: RE: st: Gologit, ologit and Akaike's Information Criterion** - Next by thread:
**st: estimates and dprobit** - Index(es):

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