Announcement

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

  • How can I include year-fixed effects into monthly panel data?

    Hi,

    I have monthly panel data on 350 mutual funds over the period January 2007 to December 2015. Here is a small extract of my data:

    Code:
    * Example generated by -dataex-. To install: ssc install dataex
    clear
    input int FundID str7 Date double(TotalAssets Flows Return Expenses)
    1 "oct2012"  75.4    .95325         -8.2476               1.35
    1 "nov2012"  76.2   3.49890        -29.2548               1.349
    1 "dec2012"  75.7    .46943        -13.5072               1.35
    1 "jan2013"    77  -5.46289         86.1624               1.35
    1 "feb2013"  98.9  28.90355         -5.544                1.35
    1 "mar2013" 107.7   6.25727         31.6872               1.35
    end
    label var FundID "FundID" 
    label var Date "Date" 
    label var TotalAssets "FundSize" 
    label var Flows "Flow" 
    label var Return "SiReturn" 
    label var Expenses "Expense"
    I am using xtreg and fe to regress Flows on Return and some controls. In the literature, year-fixed effects are used in many of these models. How can I implement year-fixed effects when I have monthly data?

    Kind regards,
    Stephan

  • #2
    Stephan:
    welcome to this forum.
    To create the (numerical) categorical variable -year- you may want to try:
    Code:
    . gen year = substr(Date,4,4)
    
    . destring year,g(num_year)
    Then you can include -num_year- in the right-hand side of your panel data regressione equation using -fvvarlist- notation (see related help file):
    Code:
    xtreg <depvar> <otherindepvars> i.year, fe
    Kind regards,
    Carlo
    (StataNow 18.5)

    Comment


    • #3
      Thank you very much for your answer. It works perfectly for my monthly panel data set. I also have the same data set at a quarterly level. What would be the code to generate year-fixed effects for quarterly panel data?

      Comment


      • #4
        Stephan:
        see -help substr()-.
        Kind regards,
        Carlo
        (StataNow 18.5)

        Comment


        • #5
          Thanks for your help Everything worked perfectly.

          Comment

          Working...
          X