Announcement

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

  • *reassign values from a random date - placebo

    Hello statalists,

    Please, I would like to create a placebo with my dataset below.
    Code:
    * Example generated by -dataex-. To install: ssc install dataex
    clear
    input float(firm city date sales)
     1 1 1 100
     2 2 1 120
     3 2 1 111
     4 3 1  90
     5 4 1 250
     6 4 1 123
     7 5 1 345
     8 5 1 199
     9 6 1  90
    10 7 1  98
     1 1 2 178
     2 2 2 300
     3 2 2 210
     4 3 2 229
     5 4 2 567
     6 4 2 897
     7 5 2 200
     8 5 2  90
     9 6 2  10
    10 7 2 100
    end
    I wish to do two exercises: 1) reassign sales from a random date (for the same city) and
    2) random city (for the same date).
    I wish to run each randomization 500 times.

    Could anyone give me a suggestion, please?

    Many thanks!

  • #2
    I believe the -permute- command will do the exchanges you want. You did not say what procedure you wanted to perform on the "placebo" data, which matters, because permute requires that you specify some procedure. I just computed the mean, but you might do a regression, etc. Now, if you actually want to save 500 sales variables, shuffled as you describe, that's another matter. In that case, the user-written program -shufflevar- (ssc describe shufflevar) might be worth considering.

    Code:
    // Exchange sales values among firms whose observations share the same date
    permute sales M = r(mean), reps(500) strata(date): summ sales
    // Exchange sales values among firms whose observations share the same city
    permute sales M = r(mean), reps(500) strata(city): summ sales

    Comment


    • #3
      Mike Lacy Thank you very much for your reply!
      What I would like to do indeed is run regressions using the fake values. For example, my main model is:
      Code:
       reghdfe sales tax, a(city date) cluster(city)
      The value of tax vary with the city; the values of sales varies per firm. So what I wish is to create in sample placebos and run 500 regressions with 500 'permuted' values of cities. So, for example, if firm 1 is located in city 1, I want to run regressions pretending firm 1 is located in other cities, therefore, the value of sales will be the same but the value of tax (which is given by the city) will be fake. And I want to repeat it lots of times.

      In another exercise, instead of using 'fake' city, I would use 'fake date'.
      Code:
      * Example generated by -dataex-. To install: ssc install dataex
      clear
      input float(firm city date sales tax)
       1 1 1 100 1000
       2 2 1 120 2341
       3 2 1 111  200
       4 3 1  90 2111
       5 4 1 250 2099
       6 4 1 123 1200
       7 5 1 345 3429
       8 5 1 199 1245
       9 6 1  90  900
      10 7 1  98  890
       1 1 2 178  976
       2 2 2 300 5766
       3 2 2 210 1001
       4 3 2 229 2090
       5 4 2 567  784
       6 4 2 897  456
       7 5 2 200  923
       8 5 2  90  437
       9 6 2  10  188
      10 7 2 100  911
      end
      Last edited by juliana pinto; 06 Nov 2020, 00:20.

      Comment


      • #4
        If your goal is to examine how the coefficients of your -reghdfe- model vary across random reassignments of sales values to firms, then yes, it would seem that -permute- does what you want. The saving() option of -permute- will enable you to save those coefficients and examine them as desired. I'm not familiar with the terminology or methods implied by the term "placebo" in this context, so I can't likely offer further useful advice.

        Comment


        • #5
          Thank you very much!!

          Comment

          Working...
          X