Announcement

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

  • Month and year fixed effects

    Hi,

    I would like to include a year-specific month fixed effects, and I have variables for year and month. What is the best way to do it?

    I was thinking to generate a variable, based on the following code,

    Code:
    egen month_year_fe=group(month year)
    And then run the model
    Code:
    regress y X i.month_year_fe i.month i.year
    Does it look okay?

    Many thanks.

    Nikos

  • #2
    Your egen statement is just a backwards way to get a monthly date variable and

    Code:
    gen month_year = ym(year, month)
    format month_year %tm
    is surely more direct. The bigger issue is that your model boils down to fitting a parameter for every distinct date, and then some more, and so it spends many degrees of freedom. Everything depends on how far the anonymous Y and X are replicated.
    Last edited by Nick Cox; 19 Sep 2017, 05:03.

    Comment


    • #3
      Thank you Nick. I thought that the code I wrote is pretty much the same with the one you proposed, isn't it?

      Regarding the following, could you please further elaborate on this?

      The bigger issue is that your model boils down to fitting a parameter for every distinct date, and then some more, and so it spends many degrees of freedom. Everything depends on how far the anonymous Y and X are replicated.

      Comment


      • #4
        No; it's not the same. Your variable will order dates differently, as all the Januaries are grouped together, etc. You can't tell the date easily from the result; nor is interpretation at all straightforward as e.g. what 42 is will depend entirely on what months and years are in your dataset.

        I don't know what you don't understand in the quotation. I am suggesting that your model is far from parsimonious. That may not bite you, but as you're telling us nothing much about your data we can't be sure.

        Why don't you try the model and see what happens?

        Comment


        • #5
          Nikos:
          you might also have collinearity issues with your current specification.
          Kind regards,
          Carlo
          (Stata 18.0 SE)

          Comment


          • #6
            many thanks for your comments!

            Comment


            • #7
              How are year-specific month effects different from month effects? Or do you mean "January" instead of "January 2001" as month effect?

              Comment


              • #8
                Hi all together,

                I got a big amount of observations in four cities, on a monthly basis over many years.

                I prepared my xtreg like this:

                Code:
                egen citynr= group(city)
                xtset citynr
                gen monthyear=mofd(time)
                format monthyear %tm
                xtset citynr monthyear, monthly
                Besides the observable controls I want to integrate all of the following fixed effects

                1. city_fe That are city fixed effects to control for time invariant differences in each city.

                2. time_fe (year-month) That are time fixed effects, which account for time variant differences, common in each city

                3. city x i.time That accounts for having a linear time trend for each city in my panel. Is that correct? What would it be if I'd like to have a quadratic time trend for each city?

                4. city x month That are city-specific month fixed effect, which account for seasonal patterns for certain months. Is that correct?

                Now this would be the command I use for including all of them in my Benchmark-model:

                Code:
                xtreg log DV log IV log CV monthyear c.monthyear##i.citynr, fe vce(cluster Stadt)
                Is that correct? Do I have all of them included? I guess there are some of them missing...

                I would be super grateful, if you would take time to correct me!

                Tanja

                Comment


                • #9
                  Tanja:
                  welcome to this forum.
                  Some comments about your query:
                  -please note that the -fe- machinery will wipe out any time-invariant predictors. Hence, Stata will not calculate their coefficients;
                  -robust/cluster standard errors (unlike -regress- , these options do the very same job under -xtreg-) make sense if you detect heteroskeadsticity and/or autocorrelation in your dataset;
                  -logging the regressand and some predictors, while keeping the remaining independent variables in their original metric can pose some interpretation problems;
                  -this chunk of your code:
                  Code:
                  monthyear c.monthyear##i.citynr
                  which can be rewritten as:
                  Code:
                  c.monthyear##i.citynr
                  ;
                  - some of your fixed effects might be omitted due to collinearity;
                  - your code does not inlcude all your fixed effects, but that is not the main issue. I would rather recommend you to skim through the literature of your research fieald and see what others did in the past when presented with the same research topic.
                  Kind regards,
                  Carlo
                  (Stata 18.0 SE)

                  Comment


                  • #10
                    Dear Statalister,

                    I would like to apply a similar approach as the questions in #8 using region and year_month (month of birth x year of birth) fixed effects.

                    Is it possible for me to use the command:

                    Code:
                    c.monthyear##i.reg

                    I am currently using
                    Code:
                    reg wazs i.sex i.month i.monthyear i.reg
                    Thanks for your help!

                    Regards!

                    Comment


                    • #11
                      Dear Statalister,

                      I would like to apply a similar approach as the questions in #8 using region and year_month (month of birth x year of birth) fixed effects.

                      Is it possible for me to use the command:

                      Code:
                      c.monthyear##i.reg

                      I am currently using
                      Code:
                      reg wazs i.sex i.monthyear i.reg
                      Thanks for your help!

                      Regards!


                      Comment


                      • #12
                        Dear Statalist,

                        I am trying to generate an interaction dummy for month and year or a month year fixed effects.

                        I have used generated the month_year using
                        Code:
                        gen month_year =ym(year, month)
                        Code:
                        format month_year %tm
                        Then I ran my regression using
                        Code:
                        reg wazs i.sex i.month_year i.reg
                        I am also using region fixed effects.

                        Using the above approach my results are insignificant. I was wondering what is the difference between using the second command and using the command below
                        Code:
                        c.month_year ##i.reg
                        , as I am getting significant results when using this command.


                        Thanks for your reply.

                        Regards,

                        Comment


                        • #13
                          In command 2, you take out the average per month and the average per region. In command 3, you take out the average per month-region. E.g. in command 2 you take out the average impact of July 2009 and the average impact of being in the Northeast. In command 3 you take out the average impact of being in the Northeast in July 2009.

                          Think about it this way. If you have 100 months and 5 regions. Then in command 2 you include 100+5 = 105 dummies. In command 3 you include 100*5 = 500 dummies. (some will be omitted to avoid the dummy variable trap)

                          Comment


                          • #14
                            Dear Jesse,

                            Thank you so much for replying.

                            It is much clearer to me now.

                            King Regards!

                            Comment

                            Working...
                            X