Announcement

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

  • New on SSC: xtgrangert

    Thanks to Kit Baum a new package is available on SSC: xtgrangert

    xtgrangert
    implements the panel Granger non-causality test approach developed by Juodis, Karavias and Sarafidis (2021, EmpEcon). This test offers superior size and power performance to existing tests, which stems from the use of a pooled estimator that has a faster √NT convergence rate. The test has two other useful properties; it can be used in multivariate systems and it has power against both homogeneous as well as heterogeneous alternatives. A working paper describing (an earlier version of) xtgrangert is available here.

    xtgrangert can be applied to balanced and unbalanced datasets.

    Examples with lag length selection based on BIC and cross-sectional heteroskedasticity-robust standard errors:

    Code:
    . use xtgrangert_example
    . xtset cert time
    
    Panel variable: cert (strongly balanced)
     Time variable: time, 1 to 56
             Delta: 1 unit
    
    . xtgrangert roa inefficiency quality, maxlags(4) het
    
    Juodis, Karavias and Sarafidis (2021) Granger non-causality Test
    ------------------------------------------------------------------------------
    Number of units= 450                        Obs. per unit (T) = 55
    Number of lags = 1                          BIC               = -34257.34
    ------------------------------------------------------------------------------
    JKS non-causality test
    
    H0: Selected covariates do not Granger-cause roa.
    H1: H0 is violated.
    
    HPJ Wald test  : 30.2387
    p-value        : 0.0000
    ------------------------------------------------------------------------------
    BIC selection:
        lags = 1, BIC = -34257.336*
        lags = 2, BIC = -33371.195
        lags = 3, BIC = -32727.595
        lags = 4, BIC = -32715.923
    ------------------------------------------------------------------------------
                   Results for the Half-Panel Jackknife estimator
           Cross-sectional heteroskedasticity-robust variance estimation
    ------------------------------------------------------------------------------
                 | Coefficient  Std. err.      z    P>|z|     [95% conf. interval]
    -------------+----------------------------------------------------------------
    inefficiency |
             L1. |   .2562039   .0572807     4.47   0.000     .1439358     .368472
                 |
         quality |
             L1. |  -.0162294   .0444754    -0.36   0.715    -.1033996    .0709409
    ------------------------------------------------------------------------------
    For more examples and info please see the WP or the helpfile.

    xtgrangert was previously called xtgranger, but the name was "too nice".

    Questions or comments are very welcome.

  • #2
    Hello,
    in stata 16 I tested:
    xtgrangert y x, maxlags(4)
    I got the error message:
    estimates post: matrix has missing values
    r(504);

    What should I check? Thank you!

    Comment


    • #3

      The message implies that it is not possible to either estimate the coefficients or the variance covariance matrix. Do you have any missing values in your data?
      Further what are the dimensions of your dataset?

      Comment


      • #4
        thank you Jan for the quick reaction!
        x and y have no missing values.
        1,746,250 obs
        69850 IDs
        25 years

        Comment


        • #5
          Can you estimate the model with xtmg or xtdcce2?

          Comment


          • #6
            No!

            xtmg y x
            matsize must be at least as large as the number of panels in the current estimation sample (69850). r(908);

            xtdcce2 y x , cr( z )
            Large number of observations, xtdcce2 might be very slow and problems occur if maximum of matrix size is reached.
            Consider the use of xtdcce2fast instead of xtdcce2.
            unable to allocate matrix;
            You have attempted to create a matrix with too many rows or columns or attempted to fit a model with too many variables.
            You are using Stata/MP which supports matrices with up to 65534 rows or columns. This is the maximum matrix size.
            If you are using factor variables and included an interaction that has lots of missing cells, try set emptycells drop to reduce the required matrix size; see help set emptycells.
            If you are using factor variables, you might have accidentally treated a continuous variable as a categorical, resulting in lots of categories. Use the c. operator on such variables.
            r(915);


            I tried xtgrangert on a much smaller subset of N (=100) and T (=8) but I got the same error:
            xtgrangert y x, maxlags(4)
            estimates post: matrix has missing values r(504).

            However, the full model using a different "y" gives no error.
            xtgrangert y1 x, maxlags(4)

            Are there requirements in the "y" for the model to avoid producing the reported error?
            Thank you!

            Comment


            • #7
              Yes, that is what I was expecting. Your dataset has too many cross-sectional units. Therefore Stata cannot post the results into the results matrix.

              What is the difference between y and y1?

              Comment


              • #8
                Actually y1 does not change as y.
                My IDs are region(r) X technology(j)
                Time is year(t)
                y and x are both "rjt"
                y1 is only "rt" so I was comparing it to y improperly, with respect to your comment.

                Why are there no results even when I select only a subsample like this?

                Number of units= 747 Obs. per unit (T) = 7
                Number of lags = 1 BIC = .

                thanks again!

                Comment


                • #9
                  I am unsure if I understand the first part of your answer. What do you mean with rjt?Is y1 only changing over time?

                  T=7 might be too small to calculate the model with different lag lengths. This might be the reason why it cannot calculate the lag length using BIC.

                  Feel free to send me an email with your data - then I will have a look as well.

                  Comment


                  • #10
                    Thank you very much, Jan.
                    I leave the outcome of our exchange here in case others find it useful.
                    As you suggested, the variables y and x have too many zeroes and thus insufficient variation.

                    Comment


                    • #11
                      Hello,
                      the information on the xtgrangert command have been very helpful.

                      I get results when I execute
                      xtgrangert cchange conf, lags(2)

                      However I keep receiving error message [estimates post: matrix has missing values
                      r(504);] when I perform
                      xtgrangert conf cchange, lags(2) and haven't been able to work around it.

                      My conf variable is a dummy, while cchange is a continuous variable.

                      How can I possibly resolve my issue?
                      Or is it the case that the xtgrangert command cannot be used when some variables are dummies?

                      Thank you

                      Comment


                      • #12
                        Is it possible that the dummy variable is constant for specific periods? How do the coefficients saved in e(b) and e(b_HPJ) look like?

                        Comment


                        • #13
                          Thank you for your quick response.
                          This is the output when I use the 'xtgrangert cchange conf, lags(2)' command

                          HPJ Wald test : 0.2937
                          p-value : 0.8634
                          ------------------------------------------------------------------------------
                          Results for the Half-Panel Jackknife estimator
                          ------------------------------------------------------------------------------
                          | Coefficient Std. err. z P>|z| [95% conf. interval]
                          -------------+----------------------------------------------------------------
                          conf |
                          L1. | .0212841 .0536463 0.40 0.692 -.0838606 .1264289
                          L2. | .0073776 .0540007 0.14 0.891 -.0984618 .1132171
                          ------------------------------------------------------------------------------



                          The results for 'xtgrangert conf rec, lags(2)' however is shown below
                          HPJ Wald test :
                          p-value :
                          ----------------------------------------------------------------------
                          > --------
                          Results for the Half-Panel Jackknife estimator
                          estimates post: matrix has missing values


                          The dummy variable represents conflict occurrence in a country during a given period (in years). It may last for several years in a certain country.
                          However, it may only be a coincidence that for the dummy to be constant during some periods across the different cross sections, even though I agree that could be a possibility.

                          Comment


                          • #14
                            I think using a dummy variable in this setting is very difficult. You would need variation within each of the half panels, that means some outcomes of the variable need to be zero and one in the first and second half of the panel. Otherwise there is no variation to estimate the HPJ estimator.

                            Comment


                            • #15
                              Well understood.
                              Thank you so much for this insightful education.

                              Comment

                              Working...
                              X