Announcement

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

  • Use estout to export a table with personalized p-values

    Hi!

    I want to export a table from stata using the estout command, and I want to put in the table personalized p-values.
    I have this p-values in a matrix.

    I have the following code:

    Code:
    reg vardep varind
    estimates store m1
    
    mat pval= (0.0001, 0.10, 0.045)
    estadd matrix pval= pval
    
    estout m1, cells(b(star pvalue(pval) fmt(%9.3f)) p(par fmt(%9.3f))) replace label
    The problem is that the table that I export have the original p-values, not the ones that are in the pval matrix.

    How can I solve this?


    Last edited by Benjamin Alvarez; 12 Apr 2022, 14:22.

  • #2
    estout is from SSC (FAQ Advice #12). Well, you name your matrix holding the p-values as "pval", so you want:

    Code:
    estout m1, cells(b(star pvalue(pval) fmt(%9.3f)) pval(par fmt(%9.3f))) replace label

    Comment


    • #3
      Hi Andrew!

      Thanks again for the answer! I am using that exact same code but the table that I get when I run the code does not have de p-values (neither the originals or the personalized).

      I thought that the matrix might not have been saved, but I have checked everything and I do not understand why they do not appear.

      Do you know what the problem can be?

      Comment


      • #4
        You are showing pseudo code in #1. Show your exact commands and Stata output, or better yet provide a data example using dataex.

        reg vardep varind
        estimates store m1
        mat pval= (0.0001, 0.10, 0.045)
        For one, the regression you show has 1 regressor and constant (2 coefficients in total) whereas your matrix (or vector) has 3 elements. You will get a conformability error if that is the real code. Secondly, you need to label the columns of the p-value matrix with those from the coefficients' matrix in the regression. I showed you how to do this in #4 of https://www.statalist.org/forums/for...mized-p-values using

        Code:
        mat colnames pval= "`:colnames e(b)'"
        As you see in that example, the p-values from the matrix p-val are outputted.

        Comment


        • #5
          Thank you very much Andrew. I will explain my problem:

          I have the following regressions:

          Code:
          reg IATscience DiD , nocons
          estimates store m1
          
          reg IATmath1 DiD , nocons
          estimates store m2
          
          reg IATmath2 DiD , nocons
          estimates store m3
          
          reg IATscience2 DiD , nocons
          estimates store m4
          
          reg IATscience3 DiD , nocons
          estimates store m5
          
          reg IATscience4 DiD , nocons
          estimates store m6
          
          reg IATscience5 DiD , nocons
          estimates store m7
          
          reg IATscience6 DiD , nocons
          estimates store m8
          
          reg IATscience7 DiD , nocons
          estimates store m9
          Following your example, my matrix of pvalues is:
          Code:
          mat pval= (0.0001, 0.10, 0.045, 0.3, 0.03, 0.1, 0.23, 0.5, 0.001)
          mat colnames pval= "`:colnames e(b)'"
          estadd matrix pval= pval    
          
          estout m1 m2 m3 m4 m5 m6 m7 m8 m9 using  "$tables/test.doc", cells(b(star pvalue(pval) fmt(%9.3f)) pval(par fmt(%9.3f))) replace label
          I think the error may be that they are different regressions, but I don't know how I could fix it.

          Comment


          • #6
            You need:

            Code:
            reg IATscience DiD , nocons
            mat pval = 0.0001
            mat colnames pval= "`:colnames e(b)'"
            estadd matrix pval
            estimates store m1
            
            reg IATmath1 DiD , nocons
            mat pval= 0.10
            mat colnames pval= "`:colnames e(b)'"
            estadd matrix pval
            estimates store m2  
            
             *AND SO ON  
            
            estout m* using  "$tables/test.doc", cells(b(star pvalue(pval) fmt(%9.3f)) pval(par fmt(%9.3f))) replace label

            Comment

            Working...
            X