Announcement

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

  • Sample may not include multiple panels error after trying to perform Breusch Godfrey test for

    Dear Everyone,

    I am using panel data and I want to test for autocorrelation in my dataset. The data covers 1059 companies, with for each company 2 (DV) Dependent Variables (ROA and Tobin's Q) and 5 (IV) Independent Variables. The data covers a maximum of 81 months (Jan 2014 - Oct 2020), where most of the companies only cover 24-36 months. Furthermore, in some cases there is data missing in the DV or IV in the relevant month (see the #N/A in the overview). Overview:
    ExtractionDate EntityName DV1 DV2 IV1 IV2 IV3 IV4 IV5 CompanyID
    1-9-2014 Company A #N/A 0,128 6,296 0,9 2536,192 30,308 0,004 1
    1-10-2014 Company A #N/A 0,128 6,296 0,9 2536,192 30,308 0,004 1
    1-11-2014 Company A #N/A 0,128 6,296 0,9 2536,192 30,308 0,004 1
    1-12-2014 Company A #N/A 0,128 6,296 0,9 2536,192 30,308 0,004 1
    1-1-2015 Company A 5,158 0,079 6,927 0,9 892,200 0,000 0,195 1
    1-2-2015 Company A 5,158 0,079 6,927 0,9 892,200 0,000 0,195 1
    1-3-2015 Company A 5,158 0,079 6,927 0,9 892,200 0,000 0,195 1
    1-4-2015 Company A 5,158 0,079 6,927 0,9 892,200 0,000 0,195 1
    1-5-2015 Company A 5,158 0,079 6,927 0,9 892,200 0,000 0,195 1
    1-11-2015 Company B 5,491 0,135 8,580 0,9 1107,4 0 0,170 2
    1-12-2015 Company B 5,491 0,135 8,580 0,9 1107,4 0 0,170 2
    1-1-2016 Company B 4,229 0,106 8,616 0,9 1399 0 0,181 2
    1-2-2016 Company B 4,229 0,106 8,616 0,9 1399 0 0,181 2
    1-3-2016 Company B 4,229 0,106 8,616 0,9 1399 0 0,181 2
    1-4-2016 Company B 4,229 0,106 8,616 0,9 1399 0 0,181 2
    1-5-2016 Company B 4,229 0,106 8,616 0,9 1399 0 0,181 2
    1-6-2016 Company B 4,229 0,106 8,616 0,9 1399 0 0,181 2
    1-1-2014 Company C 0,946 0,00713573 14,755008 1,15 870128 352 0,0539174 3
    1-2-2014 Company C 0,946 0,00713573 14,755008 1,15 870128 352 0,0539174 3
    1-3-2014 Company C 0,946 0,00713573 14,755008 1,15 870128 352 0,0539174 3
    1-4-2014 Company C 0,946 0,00713573 14,755008 1,15 870128 352 0,0539174 3
    1-5-2014 Company C 0,946 0,00713573 14,755008 1,15 870128 352 0,0539174 3
    1-6-2014 Company C 0,946 0,00713573 14,755008 1,15 870128 352 0,0539174 3
    1-7-2014 Company C 0,946 0,00713573 14,755008 1,15 870128 352 0,0539174 3
    1-8-2014 Company C 0,809 0,00229936 14,755008 1,15 930695 352 0,0635052 3
    1-9-2014 Company C 0,809 0,00229936 14,755008 1,15 930695 352 0,0635052 3
    1-10-2014 Company C 0,809 0,00229936 14,755008 1,15 930695 352 0,0635052 3
    1-11-2014 Company C 0,809 0,00229936 14,755008 1,15 930695 352 0,0635052 3
    As you can see in the overview above I have generated a CompanyID to sort and group the panel data per EntityName and ExtractionDate, using the code:
    sort EntityName ExtractionDate
    egen CompanyID = group(EntityName)

    To follow up on the latter, I have stated to STATA that I use panel data using the commands:
    xtset CompanyID ExtractionDate
    tsset CompanyID ExtractionDate
    (resulting in):

    . xtset CompanyID ExtractionDate
    panel variable: CompanyID (unbalanced)
    time variable: ExtractionD~e, 1/1/2014 to 10/1/2020, but with gaps
    delta: 1 day

    . tsset CompanyID ExtractionDate
    panel variable: CompanyID (unbalanced)
    time variable: ExtractionD~e, 1/1/2014 to 10/1/2020, but with gaps
    delta: 1 day

    I want to test for autocorrelation by using the Breusch-Godfrey test (command: estat bgodfrey), but whatever I try I keep getting the error 'sample may not include multiple panels'. The commands I use are:
    reg DV1 IV1 IV2 IV3 IV4 IV5
    estat bgodfrey
    (and then I receive the error 'sample may not include multiple panels')

    Does anyone know how I can avoid this error and perform a Breusch-Godfrey test?


  • #2
    Manuel:
    welcome to this forum.
    The community-contributed command to test for autocorrelation after -xtreg- is named -xtserial- (just type -search xtserial- to spot and install it);
    Kind regards,
    Carlo
    (Stata 19.0)

    Comment


    • #3
      Hi Carlo,

      Thank you for your reply.

      I have tried the xtserial command but receive the 'no observation r(2000)' error

      If I remember correctly I need to search for duplicates and tried the 'duplicates report' command:
      duplicates report DV1 IV1 IV2 IV3 IV4 IV5
      (received the following result):

      copies | observations surplus
      ----------+---------------------------
      1 | 3765 0
      2 | 2852 1426
      3 | 2820 1880
      4 | 3252 2439
      5 | 2320 1856
      6 | 2292 1910
      7 | 2044 1752
      8 | 1688 1477
      9 | 1503 1336
      10 | 1540 1386
      11 | 8767 7970
      12 | 25296 23188
      15 | 15 14
      24 | 24 23
      287 | 287 286
      --------------------------------------

      Do you know how I can fix this?

      Thank you in advance

      Kind regards,
      Manuel

      Comment


      • #4
        Manuel:
        try -duplicates drop- if yiou want to keep the first observation only for each group of duplicated observations.
        Kind regards,
        Carlo
        (Stata 19.0)

        Comment


        • #5
          I have tried the command -duplicates drop- and get:

          Duplicates in terms of all variables

          (0 observations are duplicates)

          I still cannot perform a xtserial test as it gives me the following error:

          no observations
          r(2000);

          What am I doing wrong?

          Comment


          • #6
            Manuel:
            could you please provide an example/excerpt of your data via -dataex-? Thanks.
            Kind regards,
            Carlo
            (Stata 19.0)

            Comment


            • #7
              Carlo:

              See -dataex- output below:

              * Example generated by -dataex-. To install: ssc install dataex
              clear
              input double ROAWinsor1 float(ESGP lnSize Beta) double(Debt RandD) float CompanyID int ExtractionDate
              .07738895750423128 28.34461 8.565343 .9 .000050889712272997575 0 1 21185
              .07738895750423128 28.34461 8.565343 .9 .000050889712272997575 0 1 21216
              .07738895750423128 28.34461 8.565343 .9 .000050889712272997575 0 1 21244
              .07738895750423128 28.34461 8.565343 .9 .000050889712272997575 0 1 21275
              .07738895750423128 28.34461 8.565343 .9 .000050889712272997575 0 1 21305
              .07738895750423128 28.34461 8.565343 .9 .000050889712272997575 0 1 21336
              .07738895750423128 28.34461 8.565343 .9 .000050889712272997575 0 1 21366
              .07738895750423128 28.34461 8.565343 .9 .000050889712272997575 0 1 21397
              .07738895750423128 28.34461 8.565343 .9 .000050889712272997575 0 1 21428
              .07738895750423128 28.34461 8.565343 .9 .000050889712272997575 0 1 21458
              .07738895750423128 28.34461 8.565343 .9 .000050889712272997575 0 1 21489
              .07738895750423128 . 8.565343 . .000050889712272997575 0 1 21519
              .05781851405707013 . 8.773685 . .007395297761788094 0 1 21550
              .05781851405707013 . 8.773685 . .007395297761788094 0 1 21581
              .05781851405707013 27.22727 8.773685 .9337838 .007395297761788094 0 1 21609
              .05781851405707013 27.22727 8.773685 .9337838 .007395297761788094 0 1 21640
              .05781851405707013 27.22727 8.773685 .9337838 .007395297761788094 0 1 21670
              .05781851405707013 27.22727 8.773685 .9337838 .007395297761788094 0 1 21701
              .05781851405707013 27.257267 8.773685 .9337838 .007395297761788094 0 1 21731
              .05781851405707013 27.257267 8.773685 .9337838 .007395297761788094 0 1 21762
              .05781851405707013 27.257267 8.773685 .9337838 .007395297761788094 0 1 21793
              .05781851405707013 27.257267 8.773685 .9337838 .007395297761788094 0 1 21823
              .05781851405707013 27.257267 8.773685 .9337838 .007395297761788094 0 1 21854
              .05781851405707013 25.625067 8.773685 .8702703 .007395297761788094 0 1 21884
              . 25.70614 . .8702703 . . 1 21915
              . 25.37494 . .8702703 . . 1 21946
              . 25.37494 . .8702703 . . 1 21975
              . 25.37494 . .8702703 . . 1 22006
              . 25.22494 . .8702703 . . 1 22036

              Comment


              • #8
                Manuel:
                type:
                Code:
                format %td ExtractionDate
                and then re-run the -xtset- and -xtserial- commands.
                Kind regards,
                Carlo
                (Stata 19.0)

                Comment


                • #9
                  Carlo:

                  I have used the 'format%td ExtractionDate' command, but unfortunately after re-running the -xtset- and -xtserial- commands it still does not work. Again STATA gives the output:

                  . format %td ExtractionDate

                  . xtset CompanyID ExtractionDate
                  panel variable: CompanyID (unbalanced)
                  time variable: ExtractionD~e, 01jan2014 to 01oct2020, but with gaps
                  delta: 1 day

                  . xtserial TobinsQWinsor1 ESGP Size Beta Debt RandD
                  no observations
                  r(2000);

                  Comment


                  • #10
                    Manuel:
                    have you double-checked that you have more than one -panelid-?
                    Kind regards,
                    Carlo
                    (Stata 19.0)

                    Comment


                    • #11
                      Carlo:

                      I believe I have multiple -panel_id-.

                      I generated a -CompanyID- as seen in my first post to group the data per company. This is because the analysis I want to conduct is on how -ESGP- (IV) affects -TobinsQ- (DV). I created the -panel_id- the following way:
                      sort EntityName ExtractionDate
                      egen CompanyID = group(EntityName)

                      I go more in depth in my first post to how I constructed the data.

                      Do I need to construct a -panel_id- another way?

                      Thank you in advance again for your help Carlo!

                      Comment


                      • #12
                        Manuel:
                        -xtserial- works by firts-differencing variables. Double-check that your dataset supports this approach.
                        As an example, there's no gain in differencing a constant.
                        Kind regards,
                        Carlo
                        (Stata 19.0)

                        Comment

                        Working...
                        X