Announcement

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

  • Saving t stat after regression into new variable/scalar

    Hello,

    I run a newey regression of a variable on a constant. I need to get the t-stat of the const saved into a new variable or scalar. I searched for this possibility in both newey and ivreg2 commands, but none of them provides it. Of course I can compute it manually with estimator of the constant and its variance, which are provided by above mentioned commands, but this is a little bit tedious as I need to go first to matrices, save them, compute t-stat.. I wonder if there is a direct way of getting t-stat. Thanks.

  • #2
    For those interested: so far the best option is as follows:

    gen t_stat = _b[_cons]/_se[_cons]

    Basically, this is already one line, and I think it is already pretty the fastest way to get t stat..

    Comment


    • #3
      Another option is to save the stored result r(table) in a matrix and extract from there:

      Code:
      *clear all
      set more off
      
      webuse idle2
      tsset time
      
      newey usr idle, lag(3)
      
      matrix define results = r(table)
      scalar myt = results[3,1]
      
      display myt
      However, that's two lines. (Saving a scalar in a scalar is better practice than saving in a variable.)
      You should:

      1. Read the FAQ carefully.

      2. "Say exactly what you typed and exactly what Stata typed (or did) in response. N.B. exactly!"

      3. Describe your dataset. Use list to list data when you are doing so. Use input to type in your own dataset fragment that others can experiment with.

      4. Use the advanced editing options to appropriately format quotes, data, code and Stata output. The advanced options can be toggled on/off using the A button in the top right corner of the text editor.

      Comment

      Working...
      X