<>
"Dr. Maartin's " is a new and enjoyable variant of a long running joke.
Anyway:
Get rid of the equal sign in "regress x2 =  z1 z2 z3 z4 mu "
Capture x2hat as -predict x2hat- w/o options as what you want is the 
default...
You may want to -set seed- inside the -simulate- command rather than 
outside...
Take a look at -drawnorm-. If you set all correlations to zero, you could 
save a couple of -generate-s.
"how do I tell stata that my y is a probit" -probit- is a model/Stata 
command, not a thing. I guess you want this to be a dummy, so it becomes 
amenable to analysis via -ivprobit-. You could simply say -generate y = 0.5 
+ 2*x1 + x2hat + mu + u>4- if "4" is a good value from which on you want the 
dependent to be 1. I have not checked that in detail.
Why do you want to capture the parameters x1 and x2hat? One is a variable 
that you -generate-d, the other a prediction derived from your -regress-ion. 
They are vectors of values, not parameters, and I think -simulate- is not 
equipped to capture those (would be a lot of data, for every replication 2 
vectors @ 500 observations each...)
HTH
Martin
_______________________
----- Original Message ----- 
From: "Sachin Chintawar" <[email protected]>
To: <[email protected]>
Sent: Monday, April 20, 2009 11:40 PM
Subject: st: Simulating Instrumental Variable Probit Model
Dear Statalist Users
I was trying to simulate a probit model with endogenous regressor and
increase the number of instruements to see how bias occurs due to
increased instruements. Following Dr. Maartin's example and the
Microeconometrics using Stata book I have created the following
program (which ofcourse I am not satisfied due to glaring mistakes). I
would greatly appreciate if you could give me some pointers and inputs
that could help me fix it.
----------------------------Start
Example---------------------------------------------------------------------------------------
global numobs 500             // sample size N
global numsims "1000"         // number of simulations
set seed 123456789
capture program drop endoprob
program endoprob, rclass
version 10.1
drop _all
set obs $numobs
   generate u = rnormal(0)
   generate mu = rnormal(0)
   generate x1 = rnormal(0)
   generate z1 = rnormal(0)   // 4 Instruements
   generate z2 = rnormal(0)
   generate z3 = rnormal(0)
   generate z4 = rnormal(0)
   generate a = 0.5*u
   generate x2 = z1 + z2 + z3 + z4 + a
   regress x2 =  z1 z2 z3 z4 mu                // endogenous
regressor with four instruments
                 //capture x2hat
   generate y = 0.5 + 2*x1 + x2hat + mu + u    //Reduced Form Equation
   ivprobit y x1 x2hat
//Capture the betas and SD's
end
------------------------------------End
Example----------------------------------------------------------------------------------
1. Well my first question is quite obvious how do I tell stata that my
y is a probit
2. How do I capture xhat2 so I can get my ivprobit to work?
3. From the MUS book I understood that _b captures the scalar beta
value but how can we capture the two parameters x1 and x2hat?
I would greatly appreciate your help in this regard
Sincerely
Sachin
*
*   For searches and help try:
*   http://www.stata.com/help.cgi?search
*   http://www.stata.com/support/statalist/faq
*   http://www.ats.ucla.edu/stat/stata/
*
*   For searches and help try:
*   http://www.stata.com/help.cgi?search
*   http://www.stata.com/support/statalist/faq
*   http://www.ats.ucla.edu/stat/stata/