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

st: re: regression simulation


From   Christopher F Baum <[email protected]>
To   [email protected]
Subject   st: re: regression simulation
Date   Sun, 19 Dec 2004 16:13:59 -0500

Haseeb said

i want to generate two random normally distributed
(with centain mu and sigma) and run a regression to
save t stat and se to a data file. I want to replicate
the simalation by 1000 times.

This may not be the most elegant way to do it, but this does it for 10 reps:

clear
local nrep 10
set obs 100
gen z = uniform()
postfile handle se t using haseeb, replace
forv i = 1 /`nrep' {
capt drop y x
drawnorm y x
reg y x
post handle (_se[x]) (_b[x]/_se[x])
}
postclose handle
use haseeb, clear
desc
su

Note that you may also specify a covariance (or correlation) between the variables drawn from the multivariate normal with drawnorm. I am using the default here, which draws them independently.

Kit Baum, Boston College Economics [email protected]
http://ideas.repec.org/e/pba1.html

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