Announcement

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

  • Random allocation of a continuous treatment

    Hello members,

    I have the following situation.

    I need to randomly assign the treatment status by group (a time-invariant measure ranging from 0 to 1 to each firm that I follow over time in my sample). I want 1,0000 random allocations, run a regression for each random allocation, and next test for our many of these regressions the treatment coefficients are statistically significant. What command should I use for this exercise?

    Thank you in advance!

  • #2
    The built-in command -permute-, using its -strata- option, would randomly reassign the treatment variable within groups. Note that each simulated data set that have the same marginal distribution of treatment within group as in your observed data, which may or may not be what you want. See -help permute-.

    I understand this is a relatively abstract recommendation, but without a -dataex- data example, a less abstract answer is difficult. I'd encourage you to take a look at the StataList FAQ for new users on this subject and post again with a data example if this answer doesn't meet your needs. Here's a minimally tested illustration of what you might try:

    Code:
    sysuse auto, clear
    // Simulate treatment and group variables for illustration.
    gen byte treat = weight > 3000
    rename foreign group
    //
    permute treat p = el(r(table), 4, 1), ///
       saving(myout.dta) reps(1000) strata(group): ///
       regress price treat
    // Inspect the distribution of the p-value of interest.
    use myout.dta, clear
    You'd have to alter this to pick the right cell of r(table) to fit your regression command. You could check this out by running your regression command and then doing -matrix list r(table)-.

    Comment


    • #3
      Thank you very much for your kind help! It is exactly what I need.

      I am estimating a difference-in-differences model in which the observations are all treated in the same units.

      The exposure to treatment is a continuous variable that goes from 0 to 1. There are no firms that are completely not exposed to the shock. The treatment is always greater than 0 but lower than 1.

      More specifically, the model that I am estimating is the following:

      reghdfe y 1.post##c.treatment, absorb(firm year) cluster(firm) noomit nocons

      post is a dummy variable equal to one after the shock.

      It would also be nice to plot the coefficients. I am using this exercise as a placebo test.

      Again, thank you a lot!


      Comment


      • #4
        I read the question with insufficient care and overlooked that Stefano's treatment variable is continuous. However, for the benefit of future readers, I'd note that -permute- by no means requires that the permuted variable be binary, as in my illustration. If a plot of the coefficients in addition to the p-values is desired, their distribution can obtained by including expressions for them in the expression list of -permute-.

        Several times I've had occasion here to point an economist user seeking a "placebo" test to the existence of the -permute- command which often (not always) will implement what is desired. My impression is that the "permutation" terminology substantially predates "placebo" in this context and is in wider use. Nevertheless, perhaps Stata Corp. might want to insert "placebo" as a key word in the help documentation for -permute- <grin>.

        Comment


        • #5
          I adapted the code to my specific case (see below)

          permute treatment p = el(r(table), 4, 1), saving(myout.dta) reps(1000) strata(firm): reghdfe y 1.post#c.treatment, absorb(firm year) cluster(firm) noomit nocons

          However, it is not doing its job. Indeed, I got the same coefficients for all the 1,0000 random allocations. I think that is due to the interaction term.

          Do you have any idea about how I could solve this issue?



          ------------------------------------------------------------------------------
          T | T(obs) c n p=c/n SE(p) [95% Conf. Interval]
          -------------+----------------------------------------------------------------
          p | .0070853 1000 1000 1.0000 0.0000 .9963179 1
          ------------------------------------------------------------------------------
          Note: Confidence interval is with respect to p=c/n.
          Note: c = #{|T| >= |T(obs)|}

          Comment


          • #6
            I'm not certain what your problem is. (Among other things, I don't use the community-contributed package -reghdfe-, and it's possible that package or one of its options that you use doesn't work well with -permute-. I might suspect the cluster() or absorb() options, but those are guesses on my part.) I would suggest a strategy to determine where your problem is, namely to start with a simple -permute- command that uses a built-in estimation command, and work your way up to something more complicated involving -reghdfe-. So, for example, you might try:

            Code:
            permute treatment p = el(r(table), 4, 1), saving(myout.dta) reps(1000): ///
               regress y c.treatment
            Then try:
            Code:
            permute treatment p = el(r(table), 4, 1), saving(myout.dta) reps(1000) strata(firm): ///
               regress y c.treatment
            Then try a more complex regression specification, and so forth. When you've worked out the problems with a "regular" estimation command, then someone with -reghdfe- experience might be able to jump in here and help.

            Comment

            Working...
            X