Stata The Stata listserver
[Date Prev][Date Next][Thread Prev][Thread Next][Date index][Thread index]

st: RE: Geometric Standard Distribution


From   "Nick Cox" <[email protected]>
To   <[email protected]>
Subject   st: RE: Geometric Standard Distribution
Date   Tue, 10 Aug 2004 21:26:26 +0100

Assuming this is exp(sd(log())), I guess most 
people would take the logs, etc. Writing your 
own is not too difficult; below is a sketch.

------------------------------ begin geomeansd 
program geomeansd
	version 8
	syntax [varlist] [if] [in] 
	marksample touse, novarlist 

	qui count if `touse' 
	if r(N) == 0 error 2000 
	if r(N) == 1 error 2001 

	local shown = 0 
	qui foreach v of local varlist { 
		capture confirm string var `v' 
		if _rc { 
			if !`shown' {  
				noi Displayheader 
				local shown = 1 
			} 	
			tempvar logv 
			gen `logv' = log(`v') if `touse' 
			su `logv' if `touse'
			noi di as txt abbrev("`v'",12) _col(15) ///
			       as res %6.0f r(N)                /// 
			       as res %15.3f exp(r(mean))       ///
			       as res %15.3f exp(r(sd)) 
			drop `logv' 
		} 	
	}
end 
		
program Displayheader 
	di 
	di as txt "{space 17}Obs     Geom. Mean       Geom. SD"
	di "{hline 50}" 
end 		
------------------------ end geomeansd.ado 


Nick 
[email protected] 

> I have a set of data that follows log-normal distribution.  
> In STATA the
> command "means" only gives geometric mean and confidence 
> intervals. Is there
> a way to calculate geometric standard deviation in STATA?

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