Announcement

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

  • #16
    Excellent, thank you William. Your explanation was incredibly helpful! Much appreciation.

    Comment


    • #17
      Hi, I have a similar problem with a .do file I'm trying to execute:

      . egen raiprod_any=rowmax(raiabove_a raiabove_b raiabove_c raiabove_d)
      variable raiprod_any already defined
      r(110);

      I've done a search of the variable in the code and no instances appear before this egen command, how is that possible? Could it be because I've already executed a different .do file with the same variable? If that's so, how can I "erase" those actions so that the variable is generated again without problems?

      Thank you so much in advance

      Comment


      • #18
        The variable raiprod_any apparently appears in your dataset. Either it was there originally or because you created it when you ran previously ran your do-file, or it was created by running another do file.

        If you are certain you no longer want that variable, you can use the -drop- command:

        Code:
        drop raiprod_any
        Stata/MP 14.1 (64-bit x86-64)
        Revision 19 May 2016
        Win 8.1

        Comment


        • #19
          in general, when defining new variables in a do file, I prefer to use
          Code:
          cap drop newvarname
          (replacing my "newvarname" with whatever actual name you are using for the newer - if you don't include the "cap", the do file will exit with an error if the variable does not exist; note that in some cases, I check whether a variable exists and then examining it (use -pause-) before dropping it; see
          Code:
          help capture
          help pause

          Comment


          • #20
            Thank you so much Carole and Rich, that sorted the problem out.

            Comment


            • #21
              Hello stata listers,

              I have a panel data for 15 countries over 22 years, but I have some missing values for some variables. When trying to use a non-linear interpolation (like cubic), allowing for extrapolation, stata gives the error code "variable __000003 already defined". The code I use is the following:
              Code:
               bysort country: mipolate pre_top1 year, cubic generate (pretop1) epolate
              If I don't add the epolate option the code runs, but some missing values are at the ending of the period for each country and in that case I couldn't fill that parts.
              My point is that I would like to fill the missing values using the "smoothest" method as possible, allowing for extrapolation, as the command "mipolate" should allow for it also for some non-linear interpolation methods.

              Thank you.
              Francesco
              Last edited by Francesco Colcerasa; 10 Jul 2019, 03:23.

              Comment


              • #22
                #21 mipolate is from SSC, as you are asked to explain.

                There is no example data here, but I could reproduce your problem. You've found a bug in that command; thanks for the signal.

                The fixes needed are

                new first line

                Code:
                *! 1.2.1 NJC 10jul2019
                in the epolate block the tempvar command should be

                Code:
                tempvar m b M B ismiss negx negy
                I'll send an update to Kit Baum for SSC. You may be confident to make those edits by hand and discard to flush the program from memory.

                All that said, I recommend cubic splines for your problem, which automatically extrapolate.
                Last edited by Nick Cox; 10 Jul 2019, 05:09.

                Comment


                • #23
                  Sorry, but I am not sure I got what to do. What should I type in the command window? Is this possible to avoid the fixes and use directly cubic splines option within the mipolate command?

                  Comment


                  • #24
                    You downloaded the code as an .ado file and the fixes are edits to be made to that file.

                    But otherwise consider this example. (Correction: the spline implementation doesn't extrapolate automatically.)


                    Code:
                    . webuse grunfeld, clear
                    
                    . 
                    . replace invest = . if inlist(_n, 20, 42, 56) 
                    (3 real changes made, 3 to missing)
                    
                    . 
                    . by company: mipolate invest year, spline epolate gen(wanted) 
                    
                    . 
                    . l company year invest wanted in 1/60, sepby(company) 
                    
                         +-------------------------------------+
                         | company   year   invest      wanted |
                         |-------------------------------------|
                      1. |       1   1935    317.6   317.60001 |
                      2. |       1   1936    391.8   391.79999 |
                      3. |       1   1937    410.6   410.60001 |
                      4. |       1   1938    257.7   257.70001 |
                      5. |       1   1939    330.8   330.79999 |
                      6. |       1   1940    461.2   461.20001 |
                      7. |       1   1941      512         512 |
                      8. |       1   1942      448         448 |
                      9. |       1   1943    499.6   499.60001 |
                     10. |       1   1944    547.5       547.5 |
                     11. |       1   1945    561.2   561.20001 |
                     12. |       1   1946    688.1   688.09998 |
                     13. |       1   1947    568.9   568.90002 |
                     14. |       1   1948    529.2   529.20001 |
                     15. |       1   1949    555.1   555.09998 |
                     16. |       1   1950    642.9   642.90002 |
                     17. |       1   1951    755.9   755.90002 |
                     18. |       1   1952    891.2   891.20001 |
                     19. |       1   1953   1304.4      1304.4 |
                     20. |       1   1954        .      1717.6 |
                         |-------------------------------------|
                     21. |       2   1935    209.9   209.89999 |
                     22. |       2   1936    355.3   355.29999 |
                     23. |       2   1937    469.9   469.89999 |
                     24. |       2   1938    262.3   262.29999 |
                     25. |       2   1939    230.4   230.39999 |
                     26. |       2   1940    361.6   361.60001 |
                     27. |       2   1941    472.8   472.79999 |
                     28. |       2   1942    445.6   445.60001 |
                     29. |       2   1943    361.6   361.60001 |
                     30. |       2   1944    288.2   288.20001 |
                     31. |       2   1945    258.7   258.70001 |
                     32. |       2   1946    420.3   420.29999 |
                     33. |       2   1947    420.5       420.5 |
                     34. |       2   1948    494.5       494.5 |
                     35. |       2   1949    405.1   405.10001 |
                     36. |       2   1950    418.8   418.79999 |
                     37. |       2   1951    588.2   588.20001 |
                     38. |       2   1952    645.5       645.5 |
                     39. |       2   1953      641         641 |
                     40. |       2   1954    459.3   459.29999 |
                         |-------------------------------------|
                     41. |       3   1935     33.1   33.099998 |
                     42. |       3   1936        .   71.691271 |
                     43. |       3   1937     77.2   77.199997 |
                     44. |       3   1938     44.6   44.599998 |
                     45. |       3   1939     48.1   48.099998 |
                     46. |       3   1940     74.4   74.400002 |
                     47. |       3   1941      113         113 |
                     48. |       3   1942     91.9   91.900002 |
                     49. |       3   1943     61.3   61.299999 |
                     50. |       3   1944     56.8   56.799999 |
                     51. |       3   1945     93.6   93.599998 |
                     52. |       3   1946    159.9   159.89999 |
                     53. |       3   1947    147.2       147.2 |
                     54. |       3   1948    146.3       146.3 |
                     55. |       3   1949     98.3   98.300003 |
                     56. |       3   1950        .   100.38347 |
                     57. |       3   1951    135.2       135.2 |
                     58. |       3   1952    157.3       157.3 |
                     59. |       3   1953    179.5       179.5 |
                     60. |       3   1954    189.6   189.60001 |
                         +-------------------------------------+
                    
                    .

                    Comment


                    • #25
                      Perfect, thank you!

                      Comment


                      • #26
                        Hello everyone.
                        I am new comer on this forum and new statat user.
                        I need your help!
                        I want to run the first difference and system GMM, when I key in the command code like tsset code year or xtset code year to declare my data my set I get this error message variable code not found and other error messages as well.

                        Error messages from stata:
                        . tsset code year
                        variable code not found
                        r(111);

                        . xtset code year
                        variable code not found
                        r(111);

                        . gen lgCIR = ln(CIR)
                        (3 missing values generated)

                        . gen lnTA = ln(TA)

                        . . xtabond2 CIR l.CIR lnTA LDR Staffexp ROA LTAR CAR NPL LNF RGDP, gmm(l.CIR) iv(lnTA Staffexp RGDP) nolevel robust
                        time variable not set
                        r(111);

                        . xtabond2 CIR l.CIR lnTA LDR Staffexp ROA LTAR CAR NPL LNF RGDP, gmm(l.CIR) iv(lnTA Staffexp RGDP) nolevelrobust
                        time variable not set
                        r(111);

                        . xtabond2 CIR l.CIR lnTA LDR Staffexp ROA LTAR CAR NPL LNF RGDP, gmm(l.CIR) iv(lnTA Staffexp RGDP)
                        time variable not set
                        r(111);

                        . gen lgCIR = l.CIR
                        variable lgCIR already defined
                        r(110);

                        Comment


                        • #27
                          #26 What defines your panels? xtset and tsset both want to see a panel identifier. Nothing else that depends on those settings will work until you fix that. Nothing in your post that I can see tells us what defines your panels.

                          Comment


                          • #28
                            Dear Nick Cox, thanks for your prompt response!
                            I have defined my panel data as firm (banks) names, years, code, dv, and iv in excel file. I imported this excel file in statat to run my models.
                            I am not sure if this is the right way to defines panels.
                            Here is my varlist:
                            BankName Country Year Code CIR100 CIR TA Staffexp ROA LTAR LDR CAR NPL RGDP LNF lgCIR lnTA
                            Last edited by Ibrahima Traore; 12 Jul 2019, 10:10.

                            Comment


                            • #29
                              All I can tell you is that the attempt to use code as panel identifier failed because Stata is case-sensitive. You have no variable code. Note that using a name year would have failed too. Perhaps you need

                              Code:
                              xtset Code Year
                              If that isn't the answer you may need to tell us more about

                              Code:
                              BankName Country Year
                              Being new here is precisely why you need to study the FAQ Advice, as every new message prompt requests. In particular please see https://www.statalist.org/forums/help#stata

                              Comment


                              • #30
                                Thank you very much Nick Cox
                                I would rather study the FAQ Advice first.

                                Comment

                                Working...
                                X