Announcement

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

  • Manipulating results stored by commands

    Is there a way to change a stored result? For example, after a regression I would to change the value of e(N) itself to then apply some postestimation commands. To provide some context, I would like to use
    Code:
    -mfxrcspline-
    from SSC with my own standard errors which I obtain from a combination of bootstraps.

  • #2
    You cannot change what is stored in e(). However, you can write code that stores new "estimates" that are more to your liking. See -help ereturn-.

    Comment


    • #3
      Originally posted by Clyde Schechter View Post
      You cannot change what is stored in e(). However, you can write code that stores new "estimates" that are more to your liking. See -help ereturn-.
      Technically, this statement is incomplete. It is true that e(b), e(V) and e(Cns) can only be altered using an eclass program and ereturn repost. Other results, stored in e() cannot be [directly, i.e., outside an eclass program] changed in Stata, but you can use Mata. Here is an example.

      Code:
      sysuse auto
      regress price mpg i.foreign
      display e(N)
      mata : st_numscalar("e(N)", 42)
      display e(N)
      In each case, you should really be sure that you know what you are doing. Messing with Stata's returned results might have unexpected consequences and might give you results that you should be able to obtain for good reason.

      Best
      Daniel
      Last edited by daniel klein; 13 Sep 2017, 13:38. Reason: add part in brackets

      Comment


      • #4
        Thank you Daniel and Clyde, you pointed me to the relevant issues. For future reference, I present my solution here, using
        Code:
        -erepost-
        available from SSC:
        Code:
        sysuse auto, clear
        reg price mpg
        matrix list e(V)
        matrix  V = (1, 1 \ 1, 1 )
        erepost V = V, rename
        matrix list e(V)

        Comment


        • #5
          Hi Felix,

          I am trying to do something similar to include both estimates and confidence intervals from a regression and from a bootstrap, with the aim of exporting them to latex though esttab o estout. Have you found a way to alter the e-class elements feeding esttab/estout? That would be very handy.
          Best,
          Felipe L.

          Comment

          Working...
          X