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

Re: st: Drawing multiple samples from a normal distribution


From   Richard Williams <[email protected]>
To   [email protected]
Subject   Re: st: Drawing multiple samples from a normal distribution
Date   Tue, 21 Dec 2004 11:22:27 -0500

At 10:48 AM 12/21/2004 -0500, Joseph Cordes wrote:
I want to give my class a simple exercise in which each student is given a different sample that is drawn from the same normal distribution with a known mean and standard deviation, and then is asked to (a) calculate the sample mean, (b) do the standard inferences about the population mean from their estimate, (c) graph the different estimates of the sample mean produced in the class, and (d) reproduce the exercise with increasing sample size to demonstrate the notion of a consistent estimator.

My question is not about (a)-(d), but about how to create the samples. Am I correct that I could do this by using the following commands?

Set obs #

drawnorm sample1, mean(M) sds(sd)

and then simply repeating this command substituting sample2, sample3, etc. in for sample 1 to generate (in my case) 25 different samples?
First off, note that -set- needs to be lower case. In the above, it appears you are actually creating 25 different variables with the same mean and SD. If that is your goal, then try something like

clear
set seed 123456
set obs 100
forvalues i = 1/25 {
drawnorm sample`i', m(25) sd(5)
}
summarize

You could then assign each of them a variable, but each of them would also have access to all 25 variables/samples.

If you want them to draw the samples themselves, then I would have them use a set seed command, where the seed is unique for each person, so that (a) they can reproduce the results, and (b) they won't generate the exact same sample as someone else.

-------------------------------------------
Richard Williams, Notre Dame Dept of Sociology
OFFICE: (574)631-6668, (574)631-6463
FAX: (574)288-4373
HOME: (574)289-5227
EMAIL: [email protected]
WWW (personal): http://www.nd.edu/~rwilliam
WWW (department): http://www.nd.edu/~soc

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