Announcement

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

  • Store a vector of coefficients after regression

    Hi all,

    I ran the following regression:
    Code:
    reg income i.event_time i.age i.year
    And now I want to store all the coefficients of i.event_time.

    What is the best commands to save this vector?

    thank you,

    Fitz

  • #2
    It depends on what you mean by "save." If you want to retain the regression results for re-use later, you have the -estimates store- command, which will save them in memory and they will be available until you exit Stata or explicitly drop them. If you will need to reuse them in a future session of Stata, then there is -estimates save-, which will create a .ster file on your hard drive that you can then bring back with -estimates use- in a new Stata session. Note that these commands affect not just the coefficients, but all of the regression results. Do read the help files for these commands for details of syntax and fine points.

    If you want to put the coefficients, and only the coefficients, into a matrix (vector = 1xn or nx1 matrix in Stata), you can do that with -matrix M = e(b)-.

    Comment


    • #3
      you don't say anything about where you are going with this so I'll just give a simple answer - the coefficients (and other results) are saved in "r(table)" - but this will go away when you do something else so, after you estimate your regression, just use the matrix command to save the r(table) matrix; see
      Code:
      h matrix
      added: crossed with the better answer in #2

      Comment


      • #4
        The user command `regsave`, which can be installed by typing `ssc install regsave, replace`, saves the coefficients to a Stata dataset.

        Code:
        sysuse auto, clear
        reg price mpg i.foreign
        regsave
        list
        
             +---------------------------------------------------+
             |        var        coef     stderr    N         r2 |
             |---------------------------------------------------|
          1. |        mpg   -294.1955   55.69172   74   .2838475 |
          2. | 0b.foreign           0          0   74   .2838475 |
          3. |  1.foreign    1767.292    700.158   74   .2838475 |
          4. |      _cons    11905.42   1158.634   74   .2838475 |
             +---------------------------------------------------+
        Associate Professor of Finance and Economics
        University of Illinois
        www.julianreif.com

        Comment

        Working...
        X