Announcement

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

  • Recovering estimate names/model titles after estimate save/use

    Hi,

    I am trying to recover the names of the estimates/model titles after -est use-, which is being used along with -eststo- (available from ssc). I would like to be able to compare the estimates from my regressions after starting a new Stata session.

    First, I save the estimates to a .ster file and then use -est use- to collect all the estimates. However, (I think) -eststo- doesn't save the model titles in `r(title)' so I can't refer back to them. Is there an alternative way to do so?

    Demo code based on ideas/examples discussed here:
    http://www.statalist.org/forums/foru...imates-to-file and here: http://www.statalist.org/forums/foru...tory-variables is as follows:

    Code:
    clear all
    ssc install estout, replace 
    sysuse auto
    
    qui eststo a: reg price weight
    qui eststo b: reg price weight length
    qui eststo c: reg price weight length mpg 
    
    * save estimates to a file
    estimates dir
    foreach e in `r(names)' {
        estimates restore `e'
        estimates save "c:/myest" , append
    }
    
    * new session
    clear all 
    estimates describe using "c:/myest"
    
    forvalues j=1/`r(nestresults)' {
        estimates use "c:/myest", number(`j')
        di "`r(title)'"
        estimates store e`j'
    }
    est dir
    I would like to be able to recover the estimates with their names/model titles: a, b and c (instead of e1, e2 and e3). Thank you for your help.

  • #2
    Perhaps adding the estimates title: command will given the estimates a title that is stored with them; I think otherwise you are getting a "default" title that is not stored.
    Code:
    foreach e in `r(names)' {
        estimates restore `e'
        estimates title: `e'
        estimates save "c:/myest" , append
    }

    Comment


    • #3
      Thank you, William. This worked. I am posting the updated code below.

      Code:
      clear all
      ssc install estout, replace 
      sysuse auto
      
      qui eststo a: reg price weight
      qui eststo b: reg price weight length
      qui eststo c: reg price weight length mpg 
      
      estimates dir
      foreach e in `r(names)' {
          estimates restore `e'
          estimates title: `e'
          estimates save "c:/myest" , append
      }
      
      clear all 
      estimates describe using "c:/myest"
      forvalues j=1/`r(nestresults)' {
          estimates describe using "c:/myest", number(`j')
          local title `r(title)'
          estimates use "c:/myest", number(`j')
          est store `title'
      }
      est dir

      Comment

      Working...
      X