Announcement

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

  • Different output from estimates table when using stored estimates

    How do I preserve value labels when running estimates table with stored estimates?

    If I run estimates table immediately after I fit a model, the output shows the correct value labels; however, if I store the estimate, fit another model, and then try to use estimates table with the stored estimate corresponding to the first model, the value labels are lost.

    Code:
    * Example generated by -dataex-. To install: ssc install dataex
    clear
    input double ped_slight_inj float season byte weather_conditions
    0 2 1
    0 2 1
    0 2 1
    0 2 1
    0 2 1
    0 2 1
    0 2 1
    0 2 1
    0 2 1
    0 2 1
    0 1 1
    1 1 1
    0 1 2
    0 1 1
    0 1 1
    0 1 1
    0 1 2
    0 1 1
    0 1 1
    0 1 1
    end
    label values season season
    label def season 1 "Winter", modify
    label def season 2 "Spring", modify
    label values weather_conditions weather_conditions
    label def weather_conditions 1 "Fine", modify
    label def weather_conditions 2 "Raining", modify
    
    // First regression
    qui logit ped_slight_inj i.season
    
    // Store first regression
    est store season
    
    // First estimates table
    estimates table season
    
    // Second regression
    qui logit ped_slight_inj i.weather_conditions
    
    // Second estimates table from stored result of first regression
    estimates table season

  • #2
    In your example, you can replace
    Code:
    // Second estimates table from stored result of first regression
    estimates table season
    with
    Code:
    // Second estimates table from stored result of first regression
    estimates restore season
    estimates table
    and the value labels are used.

    If you want to include the results of your two regressions in a single table, it gets more complicated. Don't ask me why this works the way it does - it was trial-and-error.
    Code:
    // First regression
    qui logit ped_slight_inj i.season
    est store season
    
    // Second regression
    qui logit ped_slight_inj i.weather_conditions
    estimates store weather
    
    // Estimates table from stored result of second regression
    estimates table season weather
    
    // Second try
    estimates restore season
    estimates table season weather
    
    // Third try
    qui logit ped_slight_inj i.weather_conditions i.season
    estimates store both
    estimates table season weather
    Code:
    . // First regression
    . qui logit ped_slight_inj i.season
    
    . est store season
    
    . 
    . // Second regression
    . qui logit ped_slight_inj i.weather_conditions
    
    . estimates store weather
    
    . 
    . // Estimates table from stored result of second regression
    . estimates table season weather
    
    ----------------------------------------
        Variable |   season      weather    
    -------------+--------------------------
          season |
              2  |    (empty)               
                 |
    weather_co~s |
        Raining  |                 (empty)  
                 |
           _cons | -2.1972246   -2.8332133  
    ----------------------------------------
    
    . 
    . // Second try
    . estimates restore season
    (results season are active now)
    
    . estimates table season weather
    
    ----------------------------------------
        Variable |   season      weather    
    -------------+--------------------------
          season |
         Spring  |    (empty)               
                 |
    weather_co~s |
              2  |                 (empty)  
                 |
           _cons | -2.1972246   -2.8332133  
    ----------------------------------------
    
    . 
    . // Third try
    . qui logit ped_slight_inj i.weather_conditions i.season
    
    . estimates store both
    
    . estimates table season weather
    
    ----------------------------------------
        Variable |   season      weather    
    -------------+--------------------------
          season |
         Spring  |    (empty)               
                 |
    weather_co~s |
        Raining  |                 (empty)  
                 |
           _cons | -2.1972246   -2.8332133  
    ----------------------------------------

    Comment


    • #3
      If you want to include the results of your two regressions in a single table, it gets more complicated. Don't ask me why this works the way it does - it was trial-and-error.
      I believe the reason why it works is that the active (re)stored results comprise all value labels present in the multiple comparison table.

      Comment

      Working...
      X