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

st: RE: Central LImit Theory


From   "Nick Cox" <[email protected]>
To   <[email protected]>
Subject   st: RE: Central LImit Theory
Date   Wed, 11 Dec 2002 17:58:53 -0000

Jitian Sheu

> Does anyone know how to demonstrate Central Limit Theory in Stata?

Here is one way to do it: 

clear 
set obs 10000 
gen y = -10 * ln(uniform()) 
egen sample = seq(), b(100)
egen n = seq(), t(100) 
forval i = 1/10 { 
	local n = `i'^2 
	qui egen mean = mean(y) if n <= `n', by(sample) 
	qnorm mean if n == 1, t1(sample size is `n') saving(qnorm`i')
	more 
	dotplot mean if n == 1, t1(sample size is `n') saving(dotplot`i') 
	more
	drop mean 
} 

You can clearly vary 

1. # of samples (here always 100)
2. # in sample (here squares of 1(1)10) 
3. distribution you sample from (here exponential with mean 10)
4. sampling design 

Nick 
[email protected] 

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