Announcement

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

  • saving p values of regression results using loops?

    Dear All,
    I am using a difference-in-difference setup to evaluate a treatment effect. Unfortunately it is not so clear, when the treatment started. I am working on a qualitative solution by reading through relevant documents, but I also want to work on a quantitative solution. I do know that the treatment started between 18745 and 378 days later. To this end I use the following for loop:

    Code:
        log on
        forvalues i =1(3)378 {
            di "We are at i = " `i'
            gen treattime = 0
            replace treattime = 1 if date >18745+ `i'
            gen did = treated*treattime
            reg ret did treated treattime, robust
            //reg ret did treated treattime i.bankid, cluster(bankid)
            drop treattime did
            }
        log off
    My log reports contain the regression tables and I can see how the p value of the did variable starts to decrease after a while. Now I want to try different specifications and ideally save the p value of the did regressor in a vector where I can relate it to the step i, I am at. Later I would want to export that vector (for example to excel or csv).
    Seems like not a standard-Stata-task.

    I am aware that this is the kind of data-mining excercise that should not be encouraged, but at this point I am really just trying to understand my data better.

    Any advice is appreciated!

    Best,

  • #2
    This Statatip is about how to extract the p-values: http://www.stata-journal.com/article...article=st0137
    ---------------------------------
    Maarten L. Buis
    University of Konstanz
    Department of history and sociology
    box 40
    78457 Konstanz
    Germany
    http://www.maartenbuis.nl
    ---------------------------------

    Comment


    • #3
      As an aside, don't do
      Code:
      gen did = treated*treattime
      reg ret did treated treattime, robust
      do this instead:
      Code:
      reg ret i.did##i.treated, robust
      In your particular situation, it may not make much difference, but it is best to get in the habit of letting Stata create interaction terms by using factor-variable notation, because most of the time you will want to run -margins- afterward to help interpret the results.

      Comment

      Working...
      X