Announcement

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

  • xtpmg works in Stata 13/14 but not in 15/16?

    Dear All, I use (ssc install) xtpmg to estimate the following model.
    Code:
    * Example generated by -dataex-. To install: ssc install dataex
    clear
    input str14 cn str3 code int year float(pi y c id)
    "Australia"   "AUS" 1960       . 9.126777 8.817785 1
    "Australia"   "AUS" 1961 .005512 9.117796 8.821845 1
    "Australia"   "AUS" 1962 .010618 9.165926 8.861888 1
    "Australia"   "AUS" 1963 .016399 9.242287 8.904936 1
    "Australia"   "AUS" 1964 .033551 9.285301 8.930625 1
    "Australia"   "AUS" 1965 .031854 9.275299 8.940616 1
    "Australia"   "AUS" 1966 .029922 9.324277 8.970143 1
    "Australia"   "AUS" 1967 .035304 9.335888  9.00631 1
    "Australia"   "AUS" 1968 .034349 9.406322 9.038895 1
    "Australia"   "AUS" 1969 .040493 9.444981 9.076191 1
    "Australia"   "AUS" 1970 .060083 9.461569 9.096202 1
    "Australia"   "AUS" 1971 .065964  9.48824 9.117048 1
    "Australia"   "AUS" 1972 .060993 9.540829 9.153357 1
    "Australia"   "AUS" 1973 .114068 9.597275 9.191398 1
    "Australia"   "AUS" 1974 .162968 9.595092 9.210077 1
    "Australia"   "AUS" 1975 .146564 9.597939 9.230286 1
    "Australia"   "AUS" 1976  .10849 9.610383 9.244958 1
    "Australia"   "AUS" 1977 .089166 9.586189 9.251227 1
    "Australia"   "AUS" 1978 .085865 9.618374 9.274227 1
    "Australia"   "AUS" 1979 .095046 9.635564 9.289895 1
    "Australia"   "AUS" 1980   .0932 9.660865 9.317696 1
    "Australia"   "AUS" 1981 .090036 9.668748 9.342647 1
    "Australia"   "AUS" 1982 .103054 9.618184 9.337695 1
    "Australia"   "AUS" 1983  .07155 9.667136 9.349161 1
    "Australia"   "AUS" 1984 .058712 9.697061 9.371945 1
    "Australia"   "AUS" 1985  .07722 9.704076 9.395497 1
    "Australia"   "AUS" 1986 .082827 9.698622  9.38767 1
    "Australia"   "AUS" 1987 .068714 9.742806 9.412477 1
    "Australia"   "AUS" 1988 .065982 9.789676 9.441179 1
    "Australia"   "AUS" 1989 .062069  9.78746 9.469853 1
    "Australia"   "AUS" 1990 .049224 9.745213 9.465416 1
    "Australia"   "AUS" 1991 .023524 9.734775 9.476471 1
    "Australia"   "AUS" 1992 .016738 9.750171 9.489652 1
    "Australia"   "AUS" 1993 .016277 9.779519 9.507699 1
    "Austria"     "AUT" 1960       . 11.23057 10.83956 2
    "Austria"     "AUT" 1961 .038935 11.28918 10.88387 2
    "Austria"     "AUT" 1962 .042951 11.30787 10.91059 2
    "Austria"     "AUT" 1963 .026052 11.33956 10.95798 2
    "Austria"     "AUT" 1964 .036576 11.39296 10.98502 2
    "Austria"     "AUT" 1965 .043585 11.42352 11.02673 2
    "Austria"     "AUT" 1966 .022746  11.4812 11.06216 2
    "Austria"     "AUT" 1967 .038128 11.49353 11.08902 2
    "Austria"     "AUT" 1968  .02443  11.5351 11.12317 2
    "Austria"     "AUT" 1969 .032794 11.59165 11.14846 2
    "Austria"     "AUT" 1970 .038183 11.66228 11.18577 2
    "Austria"     "AUT" 1971 .048633 11.71937 11.24638 2
    "Austria"     "AUT" 1972 .062847 11.78281 11.29955 2
    "Austria"     "AUT" 1973 .063725 11.83885 11.34633 2
    "Austria"     "AUT" 1974 .095457 11.87076  11.3741 2
    "Austria"     "AUT" 1975 .075892  11.8527 11.40869 2
    "Austria"     "AUT" 1976 .063366 11.89498 11.45485 2
    "Austria"     "AUT" 1977 .054728 11.93163 11.50765 2
    "Austria"     "AUT" 1978 .040782 11.94743 11.49356 2
    "Austria"     "AUT" 1979 .044355 11.99659 11.53841 2
    "Austria"     "AUT" 1980 .061759  12.0092 11.55339 2
    "Austria"     "AUT" 1981 .073392 11.98788 11.55459 2
    "Austria"     "AUT" 1982 .058669 11.99772 11.56568 2
    "Austria"     "AUT" 1983 .033303 12.02444 11.61679 2
    "Austria"     "AUT" 1984 .054477 12.03306  11.6159 2
    "Austria"     "AUT" 1985 .032592  12.0552  11.6388 2
    "Austria"     "AUT" 1986 .019039  12.0855 11.65526 2
    "Austria"     "AUT" 1987 .009723 12.11462 11.68486 2
    "Austria"     "AUT" 1988 .014354 12.15201 11.71764 2
    "Austria"     "AUT" 1989 .026292 12.18964   11.748 2
    "Austria"     "AUT" 1990 .030695 12.22534 11.77114 2
    "Austria"     "AUT" 1991 .033915 12.24126  11.7866 2
    "Austria"     "AUT" 1992 .038296 12.24679  11.7981 2
    "Austria"     "AUT" 1993 .034073 12.22574 11.78618 2
    "Belgium"     "BEL" 1960       . 12.25262 11.97938 3
    "Belgium"     "BEL" 1961 .026331 12.28599 11.99238 3
    "Belgium"     "BEL" 1962 .010655 12.33874 12.02688 3
    "Belgium"     "BEL" 1963 .036261 12.36487 12.06295 3
    "Belgium"     "BEL" 1964 .040851 12.42882  12.0793 3
    "Belgium"     "BEL" 1965 .045149 12.46139 12.11195 3
    "Belgium"     "BEL" 1966 .040604 12.48451  12.1314 3
    "Belgium"     "BEL" 1967 .025073 12.52161 12.15387 3
    "Belgium"     "BEL" 1968  .02847 12.55721 12.20188 3
    "Belgium"     "BEL" 1969 .028044 12.62701 12.25122 3
    "Belgium"     "BEL" 1970 .024651 12.70672 12.29345 3
    "Belgium"     "BEL" 1971 .051846 12.74088 12.33748 3
    "Belgium"     "BEL" 1972 .052345 12.79966 12.39164 3
    "Belgium"     "BEL" 1973 .059157 12.86504 12.46322 3
    "Belgium"     "BEL" 1974 .120161 12.89866 12.48594 3
    "Belgium"     "BEL" 1975 .115999 12.87614 12.48952 3
    "Belgium"     "BEL" 1976 .075352 12.93466 12.53503 3
    "Belgium"     "BEL" 1977 .069176  12.9326 12.55756 3
    "Belgium"     "BEL" 1978 .041536  12.9606 12.57946 3
    "Belgium"     "BEL" 1979 .038004 12.98042  12.6259 3
    "Belgium"     "BEL" 1980 .061659 12.99318 12.64449 3
    "Belgium"     "BEL" 1981 .083256 12.93911 12.63251 3
    "Belgium"     "BEL" 1982 .075041 12.94013 12.64548 3
    "Belgium"     "BEL" 1983 .068942 12.92719 12.62945 3
    "Belgium"     "BEL" 1984 .055551 12.94947 12.64147 3
    "Belgium"     "BEL" 1985 .057751 12.95861 12.66028 3
    "Belgium"     "BEL" 1986 .006867 13.00825 12.68271 3
    "Belgium"     "BEL" 1987 .018904  13.0316 12.71176 3
    "Belgium"     "BEL" 1988 .015478 13.07057  12.7342 3
    "Belgium"     "BEL" 1989 .035452 13.12134  12.7695 3
    "Belgium"     "BEL" 1990  .03588 13.13903 12.79296 3
    "Belgium"     "BEL" 1991 .024687 13.17091 12.82042 3
    "Belgium"     "BEL" 1992 .020526 13.19306 12.84251 3
    "Canada"      "CAN" 1960       . 8.899075 8.631179 4
    "Canada"      "CAN" 1961  .00529 8.913204 8.622852 4
    "Canada"      "CAN" 1962 .013456 8.971992 8.655091 4
    "Canada"      "CAN" 1963 .020884 9.000994 8.680049 4
    "Canada"      "CAN" 1964  .01532 9.058849 8.716622 4
    "Canada"      "CAN" 1965 .020621 9.115803 8.757779 4
    "Canada"      "CAN" 1966 .037562 9.172612 8.790492 4
    "Canada"      "CAN" 1967 .039474 9.187241  8.81161 4
    "Canada"      "CAN" 1968  .04357 9.220095 8.838357 4
    "Canada"      "CAN" 1969  .04006  9.26968 8.875424 4
    "Canada"      "CAN" 1970  .03471 9.280592 8.881181 4
    "Canada"      "CAN" 1971 .023561 9.332674 8.926323 4
    "Canada"      "CAN" 1972  .04111 9.403598 8.987632 4
    "Canada"      "CAN" 1973 .062225 9.492468 9.048448 4
    "Canada"      "CAN" 1974 .099482 9.558039 9.090315 4
    "Canada"      "CAN" 1975 .099736 9.555314 9.121487 4
    "Canada"      "CAN" 1976 .070503 9.614869 9.171438 4
    "Canada"      "CAN" 1977 .072335 9.614909 9.189951 4
    "Canada"      "CAN" 1978 .072841 9.634393 9.212977 4
    "Canada"      "CAN" 1979 .082693 9.676215 9.231655 4
    "Canada"      "CAN" 1980  .09573 9.680829 9.241051 4
    "Canada"      "CAN" 1981  .10594 9.693285 9.251542 4
    "Canada"      "CAN" 1982 .097657 9.628247 9.215019 4
    "Canada"      "CAN" 1983 .058135 9.642993  9.24092 4
    "Canada"      "CAN" 1984 .039114 9.692215 9.278929 4
    "Canada"      "CAN" 1985 .037062 9.719261  9.32174 4
    "Canada"      "CAN" 1986 .036995 9.723492 9.356698 4
    "Canada"      "CAN" 1987  .03861 9.764948  9.38862 4
    "Canada"      "CAN" 1988  .03793 9.821083 9.420688 4
    "Canada"      "CAN" 1989  .04719 9.827632 9.440114 4
    "Canada"      "CAN" 1990 .041061 9.785636 9.435515 4
    "Canada"      "CAN" 1991 .045899 9.729815 9.405815 4
    "Canada"      "CAN" 1992 .012979 9.679651 9.367965 4
    "Canada"      "CAN" 1993 .017363 9.681681 9.366916 4
    "Switzerland" "CHE" 1960       . 9.965399 9.591429 5
    "Switzerland" "CHE" 1961 .027754 10.04744 9.656388 5
    "Switzerland" "CHE" 1962 .047931 10.07565 9.692879 5
    "Switzerland" "CHE" 1963 .035305 10.11212 9.718802 5
    "Switzerland" "CHE" 1964 .041613 10.15347 9.748298 5
    "Switzerland" "CHE" 1965 .039101 10.17203 9.770731 5
    "Switzerland" "CHE" 1966 .045801 10.18876 9.789802 5
    "Switzerland" "CHE" 1967 .042941 10.20935 9.806178 5
    "Switzerland" "CHE" 1968 .025469 10.24062 9.831609 5
    "Switzerland" "CHE" 1969 .027288 10.28156 9.873432 5
    "Switzerland" "CHE" 1970 .038991 10.32932 9.904316 5
    "Switzerland" "CHE" 1971  .06716 10.37654  9.93925 5
    "Switzerland" "CHE" 1972 .073388 10.41439 9.983094 5
    "Switzerland" "CHE" 1973 .086496 10.43622  10.0041 5
    "Switzerland" "CHE" 1974 .095292 10.42758 9.996275 5
    "Switzerland" "CHE" 1975 .064161 10.36775 9.975313 5
    "Switzerland" "CHE" 1976 .022172 10.38155 9.997073 5
    "Switzerland" "CHE" 1977 .011412 10.39939 10.02961 5
    "Switzerland" "CHE" 1978 .006066 10.42801 10.04888 5
    "Switzerland" "CHE" 1979  .04291 10.43364  10.0587 5
    "Switzerland" "CHE" 1980 .044178 10.45403 10.07929 5
    "Switzerland" "CHE" 1981 .063516 10.47382 10.07745 5
    "Switzerland" "CHE" 1982 .054087 10.47155 10.07132 5
    "Switzerland" "CHE" 1983  .02582 10.48852 10.08568 5
    "Switzerland" "CHE" 1984 .032523 10.50972  10.0976 5
    "Switzerland" "CHE" 1985 .036411 10.53396 10.10766 5
    "Switzerland" "CHE" 1986 .002854 10.58168 10.12936 5
    "Switzerland" "CHE" 1987 .015313 10.60068 10.14294 5
    "Switzerland" "CHE" 1988 .022848 10.62891 10.15625 5
    "Switzerland" "CHE" 1989 .034838 10.67106 10.18205 5
    "Switzerland" "CHE" 1990 .052054 10.67919 10.18732 5
    "Switzerland" "CHE" 1991 .055286 10.66348 10.18889 5
    "Switzerland" "CHE" 1992 .040839 10.62828 10.17621 5
    "Switzerland" "CHE" 1993 .029346 10.60321 10.15904 5
    end
    
    xtset id year
    
    // PMG
    xtpmg D.c D.y D.pi, lr(L.c y pi) ec(ec) replace pmg 
    est store pmg
    
    // MG
    xtpmg D.c D.y D.pi, lr(L.c y pi) ec(ec) replace mg
    est store mg
    In both Stata 13/14, it works just fine.
    Code:
    . // PMG
    . xtpmg D.c D.y D.pi, lr(L.c y pi) ec(ec) replace pmg 
    
    Iteration 0:   log likelihood =  533.08568  
    Iteration 1:   log likelihood =  533.97325  
    Iteration 2:   log likelihood =  534.01755  
    Iteration 3:   log likelihood =  534.01765  
    Iteration 4:   log likelihood =  534.01765  
    
    Pooled Mean Group Regression
    (Estimate results saved as pmg)
    
    Panel Variable (i): id                          Number of obs      =       159
    Time Variable (t): year                         Number of groups   =         5
                                                    Obs per group: min =        31
                                                                   avg =      31.8
                                                                   max =        32
    
                                                    Log Likelihood     =  534.0176
    ------------------------------------------------------------------------------
             D.c |      Coef.   Std. Err.      z    P>|z|     [95% Conf. Interval]
    -------------+----------------------------------------------------------------
    ec           |
               y |   .9558091    .013805    69.24   0.000     .9287518    .9828664
              pi |  -.7580091   .1499926    -5.05   0.000    -1.051989   -.4640289
    -------------+----------------------------------------------------------------
    SR           |
              ec |   -.196124   .0649038    -3.02   0.003    -.3233331   -.0689148
                 |
               y |
             D1. |   .2564224   .0904152     2.84   0.005      .079212    .4336329
                 |
              pi |
             D1. |  -.0375937   .0591728    -0.64   0.525    -.1535703    .0783829
                 |
           _cons |   .0399847   .0124331     3.22   0.001     .0156163    .0643531
    ------------------------------------------------------------------------------
    
    . est store pmg
    
    . 
    . // MG
    . xtpmg D.c D.y D.pi, lr(L.c y pi) ec(ec) replace mg
    
    ------------------------------------------------------------------------------
    Mean Group Estimation: Error Correction Form
    (Estimate results saved as mg)
    ------------------------------------------------------------------------------
    ------------------------------------------------------------------------------
             D.c |      Coef.   Std. Err.      z    P>|z|     [95% Conf. Interval]
    -------------+----------------------------------------------------------------
    ec           |
               y |   .9098558   .0751301    12.11   0.000     .7626036    1.057108
              pi |  -.7133219   .1565366    -4.56   0.000    -1.020128   -.4065159
    -------------+----------------------------------------------------------------
    SR           |
              ec |  -.2394112   .0489541    -4.89   0.000    -.3353595    -.143463
                 |
               y |
             D1. |   .2037221   .0623671     3.27   0.001     .0814848    .3259595
                 |
              pi |
             D1. |  -.0211505   .0791552    -0.27   0.789    -.1762919    .1339909
                 |
           _cons |   .0711615   .0829173     0.86   0.391    -.0913534    .2336764
    ------------------------------------------------------------------------------
    
    . est store mg
    However, in both Stata 15/16, I encountered an error message as
    Code:
    . // PMG
    . xtpmg D.c D.y D.pi, lr(L.c y pi) ec(ec) replace pmg 
    
    Iteration 0:   log likelihood =  533.08568  
    Iteration 1:   log likelihood =  533.97325  
    Iteration 2:   log likelihood =  534.01755  
    Iteration 3:   log likelihood =  534.01765  
    Iteration 4:   log likelihood =  534.01765  
    
    Pooled Mean Group Regression
    (Estimate results saved as pmg)
    
    Panel Variable (i): id                          Number of obs      =       159
    Time Variable (t): year                         Number of groups   =         5
                                                    Obs per group: min =        31
                                                                   avg =      31.8
                                                                   max =        32
    
                                                    Log Likelihood     =  534.0176
    ------------------------------------------------------------------------------
             D.c |      Coef.   Std. Err.      z    P>|z|     [95% Conf. Interval]
    -------------+----------------------------------------------------------------
    ec           |
               y |   .9558091    .013805    69.24   0.000     .9287518    .9828664
              pi |  -.7580091   .1499926    -5.05   0.000    -1.051989   -.4640289
    -------------+----------------------------------------------------------------
    SR           |
              ec |   -.196124   .0649038    -3.02   0.003    -.3233331   -.0689148
                 |
               y |
             D1. |   .2564224   .0904152     2.84   0.005      .079212    .4336329
                 |
              pi |
             D1. |  -.0375937   .0591728    -0.64   0.525    -.1535703    .0783829
                 |
           _cons |   .0399847   .0124331     3.22   0.001     .0156163    .0643531
    ------------------------------------------------------------------------------
    
    . est store pmg
    
    . 
    . // MG
    . xtpmg D.c D.y D.pi, lr(L.c y pi) ec(ec) replace mg
    invalid new variable name;
    variable name ec is in the list of predictors
    r(110);
    
    end of do-file
    
    r(110);
    That is, the `mg' option (pmg option is OK) does not work. Any possibilities? Thanks. (In fact, I sent an email to the author of -xtpmg- but didn't get any response.
    Ho-Chuan (River) Huang
    Stata 17.0, MP(4)

  • #2
    I can confirm the problem in Stata 16 (16.0, latest update). Using Stata 15.0 it still works, but with 15.1 it does not work. In Stata 14.2 it is working. Thus there must have been a change from 15.0 to 15.1.

    Using trace, xtpmg stops working when predicting fitted values. The command line is:
    Code:
    _predict double ec if __000003, eq(ec)
    xtpmg does not come with it's own predict command, it uses Stata's _predict command. There was an update to predict on 20 February 2019, see help whatsnew15. The change reads:
    14. predict, when specified with a new variable name that matches a variable in the current estimation results, now exits with an error message even when that variable does not exist in the current dataset. The old behavior, which provided invalid predicted values, is not preserved under version control.
    Is my reading that correct, that predicted values were invalid?

    I had a further look at the code of xtpmg and it looks like the predicted values are not required. When removing the lines, xtpmg works and I obtain the same results. I attached the ado file and called the program xtpmg2. Please check.

    Jan
    Attached Files
    Last edited by JanDitzen; 12 Feb 2020, 04:14. Reason: corrected code environment

    Comment


    • #3
      Dear Jan, Thanks a lot. I will give it a try. (PS. I also use your -xtdcce2- command.)
      Ho-Chuan (River) Huang
      Stata 17.0, MP(4)

      Comment


      • #4
        Dear Jan,
        Thank you for your answer. I have the same problem than River Huang when I use the command 'xtpmg'. I did use your xtpmg2.ado command but this seems to only work for MG ARDL (1,1,1)...
        Indeed, when I try to estimate it for MG ARDL (2,2,2) using this command:
        xtpmg d(1/2).EF d(1/2).Y d(1/2).Ysq, lr(l.EF Y Ysq) ec(ECT) replace mg
        I get the error message: expression (-_b[Y]/_b[L.EF]) evaluates to missing
        Could you please indicate me how to use the xtpmg command for an MG ARDL (2,2,2)?
        Thank you very much for your help,
        Kind regards

        Comment


        • #5
          Dear Vali,
          I am not the author if xtpmg, thus I cannot comment on error messages.

          You are correct, xtpmg can only estimate an ARDL(1,1). The reason is that it cannot calculate the long run coefficients of multiple lags of the dependent and independent variables in the error correction term. To achieve this, you need to reformulate the equation such that the error correction term only consists of one variable. Usually this is done by using the difference operator, where the difference depends on your ARDL.
          If you are only using an MG ARDL and you are not pooling, then I would strongly suggest to use xtdcce2 without the cross-sectional averages.

          Hope this helps.
          Jan

          Comment


          • #6
            Hi Jan,

            Please, could you advise how to circumvent below issue (using Stata 16.1)
            xtpmg d2.lnun d.lnp d.lngd d.lnprim, lr(l.lnun lnp lngd lnprim)
            > ec(ec) replace mg
            invalid new variable name;
            variable name ec is in the list of predictors
            r(110);

            .

            Comment


            • #7
              Hi Kidaya,

              If you implement the solution described by Jan in post #2, then you should be fine. You have the exact same problem as the one River mentioned in the original post of this thread.

              Comment


              • #8
                I got that. I just want to find away to conduct an Haussman test (PMG vs. MG).

                Comment


                • #9
                  If you check the paper by Blackburne and Frank in the Stata Journal (2007 I think) where they introduced the xtpmg command you will it quite straightforward to run the Hausman

                  Comment


                  • #10
                    I know how to perform it. The problem arises with Stata 16 not performing mg) . I need to perform both Pmg and Mg in order to perform the test (hausman mg pmg, sigmamore).

                    Comment


                    • #11
                      This problem has been answered in #2 (above) by JanDitzen.
                      Ho-Chuan (River) Huang
                      Stata 17.0, MP(4)

                      Comment


                      • #12
                        Dear Huang, Could you explain this?

                        xtset2 not installed.
                        To update, from within Stata type {net
                        describe not found
                        r(111);

                        checking xtset2 consistency and verifying not already installed...


                        checking xtdcce2 consistency and verifying not already installed...
                        all files already exist and are up to date.



                        Comment


                        • #13
                          Hi Kidaya Ntoko ,
                          I believe I am the person to answer this question. You want to run xtdcce2 and you are missing an important ado file which comes with it. In general I advise to remove all version of xtdcce2 before installing a new version. You can do this by either
                          Code:
                          ssc uninstall xtdcce2
                          or [net uninstall xtdcce2[/CODE]. Then you can install the latest version oft xtdcce2 from either SSC (via
                          Code:
                          ssc install xtdcce2
                          or you can install it from my github including beta version:
                          Code:
                          net from https://janditzen.github.io/xtdcce2/
                          Hopefully this helps.

                          Best,
                          Jan

                          Comment


                          • #14
                            Thanks.

                            Comment


                            • #15
                              Jan, my next question is how to perform the Hausman test then (Pmg mg DFE )?

                              Comment

                              Working...
                              X