Statalist


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

st: programming prob


From   "Martin Weiss" <[email protected]>
To   <[email protected]>
Subject   st: programming prob
Date   Fri, 11 Apr 2008 14:14:54 +0200

Dear Statalisters,

I wanna check the power of normality tests and to this end I have written a
program that does exactly that. It worked fine until I added an option to
provide a desired sig. level to the program. Stata complains about the
syntax, and I cannot figure out why. Any ideas why that might be? I want to
make both varlist and sig optional so I put them in square brackets. Here is
the program (with useful commands around it):

*********
  capt pr drop normality
  
  pr de normality, rclass
        version 10
        syntax [varlist(max=1 numeric default=none), sig(0.95)] 
*        set trace on
	      tokenize `varlist'
        if "`1'" !=""{
					qui{		
	
noi di _newline
	
noi di in red "Var supplied"
						        sktest `1',
level(`sig')
*						         set trace off
						        ret sca psk =
r(P_chi2) 
						        sfrancia `1',
level(`sig')
						        ret sca psf  = r(p)
						        swilk `1',
level(`sig')
						        ret sca psw  = r(p)
						*end quietly        
					}
					*end if
				}
				else{
							qui{
							noi di _newline
							noi di in red "No
var supplied, generating 1.000 standard normal random deviates"
							drop _all
							tempvar h
							set obs 1000
		    			g `h'=invnormal(uniform())
		    			sktest `h', level(`sig')
*		    			set trace off
						  ret sca psk = r(P_chi2) 
						  sfrancia `h', level(`sig')
						  ret sca psf  = r(p)
						  swilk `h', level(`sig')
						  ret sca psw  = r(p)
						  * qui end
						}
						*else end
						}
    end
    
    
    
simulate psk=r(psk) psf=r(psf) psw=r(psw), reps(200): normality, sig(0.99)


qui{
	count if psk<`=1-`sig''
	
	noi di in red "Skewness/Kurtosis Test:" _skip(2) r(N) " out of " _N
", which works out as fraction " `=r(N)/_N' "with sig. level at " `sig'
_newline
	
	
	count if psf<`=1-`sig''
	
	noi di in red "Sfrancia Test:" _skip(2) r(N) " out of " _N ", which
works out as fraction " `=r(N)/_N' _newline
	
	
	count if psw<0.05`=1-`sig''
	noi di in red "Swilk Test:" _skip(2) r(N)  " out of " _N ", which
works out as fraction " `=r(N)/_N' _newline 
}
*********

Martin Weiss
_________________________________________________________________

Diplom-Kaufmann Martin Weiss
Mohlstrasse 36
Room 415
72074 Tuebingen
Germany

Fon: 0049-7071-2978184

Home: http://www.wiwi.uni-tuebingen.de/cms/index.php?id=1130

Publications: http://www.wiwi.uni-tuebingen.de/cms/index.php?id=1131

SSRN: http://papers.ssrn.com/sol3/cf_dev/AbsByAuth.cfm?per_id=669945



*
*   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/



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