I am trying to implement a simulation and face an error message. Apparently it has to do with the previously defined global macro that I use in the simulation program. The error can be illustrated by this simple example code:
Code:
clear
set seed 123
set obs 100
gen binary = runiformint(0,1)
gen indep = runiformint(0,100)
// EXAMPLE PROBIT REGRESSION, SAVING ONE REGRESSION OUTPUT VALUE AS A GLOBAL MACRO
probit binary indep
global probit_cons _b[_cons]
// SIMULATION PROGRAM
capture program drop sim1
program define sim1
// IRRELEVANT EXAMPLE CALCULATION IN THE SIMULATION
clear
set obs 10
gen uni = runiform()
sum uni, meanonly
scalar a = r(mean)
// THIS IS THE PROBLEMATIC LINE - WHY?
gen test = normal($probit_cons)
end
simulate a, reps(10): sim1Code:
no variables defined an error occurred when simulate executed sim1 r(111)
I would be greatful for any hint.
Best,
Tom Storwitz
0 Response to Simulation fails when global macro is called
Post a Comment