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/