Announcement

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

  • Problem with xtserial

    Hi everyone,
    I am running a fixed-effects model with robust standard errors and I'd like to test for within-group serial correlation. The relevant code is the following:

    xtset country_num year
    xtreg score second_period third_period, fe vce(robust)

    I read that I should use xtserial for the test, but when I try to run the following code: xtserial score, I get the error message "no observations". I don't know why I get it and how I could avoid it.
    Sorry if this sounds trivial and thanks in advance!


  • #2
    Do you have only two time periods in your panel? It does not make sense to test for serial correlation with two time periods. Implementation-wise, the Wooldridge (2002) test of serial correlation is based on a first-differenced regression, so you need a minimum of 3 time periods.

    Reference:
    Wooldridge, J. M. 2002. Econometric Analysis of Cross Section and Panel Data. Cambridge, MA: MIT Press.

    Comment


    • #3
      I have two time periods but each contains several years, that's why I thought serial correlation could be a problem. Instead what matters are the periods of the dummies included in the model, is that right?

      Comment


      • #4
        You’ll need to show a data extract. I don’t know what it means to have two periods but several years within each. Is this like a difference-in-differences setup?

        Comment


        • #5
          I have two time periods but each contains several years
          The only way I can make sense of this is that you have a weakly balanced panel, i.e., the years are not unique across panels, but each panel has 2 time periods. Indeed, the only way the following doesn't throw an error is if "country_num" identifies panels and "year" identifies time periods.

          xtset country_num year
          xtreg score second_period third_period, fe vce(robust)
          that's why I thought serial correlation could be a problem.
          As I said, with two time periods, there is no notion of temporal correlation. Here, what matters is the \(T\) dimension, regardless of how large \(N\) is. If the above is not correct, you need to show us the result of

          Code:
          xtset country_num year
          xtsum country_num year

          Comment


          • #6
            Sorry. It is like a difference-in-differences setup in the sense that I have a watershed event and the pre and post periods (1984-1992 and 1992-2019).
            I attached the output of xtsum country_num year, I hope it is correct

            Attached Files

            Comment


            • #7
              So you have 116 observations and 11 countries which averages to 10.5 observations per country. One reason that you would get a "no observations" error from xtserial (the Stata Journal) is if you do not have at least 3 consecutive years per country. You lose a cross-section from differencing, and you need at least 2 observations to run a regression. So one thing that you could do is to create an alternative time variable and then proceed with this.

              Code:
              bys country_num (year): gen time=_n
              xtset country_num time
              xtserial score

              Comment


              • #8
                Yes, I think the problem was that I don't have consecutive years, but gaps between observations from different years.
                Using your code I am able to run xtserial, thanks!

                Comment


                • #9
                  Originally posted by Andrew Musau View Post
                  So you have 116 observations and 11 countries which averages to 10.5 observations per country. One reason that you would get a "no observations" error from xtserial (the Stata Journal) is if you do not have at least 3 consecutive years per country. You lose a cross-section from differencing, and you need at least 2 observations to run a regression. So one thing that you could do is to create an alternative time variable and then proceed with this.

                  Code:
                  bys country_num (year): gen time=_n
                  xtset country_num time
                  xtserial score
                  Dear Andrew,
                  I am running a REM and'd like to test for within-group serial correlation. I should use xtserial for the test, but when I try to run the following code: xtserial, I get the error message "no observations (2000)". I have read everyone's questions and answers, and I have applied but still no results. I think the reason is because my data only has 2 years (2014 and 2022). However, I have read a number of similar studies, some covering only 2 years (2009 and 2015). They said they used Actest and robust vce. But I still can't get results when I try to use them.
                  I look forward to your help.

                  Thank youuuuuu.

                  Comment


                  • #10
                    Emma: You can't test for serial correlation with T = 2 if you are using fixed effects -- equivalently, first differencing. If you use FE, use vce(cluster country) or vce(robust). There's nothing for you to test concerning serial correlation (and no need to, either).

                    Comment


                    • #11
                      Originally posted by Jeff Wooldridge View Post
                      Emma: You can't test for serial correlation with T = 2 if you are using fixed effects -- equivalently, first differencing. If you use FE, use vce(cluster country) or vce(robust). There's nothing for you to test concerning serial correlation (and no need to, either).
                      Hello M. Wooldridge, i need your help for an autocorrelation test i trying to do on stata

                      Comment

                      Working...
                      X