But I was wondering whether it is possible to have a macro indicator of the repetition. The goal is to execute a certain command only for that repetition, within the program being simulated. For instance, I might wish to display some feature of the data, but I only want to have a look in the first simulation, not all of them. Can't find anything about this in the simulate help command. Here is a working example. I'd like to generate some plot but only for a given repetition.
Code:
clear all cap drop program MCS program MCS, rclass drop _all // drop all observations set obs 10000 // set the sample size ge X = rnormal(0,1) ge Y = 10 + X + rnormal(0,1) reg Y X return scalar bOLS = _b[X] predict Yhat scatter Y X || line Yhat X // I would like this displayed only for a given repetition say // if `r'==10 { scatter Y X || line Yhat X } end simulate bOLS=r(bOLS), reps(100) seed(12346): MCS
0 Response to rep macro in simulate command
Post a Comment