[Date Prev][Date Next][Thread Prev][Thread Next][Date index][Thread index]

From |
Kit Baum <kitbaum@mac.com> |

To |
statalist@hsphsun2.harvard.edu |

Subject |
st: simulate |

Date |
Wed, 25 Aug 2004 21:07:37 -0400 |

Frank said

I am learning STATA programming. The following

question seems very basic, but I wasted much time

debugging it and failed to get through.

I copied the following codes exactly from somewhere,

but I can not get it running in STATA 8.1. What's the

problem?

Here is a working version. Note that you need _b[_cons], and the program must be rclass:

capt program drop _all

set seed 10101

program define simrandm, rclass

version 8.2

if "`1'"=="?" {

global S_1 "b_const se_const b_slope se_usual se_white"

exit

}

drop _all

set obs 20

gen x = invnorm(uniform())

gen u = x*invnorm(uniform())

gen y = 1+1*x + u

regress y x, robust

scalar sewhite=_se[x]

regress y x

return scalar a= _b[_cons]

return scalar as= _se[_cons]

return scalar b= _b[x]

return scalar sb= _se[x]

return scalar sw= sewhite

end

simulate "simrandm" a=r(a) as=r(as) b=r(b) bs=r(sb) bw=r(sw), reps(1000)

Kit

*

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

- Prev by Date:
**st: RE: vecstable graph ?** - Next by Date:
**st: RE: program define** - Previous by thread:
**st: program define** - Next by thread:
**st: how to -tsset- this data?** - Index(es):

© Copyright 1996–2016 StataCorp LP | Terms of use | Privacy | Contact us | What's new | Site index |