Announcement

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

  • Storing estimates from bysort: reg command into a new variable

    Hello,

    First time Statalist user here (please let me know if there is any way to improve my post)!
    I am using individual-level panel data that includes variables for income, years of education, and occupation-industry. I use the below code to estimate the returns of education on income, by industry-occupation.
    Code:
    bysort occupation_industry: reg income education, r
    I would like to store all of the coefficients for education in a variable, but I was not able to find any options in the regress command that allow me to do this. I would usually use _b[varname] or estimates save to save coefficients but as far as I am aware, these are not compatible with bysort: regress.

    Any suggestions?

  • #2
    Code:
    . sysuse auto, clear
    (1978 automobile data)
    
    . statsby, by(foreign) : regress mpg weight, r
    (running regress on estimation sample)
    
          Command: regress mpg weight, r
               By: foreign
    
    Statsby groups
    ----+--- 1 ---+--- 2 ---+--- 3 ---+--- 4 ---+--- 5 
    ..
    
    . l
    
         +---------------------------------+
         |  foreign   _b_weight    _b_cons |
         |---------------------------------|
      1. | Domestic   -.0059751   39.64697 |
      2. |  Foreign    -.010426    48.9183 |
         +---------------------------------+
    There are options to save more results.

    Comment


    • #3
      statsby seems to do exactly what I wanted, so thank you. Unfortunately, I failed to mention in my original post that my equation uses pweights, which is the only type of weight that is not supported by statsby. A more correct version of my code(before using statsby) is the following.
      Code:
        
       bysort occupation_industry: reg income education [pw=sw], r


      Do you have any suggestions for a way to include a sample weight when pweights is not allowed? Thanks!

      Comment


      • #4
        Sorry, no.

        Comment

        Working...
        X