Announcement

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

  • XTunitroot error r(111) variable ccode not found

    I am using the command XTunitroot to test for stationarity with a cross country-year dataset, using Stata 15.1.

    My data looks like this (where "..." indicates more of the same):

    country year wheat_yld rice_yld maize_yld ....
    Angola 1980 21,241
    Angola 1981 23,701
    Angola 1982 24,868
    Angola .... ....
    ​​​​​​​Angola 2010 23,939
    Ethiopia 1980 25,429
    Ethiopia 1981 21,682
    Ethiopia 1982 24,752
    Ethiopia .... ....
    Ethiopia 2010 31,409
    ....

    The variables ending with _yld are yields. These yields are defined as the number of hectograms/hectare of the given crop produced in the country in the given year.

    Where X is one of my agricultural yield variables, eg. wheat_yld, I seek to run the following commands:

    Code:
    ​​​​​​​xtunitroot ips X, demean
    xtunitroot ips X, demean trend
     
    xtunitroot fisher X, dfuller lags(1) demean
    xtunitroot fisher X, dfuller lags(1) demean trend
     
    xtunitroot fisher X, pperron lags(1) demean
    xtunitroot fisher X, pperron lags(1) demean trend
    In response to any of these commands, Stata responds:

    Code:
    variable ccode not found
    r(111);
    But my data has no variable called ccode, I didn't generate any variable called ccode in my syntax, and the command lines I am trying to run don't include a ccode variable, so I am not sure why Stata is looking for a variable called ccode?

    I include a more complete example set of my data below using dataex if helpful. Thanks kindly for any help!

    Code:
    * Example generated by -dataex-. To install: ssc install dataex
    clear
    input long country_codes int year long(wheat_yld maize_yld)
     3 1995  8924 16115
     3 1996 13090 17154
     3 1997  8016 21417
     3 1998  8847 17222
     3 1999 10711 22375
     3 2000  9194 36186
     3 2001 11104 27175
     3 2002 10739 33480
     3 2003 14480 28853
     3 2004 13582 31729
     3 2005 15057 33864
     3 2006 15068 65668
     3 2007 12742 85625
     3 2008 11038 44714
     3 2009 15975 30914
     3 2010 14838 25827
     7 1980 15596 25703
     7 1981 14014 38008
     7 1982 20501 30284
     7 1983 18405 30303
     7 1984 23068 31407
     7 1985 16177 35629
     7 1986 17819 37450
     7 1987 18847 31897
     7 1988 18344 37744
     7 1989 18947 29103
     7 1990 18947 34608
     7 1991 18972 40444
     7 1992 21809 45237
     7 1993 23272 43552
     7 1994 20237 42371
     7 1995 21675 45223
     7 1996 19344 40397
     7 1997 22426 45557
     7 1998 26088 60780
     7 1999 23028 53702
     7 2000 24873 54329
     7 2001 24934 54553
     7 2002 22398 60791
     7 2003 20361 64767
     7 2004 25441 63931
     7 2005 26356 73587
     7 2006 25302 59030
     7 2007 26234 76655
     7 2008 28271 64525
     7 2009 19628 55760
     9 1990 16344 41821
     9 1991 14698 39938
     9 1992 17812 51721
     9 1993 19658 44261
     9 1994 11356 46620
     9 1995 17899 48263
     9 1996 21673 57689
     9 1997 18412 59403
     9 1998 19153 47544
     9 1999 20066 51212
     9 2000 18209 49360
     9 2001 18209 46471
     9 2002 21076 54929
     9 2003  9070 62570
     9 2004 19998 56326
     9 2005 16348 57983
     9 2006 20213 53856
     9 2007  9173 49103
     9 2008 10788 56912
     9 2009 15831 58171
     9 2010 15729 55593
    14 1980 18990  7146
    14 1981 18479  7300
    14 1982 18114  7387
    14 1983 21090  7829
    14 1984 23021  8179
    14 1985 21647  8669
    14 1986 19282  9246
    14 1987 18657  9458
    14 1988 17542  9118
    14 1989 18246  9417
    14 1990 15034 10015
    14 1991 16767  9781
    14 1992 18534  9319
    14 1993 18457  9351
    14 1994 18390  9042
    14 1995 19483 10700
    14 1996 19531 10166
    14 1997 20544 10914
    14 1998 22408  7339
    14 1999 21627 12346
    14 2000 22104 20597
    14 2001 21643 32216
    14 2002 21644 40349
    14 2003 21327 40334
    14 2004 19527 48243
    14 2005 17478 53311
    14 2006 15344 52998
    14 2007 18471 59812
    14 2008 21753 60172
    14 2009 21516 56831
    14 2010 23959 58378
    21 1980  5992 13063
    21 1981  6943 16087
    end
    label values country_codes country_codes
    label def country_codes 3 "Algeria", modify
    label def country_codes 7 "Argentina", modify
    label def country_codes 9 "Australia", modify
    label def country_codes 14 "Bangladesh", modify
    label def country_codes 21 "Bolivia (Plurinational State of)", modify

  • #2
    So after using the dataex code I generated through statalist for this question I posted, to try my commands on the truncated dataset it generates, I encountered a new error requiring me to use xtset before running the command, which I did:

    Code:
    xtset country_codes year
    Now, after I run the following xtunitroot command
    Code:
    xtunitroot ips wheat_yld, demean
    Stata gives me this error:
    Code:
    Im-Pesaran-Shin test cannot have gaps in data 
    r(498);
    However my data does not have gaps as far as I can see. There are full observations for each variable that are non-missing and non-zero.

    Code:
    . su country_codes year wheat_yld
    
        Variable |        Obs        Mean    Std. Dev.       Min        Max
    -------------+---------------------------------------------------------
    country_co~s |        820    98.70976    59.42785          3        199
            year |        820    1997.361    8.171031       1980       2010
       wheat_yld |        820    23720.46    12064.88       4561      69777
    Any advice on the error Stata is encountering now?

    Thank you again.

    Comment


    • #3
      I have been able to find the answer to the posts I gave above.

      Given I do not have an observation for every time period in every country, there are gaps in the data. I can still execute the xtunitroot fisher commands however.

      And again, resetting xtset with the country and year variables prior to running the xtunitroot commands resolved the error r(111) that came up initially.

      Kind regards, Jenny

      Comment


      • #4
        I am cross posting this site that helped answer my second question: https://www.statalist.org/forums/for...ps-error-r-498

        Comment

        Working...
        X