Announcement

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

  • Error when use xtcsd (_variable merge already defined)

    Hi, I have a problem when I use xtcsd. After I run using xtreg depvar indepvar, fe , and then use "xtcsd, frees", there is an error saying "variable _merge already defined". I dont have variable named "_merge". How can I deal with this?

    Thanks in advanced

  • #2
    Your dataset apparently contains a _merge variable created by a previous command - merge, joinby, or perhaps some other command.

    Rename it, or drop it if you do not need it. The xtcsd command (a community contributed command available from SSC and the Stata Journal) should have been better about specifying a temporary variable name for the results of the merge that it apparently does.

    Comment


    • #3
      Originally posted by William Lisowski View Post
      Your dataset apparently contains a _merge variable created by a previous command - merge, joinby, or perhaps some other command.

      Rename it, or drop it if you do not need it. The xtcsd command (a community contributed command available from SSC and the Stata Journal) should have been better about specifying a temporary variable name for the results of the merge that it apparently does.
      Hi William, thank you for your response. I dont have any _merge variable, even if I try to drop by doing "drop _merge", the result says that "variable _merge cannot be found". What do you think about it?

      Comment


      • #4
        I installed version 1.1.1 of xtcsd from SSC. The example in help xtcsd uses an example dataset that is no longer online at the URL given. From the Stata Journal article I was able to locate the original source of the data and reconstruct the example dataset enough to run the following code.
        Code:
        use xtcsd_data, clear
        xtset
        xtreg lngsp lnpcap lnpc lnemp unemp, fe
        which xtcsd
        ds
        xtcsd, frees
        This gave the following results.
        Code:
        . which xtcsd
        /Users/lisowskiw/Library/Application Support/Stata/ado/plus/x/xtcsd.ado
        *! version 1.1.1        R.E. De Hoyos and V. Sarafidis 16may2006
        
        . ds
        state   yr      hwy     util    gsp     unemp   lngsp   lnpc
        st_abb  p_cap   water   pc      emp     sc      lnpcap  lnemp
        
        . xtcsd, frees
         
         
          Frees' test of cross sectional independence =     8.386
        |--------------------------------------------------------|
          Critical values from Frees' Q distribution
                              alpha = 0.10 :   0.1521
                              alpha = 0.05 :   0.1996
                              alpha = 0.01 :   0.2928
        
        .
        Note the ds command preceding the xtcsd command; it confirms there is no _merge variable. I suggest you add the same command to your code in the same location to absolutely confirm there is no _merge variable.

        With that said, the source xtcsd.ado does not seem to have a merge command, so I am suspicious that you might have not correctly interpreted the source of the problem.

        I will also say that xtcsd has been the subject of other problem reports on this forum, and in its archives, in the past. The code has not been updated in forever, so it doesn't appear to be actively maintained.

        I have attached the example dataset I used for any who are curious.

        xtcsd_data.dta

        Comment


        • #5
          Originally posted by William Lisowski View Post
          I installed version 1.1.1 of xtcsd from SSC. The example in help xtcsd uses an example dataset that is no longer online at the URL given. From the Stata Journal article I was able to locate the original source of the data and reconstruct the example dataset enough to run the following code.
          Code:
          use xtcsd_data, clear
          xtset
          xtreg lngsp lnpcap lnpc lnemp unemp, fe
          which xtcsd
          ds
          xtcsd, frees
          This gave the following results.
          Code:
          . which xtcsd
          /Users/lisowskiw/Library/Application Support/Stata/ado/plus/x/xtcsd.ado
          *! version 1.1.1 R.E. De Hoyos and V. Sarafidis 16may2006
          
          . ds
          state yr hwy util gsp unemp lngsp lnpc
          st_abb p_cap water pc emp sc lnpcap lnemp
          
          . xtcsd, frees
          
          
          Frees' test of cross sectional independence = 8.386
          |--------------------------------------------------------|
          Critical values from Frees' Q distribution
          alpha = 0.10 : 0.1521
          alpha = 0.05 : 0.1996
          alpha = 0.01 : 0.2928
          
          .
          Note the ds command preceding the xtcsd command; it confirms there is no _merge variable. I suggest you add the same command to your code in the same location to absolutely confirm there is no _merge variable.

          With that said, the source xtcsd.ado does not seem to have a merge command, so I am suspicious that you might have not correctly interpreted the source of the problem.

          I will also say that xtcsd has been the subject of other problem reports on this forum, and in its archives, in the past. The code has not been updated in forever, so it doesn't appear to be actively maintained.

          I have attached the example dataset I used for any who are curious.

          [ATTACH]n1627656[/ATTACH]
          Hi William, thanks for replying. I still have the issue. Here is the output.

          . xtset psid year

          Panel variable: psid (unbalanced)
          Time variable: year, 1 to 5, but with gaps
          Delta: 1 unit

          . qui xtreg lnWE HSpill_ind HSpill_provi HSpill_tech $X , fe

          . which xtcsd
          /Users/zeqiyasin/Library/Application Support/Stata/ado/plus/x/xtcsd.ado
          *! version 1.1.0 R.E. De Hoyos and V. Sarafidis 16may2006

          . ds
          psid FOR10 HSpill_provi importperc~t lnWE Dfsize2
          year HSpill_ind HSpill_tech HHI FshFOR10 Dfsize3

          . xtcsd , frees
          variable _merge already defined
          r(110);

          Comment


          • #6
            I note you are using version 1.1.0, not version 1.1.1 as I indicated. The fact that you are not using the latest version might be important.
            Code:
            . which xtcsd
            /Users/lisowskiw/Library/Application Support/Stata/ado/plus/x/xtcsd.ado
            *! version 1.1.0        R.E. De Hoyos and V. Sarafidis 16may2006
            
            . ado describe, find(xtcsd)
            
            ------------------------------------------------------------------------------------------------
            [21] package st0113 from http://www.stata-journal.com/software/sj6-4
            ------------------------------------------------------------------------------------------------
            
            TITLE
                  SJ6-4 st0113.  Test for cross-sectional dependence in...
            
            DESCRIPTION/AUTHOR(S)
                  Test for cross-sectional dependence in panel-data models
                  by Rafael E. De Hoyos, University of Cambridge
                     Vasilis Sarafidis, University of Sydney
                  Support:  [email protected], [email protected]
                  After installation, type help xtcsd
            
            INSTALLATION FILES
                  x/xtcsd.ado
                  x/xtcsd.hlp
            
            INSTALLED ON
                  15 Sep 2021
            ------------------------------------------------------------------------------------------------
            
            . ado uninstall st0113
            
            package st0113 from http://www.stata-journal.com/software/sj6-4
                  SJ6-4 st0113.  Test for cross-sectional dependence in...
            
            (package uninstalled)
            
            . ssc install xtcsd
            checking xtcsd consistency and verifying not already installed...
            installing into /Users/lisowskiw/Library/Application Support/Stata/ado/plus/...
            installation complete.
            
            . which xtcsd
            /Users/lisowskiw/Library/Application Support/Stata/ado/plus/x/xtcsd.ado
            *! version 1.1.1        R.E. De Hoyos and V. Sarafidis 16may2006
            
            .

            Comment


            • #7
              It now says: "too many value". My N is quite large actually. The total observation is 64195 with T=5.

              . do "/var/folders/4r/m10_2qcj3ml61whjc846thbc0000gn/T//SD00574.000000"

              . qui xtreg lnWE HSpill_ind HSpill_provi HSpill_tech $X , fe

              . which xtcsd
              /Users/zeqiyasin/Library/Application Support/Stata/ado/plus/x/xtcsd.ado
              *! version 1.1.1 R.E. De Hoyos and V. Sarafidis 16may2006

              . ds
              psid FOR10 HSpill_provi importperc~t lnWE Dfsize2
              year HSpill_ind HSpill_tech HHI FshFOR10 Dfsize3

              . xtcsd , frees
              too many values
              r(134);

              Comment


              • #8
                The xtcsd command source code has a section preceded by the comment
                Code:
                *Modifying the data set to get a column of residuals for each cross-section
                If you are using Stata/SE, the number of panels you have exceeds the maximum number of variables allowed.

                Comment


                • #9
                  Thank you so much for your help William.

                  Comment

                  Working...
                  X