Announcement

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

  • Storing values of the regressand post estimation

    I am trying to get the values of my regressand variable TA_SCALED_LASSETS post regression. I looked over online seems like it should be "regsave" but just looking for more clarification.

    Code:
    set more off
    
    gen DACC = . 
    gen TA = .                   
    
    egen sicid = group(SICCode Year)         
    sum sicid
    local max=r(max)
    
    forvalues i = 1/`max' {
    
     di "Busy with regression " `i' " of " `max'
     qui reg TA_SCALED_LASSETS INVER_LAG_ASSET DSALES_S_LAGASSETS PPE_S_LAGASSETS if sicid == `i', nocons
     qui predict res if sicid == `i', res
     qui replace DACC = res if sicid == `i'
     qui drop res
     
    }
    Thanking you in advance for your help.

  • #2
    What you want is unclear. Your regressand variable TA_SCALED_LASSETS is the same post-regression and remains in your dataset, and you have added to the dataset the predicted value of TA_SCALED_LASSETS in the variable DACC.

    Comment


    • #3
      Farhan:
      like William, I'm not sure I got you right.
      That said, you may want to test the following small tweaks to your previous code:
      Code:
      set more off
      gen DACC = .
      gen TA = . 
      gen regressand=.                
      egen sicid = group( idcode year )        
      sum sicid
      local max=r(max)
      forvalues i = 1/`max' {
       di "Busy with regression " `i' " of " `max'
       qui reg ln_wage c.age##c.age if sicid == `i', nocons
       qui predict res if sicid == `i', res
       replace DACC = res if sicid == `i'
       replace regressand = TA_SCALED_LASSETS if sicid == `i'
       drop res
      }
      Kind regards,
      Carlo
      (StataNow 18.5)

      Comment

      Working...
      X