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

Re: st: re: regression simulation


From   "maartenbuis" <[email protected]>
To   [email protected]
Subject   Re: st: re: regression simulation
Date   Mon, 20 Dec 2004 10:59:39 -0000

--- 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.
 
--- Christopher F Baum <baum@b...> wrote:
>> This may not be the most elegant way to do it
<snip>

One way to make Kit's code more elegant is to use the -simulation-
command:

program define sim, rclass
drop _all
set obs 100
drawnorm y x
reg y x
return scalar se = _se[x]
return scalar t  = _b[x]/_se[x]
end

simulate "sim" se=r(se) t=r(t), dots reps(1000)
desc
sum




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