+ Reply to Thread
Results 1 to 2 of 2

Thread: Help with First Differencing in STATA

  1. #1
    Points: 7, Level: 1
    Level completed: 13%, Points required for next Level: 43

    Thanked 0 Times in 0 Posts

    Help with First Differencing in STATA

    I am a student working with STATA for the first time. I am using panel data for the English Premier League football from 2010 to 2015 and am having trouble with first differencing my data to control for unobserved heterogeneity. Overall, I am interested in how a team's total player salary explains performance through statistics like total wins, shots, crosses, goalkeeper saves, and blocks

    I have the 10 teams I am looking at in the observations column and have set up my statistics of interest as variables distinguished by year (i.e., Wins2010, Wins2011, etc.).

    Do I need to rearrange my data in order to do first differencing in STATA or is there a way to input the function so that I have 5 dummy variables to account for the different years?

    Any help is greatly appreciated!

  2. #2
    TS Contributor
    Points: 5,246, Level: 46
    Level completed: 48%, Points required for next Level: 104
    maartenbuis's Avatar
    Thanked 146 Times in 123 Posts

    Re: Help with First Differencing in STATA

    Situations like these are almost always much easier in "long" format, see help reshape. After that you declare your data to be a time series with tsset and use the lag operator. Below is an example:

    clear all
    // some example data
    input team wins2010 wins2011 wins2012 wins2013 wins2014 wins2015
    1 1 2 3 4 5 6
    2 0 0 0 1 1 1
    3 9 9 9 9 9 9
    // reshape
    reshape long wins , i(team) j(year)
    // declare time series (within teams)
    tsset team year
    // create differences
    gen dwins = d.wins
    // admire the results
    list, sepby(team)

+ Reply to Thread


Tags for this Thread

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts

Advertise on Talk Stats