Announcement

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

  • Adding postestimation and p-values as scalars with esttab

    Hello everyone,
    I am performing an endogeneity procedure with ivregress 2sls and I am having some problem with postestimation commands.
    I'll put the output in order to (try to) be more clear.

    Essentially I have my ivregress command
    Code:
    quietly ivregress 2sls DepV ( Instrumented = IVs) DepVars , vce(robust)
    quietly eststo MODEL
    and then I perform Wooldridge's robust score test and dd it in memory with its relative p-value
    Code:
    estat endog
    quietly estadd scalar Wooldridge=r(r_score)
    quietly estadd scalar p_Wooldridge=r(p_r_score)
    Then, I do the same thing with Sargan Score
    Code:
    estat overid
    quietly estadd scalar Sargan=r(score)
    quietly estadd scalar p_Sargan=r(p_score)
    Once arrived at this point I have two issues.
    1) I want to add to my scalars Shea's partial R-square. Normally, as suggested by Stata guide (here), I would proceed like this
    Code:
    estat firststage
    quietly estadd scalar Shea=r(multiresults)
    However, what I have is the following:
    Code:
    estat firststage
    
      First-stage regression summary statistics
      --------------------------------------------------------------------------
                   |            Adjusted      Partial       Robust
          Variable |   R-sq.       R-sq.        R-sq.     F(2,5190)   Prob > F
      -------------+------------------------------------------------------------
         RepRisk1Y |  0.6165      0.6144       0.2747       992.334    0.0000
      --------------------------------------------------------------------------
    
    
    . estadd scalar Shea=r(multiresults)
    
    added scalar:
                   e(Shea) =  .
    2) I want to see the final output of my model and, in the scalars section at the end of the table, I'd like to see the p-value not as a separate cell but as significance stars of their relative values.
    In few words, rather than having this

    Code:
    esttab MODEL,  label star(† 0.1 * 0.05 ** 0.001 *** 0.0001) b(%9.4f) mtitles scalars(Wooldridge p_Wooldridge Sargan p_Sargan Shea)
    
    Beta estimations are omitted 
    Constant                   6.2030***
                              (15.37)   
    ------------------------------------
    Observations                 5220   
    Wooldridge                 1.6750   
    p_Wooldridge               0.1956   
    Sargan                     2.2504   
    p_Sargan                   0.1336
    Shea                            .     
    ------------------------------------
    t statistics in parentheses
    † p<0.1, * p<0.05, ** p<0.001, *** p<0.0001
    I'd like to have something like this

    Code:
     Beta estimations are omitted 
    Constant                   6.2030***
                              (15.37)   
    ------------------------------------
    Observations                 5220   
    Wooldridge                 1.6750 p_Wooldridge
    Sargan                     2.2504 p_Sargan
    Shea                       0.2747
    ------------------------------------
    t statistics in parentheses
    † p<0.1, * p<0.05, ** p<0.001, *** p<0.0001
    In this case, both p-values are above the conventional levels, hence close to the Wooldridge and Sargan values space would be blank.
    But, in the case that (for example) I'd have Wooldridge statistically significant at 5% and Sargan statistically significant at 1% I'd like to have something like this

    Code:
     Beta estimations are omitted 
    Constant                   6.2030***
                              (15.37)   
    ------------------------------------
    Observations                 5220   
    Wooldridge                 1.6750*
    Sargan                     2.2504**
    Shea                       0.2747
    ------------------------------------
    t statistics in parentheses
    † p<0.1, * p<0.05, ** p<0.001, *** p<0.0001

  • #2
    Regarding the first question:

    Running return list after estat firststage would show you that only r(singleresults) is created, and not r(multiresults). Why? help ivregress postestimation informs you that "estat firststage reports various statistics that measure the relevance of the excluded exogenous variables. By default, whether the equation has one or more than one endogenous regressor determines what statistics are reported." There is an option, all, which "requests that all first-stage goodness-of-fit statistics be reported regardless of whether the model contains one or more endogenous regressors. By default, if the model contains one endogenous regressor, then the first-stage R-squared, adjusted R-squared, partial R-squared, and F statistics are reported, whereas if the model contains multiple endogenous regressors, then Shea's partial R-squared and adjusted partial R-squared are reported instead."

    r(multiresults) are Shea's partial R-squared statistics, so run estat firststage, all.

    Additionally, note that r(multiresults) is a matrix, so you will have to estadd matrix rather than estadd scalar.

    Comment


    • #3
      Thank you Nils Enevoldsen for your kind answer.
      I knew that adding the scalar was an incorrect procedure since that, as you said, results are stored in a matrix. However, I do not know how to add the matrix to my esttab outcome.
      In essence, after that I stored my model and stored my matrix as you suggested:

      Code:
      quietly ivregress 2sls DepV ( Instrumented = IVs) DepVars , vce(robust)
      quietly eststo Model
      estat firststage, all
      quietly estadd matrix Shea=r(multiresults)


      How do I add it in my final output?


      Code:
      esttab Model, label star(† 0.1 * 0.05 ** 0.001 *** 0.0001) b(%9.4f) mtitles scalars(Wooldridge p_Wooldridge Sargan p_Sargan )
      Thanks for your time,
      Luigi

      Comment


      • #4
        Hi Luigi,

        I am having the same problem as your previous post. Can you introduce me to some sources to understand the command with the scalar option? I have no idea about how to choose the options such as: r(r_score) or r(p_r_score).
        Thanks for your help.

        I am looking forward to hearing from you soon.
        Anh Le

        Comment

        Working...
        X