Announcement

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

  • Estadd does not reproduce scalar saved post resetxt

    Hello Statalists,

    I am running some random effects regressions on panel data and would like to test which specification is correct using the Ramsey test. I am using the user-created command resetxt downloaded from SSC.
    Afterwards, I would like to organise my results in a table format to compare them using the user-created estadd.

    However, estadd does not reproduce the statistics in the table. Would anyone be able to help with this? Please see my data and code below.

    Code:
    * Example generated by -dataex-. To install: ssc install dataex
    clear
    input float(id year cost input input_squared)
    10 2017 12.439766  7.387097  54.56921
    10 2018 13.060278  7.338101  53.84773
    10 2019 12.811565  7.595946  57.69839
    11 2017   11.9424  6.868429  47.17531
    11 2018 12.617618   6.82206   46.5405
    11 2019 12.263633  6.853036  46.96411
    12 2017  9.337701  2.475606  6.128623
    12 2018  9.926363  2.429237  5.901192
    12 2019  9.417656 2.4602134   6.05265
    13 2017  8.440928  .9367855   .877567
    13 2018 10.189826  .8904165  .7928416
    13 2019  9.953368   .921393  .8489651
    14 2017  9.615168  2.876588   8.27476
    14 2018 10.391204 2.8302195  8.010142
    14 2019 11.316359  2.861196  8.186442
    15 2017  12.19255 4.3916397   19.2865
    15 2018  12.25161  4.345271  18.88138
    15 2019 12.307883 4.3762474  19.15154
    16 2017  9.043903 2.8293495 8.0052185
    16 2018  9.867072  2.782981  7.744981
    16 2019   9.33295  2.813957  7.918355
    17 2017   8.55707  2.485013  6.175291
    17 2018  9.464444 2.4386444  5.946987
    17 2019  8.755593  2.469621  6.099028
    18 2017  14.39939  8.888922  79.01293
    18 2018 14.115676    8.8381  78.11202
    18 2019 14.000032  8.839617  78.13882
    19 2017  10.84751  5.631671  31.71572
    19 2018 11.298195  5.585302   31.1956
    19 2019 10.978483  5.616279 31.542585
    20 2017 14.017168  8.601939 73.993355
    20 2018 13.791075  8.450449  71.41009
    20 2019 13.897657  8.447175  71.35477
    end

    Code:
    global reg1 cost input
    global reg2 cost input input_squred
    
        forvalues i = 1(1)2{
        xtset name year
        
        *Run Pooled random effect regressions with clustered standard errors at id level and store results.
        eststo re`i': qui xtreg ${reg`i'} , re vce(cluster id)
        sort id year
            
        *RESET test
        resetxt ${reg`i'} , model(xtre) id(id) it(year)
        estadd scalar RESET_Ramsay_stata = e(resetf3p): re`i'
        estadd scalar RESETL_DG_stata = e(resetl3p): re`i'
        xtset id year
        
        }    
    
    estout re1 re2 , ///
            cells(b(star fmt(3)) se(par fmt(3)))      ///
            stats(RESET_Ramsey_stata RESETL_DG_stata ///
            ,fmt(3)) starlevels(* 0.10 ** 0.05 *** 0.01)
    Here is the estadd output, which does not reproduce the test statistic:

    Code:
                                   re1             re2  
                                 b/se            b/se  
    ----------------------------------------------------
    input                     0.470***        0.263***
                                (0.018)         (0.073)  
    input_squared                               0.037***
                                              (0.007)  
    constant                    6.587***        3.502***
                              (0.116)         (0.190)  
    ----------------------------------------------------
    RESET_Ramsey_stata                                  
    RESETL_DG_stata                 .               .

    Last edited by Stella Bagasheva; 25 Nov 2021, 10:38.

  • #2
    See https://www.statalist.org/forums/for...alar-pseudo-r2

    Comment


    • #3
      Thanks Andrew. I tried saving the scalars using estout as per your suggestion and then using estadd but unfortunately it did not work - there is still a . where the number should be. Do you have any other suggestions? Might it not work because I am running a loop and the scalar is not saved properly?

      Comment


      • #4
        Try

        Code:
        *RESET test
            resetxt ${reg`i'} , model(xtre) id(id) it(year)
            estadd scalar RESET_Ramsay_stata = `=e(resetf3p)': re`i'
            estadd scalar RESETL_DG_stata = `=e(resetl3p)': re`i'
            xtset id year

        Comment


        • #5
          YES, IT WORKS!

          Thanks so much, Andrew

          Comment

          Working...
          X