Announcement

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

  • Test difference between mean of a var before and after an event.

    I have a data like this:

    Firm Year Event time_event Capital
    1 | 1 | 0 | -1 | 100
    1 | 2 | 1 | 0 | 150
    1 | 3 | 0 | 1 |125
    1 | 4 | 0 | 2 |100
    2 | 1 | 0 | . | 200
    2 | 2 | 0 | . | 200
    2 | 3 | 0 | . | 200
    3 | 1 | 1 | 0 | 300
    3 | 2 | 0 | 1 | 300
    3 | 3 | 0 | 2 | 300

    And I want to calculate de Mean of the Capital for the years after an event (1) and for the years before an event (-1), and test its difference no matter which firm it is.

    Thanks!
    Last edited by Tomas Jankelevich; 17 May 2018, 18:02.

  • #2
    Tomas:
    welcome to this forum.
    You might be interested in:
    Code:
    . g flag=0 if time_event==-1
    (9 missing values generated)
    
    . replace flag=1 if time_event==1
    (2 real changes made)
    
    . ttest Capital, by(flag) unequal
    Fot the future, please use CODE delimiters and/or -dataex- to share codes/outputs/excerpts/examples with interested Stata listers (see the FAQ about these and other posting-related topics). Thanks.
    Kind regards,
    Carlo
    (Stata 18.0 SE)

    Comment

    Working...
    X