Announcement

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

  • Error outputting multiple scalars using estout

    I am using est out on Stata/MP version 14.1. Recently, I've run into the same problem in a number of do files when I try to save the result of multiple post-estimation commands:
    Code:
    sysuse auto
    
    reg price mpg rep78
    est store output
    test _b[mpg]=0
    estadd scalar p1 = r(p)
    test _b[rep78]=0
    estadd scalar p2 = r(p)
    
    estout output using "test.xls", replace stats(p1 p2)
    When I open text.xls I am able to see the value for p1, but p2 appears as an empty cell.

  • #2
    A puzzler. I'm also on Stata 14.1 MP and can't replicate this. I copied your code into Stata's editor and ran it. p2 was not missing in the xls file. A search of the description of recent updates contains no mention of estout. What happens if you
    Code:
    estout output using "test.txt", replace stats(p1 p2)
    type test.txt
    Steve Samuels
    Statistical Consulting
    [email protected]

    Stata 14.2

    Comment


    • #3
      Yes, it's a bit bizarre. I've tried it on a couple of colleagues' machines with the same outcome, so it doesn't seem to be particular to my setup (though perhaps to our institution's?). Your suggestion yields the same excel output, and the value of p2 is omitted from the output window:

      Code:
      . type test.txt
              output
              b
      mpg     -271.6425
      rep78   666.9568
      _cons   9657.754
      p1      .0000136
      p2

      Comment


      • #4
        I am also unable to replicate your issue. What happens if you print to screen? Is p2 omitted when you type the following:
        Code:
        estout output, replace stats(p1 p2)

        Comment


        • #5
          I suggest that you contact tech support ([email protected]).
          Steve Samuels
          Statistical Consulting
          [email protected]

          Stata 14.2

          Comment


          • #6
            There seems several conflicts between the 'estout' package within and with Excel.

            1. Producing output with "*.xlsx" extension leads to a corrupt file for MS-Office for Mac 2016 (updated May 2016).

            2. Without output in Excel, Stata output suggests the 'estadd' is not capturing the value from the 2nd scalar:

            Code:
            reg price mpg rep78
            est store output
            test _b[mpg]=0
            estadd scalar p1 = r(p)
            test _b[rep78]=0
            estadd scalar p2 = r(p)
            
            ********************************
             estout output, stats(p1 p2)
            
            -------------------------
                               output
                                    b
            -------------------------
            mpg             -271.6425
            rep78            666.9568
            _cons            9657.754
            -------------------------
            p1               .0000136
            p2                       
            -------------------------
            3. Without scalar, the Stata output looks fine:

            Code:
             estout output, cells(b p)
            
            -------------------------
                               output
                                  b/p
            -------------------------
            mpg             -271.6425
                             .0000136
            rep78            666.9568
                             .0556529
            _cons            9657.754
                             7.99e-10
            -------------------------
            Roman

            Comment


            • #7
              Yes, but for Aaditya and for me, p2 is there. I should have mentioned that my system is Mac (OS X 10.9.5). Perhaps that's what differentiates those who see and who don't see this bug. I've reported this to Tech Support with a link to the thread.
              Last edited by Steve Samuels; 31 May 2016, 17:06.
              Steve Samuels
              Statistical Consulting
              [email protected]

              Stata 14.2

              Comment


              • #8
                Update Stata and estout (via adoupdate). This was fixed in February after a Stata update broke estadd.

                Long story short: after estadd was called, the _estimates_name value was removed from the active estimates. This caused problems with subsequent uses of estadd. Stata's changed behavior was that ereturn cleared any value called _estimates_name. Here is a brief demonstration of the changed Stata behavior without using estadd:

                Code:
                clear all
                
                program define monkey_business, eclass
                    ereturn local _estimates_name "foo"
                    di "e(_estimates_name): `e(_estimates_name)'"
                    ereturn local bar "bar"
                    di "e(_estimates_name): `e(_estimates_name)'"
                end
                
                cls
                sysuse auto
                quietly regress price weight
                monkey_business
                Last edited by Nils Enevoldsen; 01 Jun 2016, 09:22.

                Comment


                • #9
                  Thanks, Nils! I'd forgotten that estadd is not a built-in command. Like many of Ben Jann's contributions it just feels that way.
                  mmurphy. As the FAQ strongly request, please change your username to include your first name. Use the Contact Us button at the lower right.
                  Last edited by Steve Samuels; 01 Jun 2016, 10:13.
                  Steve Samuels
                  Statistical Consulting
                  [email protected]

                  Stata 14.2

                  Comment


                  • #10
                    Thanks Steve- I have requested a S/N update.

                    Nils- I have updated both, and the problem persists. Will follow up with technical support.

                    Comment


                    • #11
                      That updating estout did not fix the issue surprises me, as the behavior seems consistent with the fixed issue. Would you mind running the code from comment #8 and pasting the results here?

                      edit: Actually, this won't tell me what I really want to know. Disregard this post. I'd be interested to hear what Tech Support says.
                      Last edited by Nils Enevoldsen; 06 Jun 2016, 13:24.

                      Comment


                      • #12
                        Nils- Apologies, adoupdate was updating estadd, but I had overlooked estout. Manually re-installing estout resolves the issue.

                        Comment


                        • #13
                          Huh, I didn't even know it was possible to update estadd independently. Thanks for the update, Mike. Glad it's working.

                          Comment

                          Working...
                          X