Announcement

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

  • storing significant coefficients only - by firm regression

    Hello there,

    I am trying to store the beta coefficients with their t-stats and p-value but am unable to find any command that can help me to get that information. I tried different commands but was only able to get the beta coefficients but not the t-stats and p-value.

    below are some codes I found on this forum and tried.
    Code:
    sysuse auto, clear
    rangestat (reg) price mpg, by(rep78) interval(mpg . .)
    Code:
    bys rep78: asreg price mpg

    Any help would be highly appreciated.
    regards, Sara
    Last edited by sara haris ali; 13 Nov 2021, 05:02.

  • #2
    This example may start you in a useful direction.
    Code:
    sysuse auto, clear
    
    frame create regs rep str12 var b t p 
    
    levelsof rep78, local(reps)
    foreach r of local reps {
        regress price mpg if rep78==`r'
        foreach var in mpg _cons {
            frame post regs (`r') ("`var'")    ///
                (r(table)["b","`var'"]) ///
                (r(table)["t","`var'"]) ///
                (r(table)["pvalue","`var'"])
        }
    }
    
    frame regs {
        list, clean
        save results, replace
    }
    Code:
    .     list, clean
    
           rep     var           b           t          p  
      1.     1     mpg   -123.1667           .          .  
      2.     1   _cons        7151           .          .  
      3.     2     mpg    -630.823   -2.165634   .0735033  
      4.     2   _cons    18032.12    3.183512   .0189914  
      5.     3     mpg   -498.8875   -3.827617   .0006658  
      6.     3   _cons    16124.28    6.230595   9.86e-07  
      7.     4     mpg   -79.90338   -.9481444   .3571577  
      8.     4   _cons     7802.74    4.172322   .0007189  
      9.     5     mpg   -204.6947   -2.807912   .0204467  
     10.     5   _cons    11514.19    5.522168   .0003694

    Comment


    • #3
      Thanks, William, it is very helpful. just one thing, I was getting insufficient data errors due to the number of observations of the firms (less than the independent variables I used in the equation). I manually removed them and can see the results and wondering if we can impose a restriction to run for those that are greater than 3 or more?

      Regards, Sara

      Comment


      • #4
        Add -capture- in front of the regress command. See

        Code:
        help capture

        Comment


        • #5
          In this post https://fintechprofessor.com/2019/02...es-with-asreg/, I show how to get t-values and p-values using asreg.
          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


          • #6
            Thanks, Andrew and Attaullah for your help on this.

            Comment

            Working...
            X