Announcement

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

  • table with coefficients from regressions

    Hello

    With the following code I am able to run the regressions and get the constant and the t-statistic.

    Code:
    eststo er1: quietly reg er1 MktRF SMB HML
    eststo er2: quietly reg er2 MktRF SMB HML
    eststo er3: quietly reg er3 MktRF SMB HML
    eststo er4: quietly reg er4 MktRF SMB HML
    eststo er5: quietly reg er5 MktRF SMB HML
    eststo er6: quietly reg er6 MktRF SMB HML
    eststo er7: quietly reg er7 MktRF SMB HML
    eststo er8: quietly reg er8 MktRF SMB HML
    eststo er9: quietly reg er9 MktRF SMB HML
    esttab, t nostar r2
    mat list r(coefs)
    esttab r(coefs, transpose)
    eststo clear
    I would like to create two tables that looks as follows:
    er1 _cons er2 _cons er3 _cons
    er4 _cons er5 _cons er6 _cons
    er7 _cons er8 _cons er9 _cons
    and the second with the t-statistics
    er1 _t-stat er2 _t-stat er3 _t-stat
    er4 _t-stat er5 _t-stat er6 _t-stat
    er7 _t-stat er8 _t-stat er9 _t-stat
    Does anybody know how I can create such tables?

    Thank you very much for your help.
    Last edited by Pascal Strebel; 02 Nov 2020, 06:01.

  • #2
    This looks like a format that Fama and French use for their regression results.

    I do not know of any Stata command that does this format automatically.

    You can create the matrices and manually populate them with the coefficients and t-statistics.

    Comment


    • #3
      You can write the results to a matric and then export the matric to MS Word file using asdoc. Here is an example code.


      Code:
      clear
      set obs 100
      gen SMB = uniform()
      gen HML = uniform()
      gen MktRF = SMB + HML + uniform()
      
      
      forv i = 1 / 9 {
          gen er`i' = uniform()
      }
      
      mat cons = J(3,3,.)
      mat tstat = J(3,3,.)
      loc row = 1
      loc col = 1
      
      forv i = 1 / 3 {
          reg er`i' MktRF SMB HML
          mat rtable = r(table)
          mat cons[`row', `col']  = rtable[1,4]
          mat tstat[`row', `col'] = rtable[3,4]
          loc ++col
      }
      loc row = 2
      loc col = 1
      
      forv i = 4 / 6 {
          reg er`i' MktRF SMB HML
          mat rtable = r(table)
          mat cons[`row', `col']  = rtable[1,4]
          mat tstat[`row', `col'] = rtable[3,4]
          loc ++col
      }
      loc row = 3
      loc col = 1
      
      forv i = 7 / 9 {
          reg er`i' MktRF SMB HML
          mat rtable = r(table)
          mat cons[`row', `col']  = rtable[1,4]
          mat tstat[`row', `col'] = rtable[3,4]
          loc ++col
      }
      
      * Write the matrices with asdoc to a word file
      asdoc wmat, mat(cons)  replace
      asdoc wmat, mat(tstat)
      Click image for larger version

Name:	Capture.PNG
Views:	1
Size:	25.0 KB
ID:	1580001

      Regards
      --------------------------------------------------
      Attaullah Shah, PhD.
      Professor of Finance, Institute of Management Sciences Peshawar, Pakistan
      FinTechProfessor.com
      https://asdocx.com
      Check out my asdoc program, which sends outputs to MS Word.
      For more flexibility, consider using asdocx which can send Stata outputs to MS Word, Excel, LaTeX, or HTML.

      Comment


      • #4
        Dear Mrs Shah

        This is awesome and exactly what I was looking for! Thank you very much

        Comment

        Working...
        X