Announcement

Collapse
No announcement yet.
X
  • Filter
  • Time
  • Show
Clear All
new posts

  • simulation/falsification with categorical variables as controls

    As a test of randomisation / falsification I am simulating random assignment of observations to treatment group using the 'simulate' command. I have a couple of categorical variables in my list of controls. I ran the regressions with "i.name_of_categorical_variable" and it worked. But this doesn't seem to work when I run the same command with 'simulate'

    My code for reference:
    simulate coefpolicy_effect=r(coefpolicy_effect) tpolicy_effect= r(tpolicy_effect) ppolicy_effect= r(ppolicy_effect) sepolicy_effect=r(sepolicy_effect) r2=r(r2) N=r(N) , reps(1000): my_model FP2A policy_effect post_policy treated RO5 ED6 i.HHEDUC HHEDUCF HHEDUCM SPED6 NMARRIEDF NMARRIEDM NPERSONS NADULTS URBAN INCOME forward_caste religion IDPSU STDIST01

    In the above code, the variable HHEDUC is a categorical variable, hence the i.HHEDUC in regression command.

    Any suggestions on how to run simulate with categorical variables?


  • #2
    replace i.HHEDUC with a set of binary indicators,
    Code:
    sysuse auto, clear
    reg price i.rep78
    tab rep78, gen(rep78_)
    reg price rep78_2-rep78_5

    Comment


    • #3
      I'll note something that is separate from any issues with factor variables here, but which might be of interest:

      What is being done here *might* more easily be done with -permute- rather than -simulate-, as the simulation Sarthatk describes sounds like what -permute- does, i.e., to repeatedly shuffle the value of one variable across observations, run an estimation command, and collect results. It's possible I'm not taking account of all of the details of what Sarthatk wants to do, but this looks to me like:
      Code:
      permute SomeTreatmentVariable  ///
         coefpolicy_effect=r(coefpolicy_effect)  tpolicy_effect= r(tpolicy_effect)..[etc.]..., ///
         reps(1000): SomeEstimationCommand


      This would avoid any need for managing the shuffling of the treatment variable within the my_model .. command, and might well be faster.

      Comment

      Working...
      X