Announcement

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

  • Quickly accessing p-values and confidence interval limits

    After running a regression model in Stata a quick way to access the coefficients and their standard errors is using _b[varname] and _se[varname]. However, to access their corresponding p-values and confidence interval limits I find myself having to create a matrix of the results from which to extract them, like so:

    sysuse auto, clear
    regress length weight
    mat R = r(table)
    local p = R[4,1]
    local ll = R[5,1] etc...


    The code is rather ugly, having to manually specify the entries of the matrix from which to extract the relevant results. Also, when using multivariable regression I often end up with a sea of numbers from which I need to find my statistics of interest. Clearly this would be much easier (particularly when writing an ado file) if I could instead simply type

    local p = _p[weight]
    local ll = _ll[weight] etc
    ...

    in a similar manner to the _b[] and _se[] functions. My question is therefore, is there an easier way to extract p-values and confidence interval limits to what I have been using, and if not, might Stata consider adding functions like _p, _ll, _ul, _df etc in a future Stata release?

    Thanks,

    Dan

  • #2
    Try something like
    Code:
    local t = _b[_cons]/_se[_cons]
    local p =2*ttail(e(df_r),abs(`t'))
    Regards
    --------------------------------------------------
    Attaullah Shah, PhD.
    Professor of Finance, Institute of Management Sciences Peshawar, Pakistan
    FinTechProfessor.com
    https://asdocx.com
    Check out my asdoc program, which sends outputs to MS Word.
    For more flexibility, consider using asdocx which can send Stata outputs to MS Word, Excel, LaTeX, or HTML.

    Comment


    • #3
      Thanks. I'm aware that that is another way of doing it but it still wouldn't be as easy as simply specifying _p[_cons] or _ll[_cons] etc. I realise that this is only a minor gripe of mine but I do not understand why you can use _b and _se to obtain the coefficient and its standard error but not similar things for p-values, CIs etc.

      Comment


      • #4
        You can use the above code to write your own program with rclass properties.
        Regards
        --------------------------------------------------
        Attaullah Shah, PhD.
        Professor of Finance, Institute of Management Sciences Peshawar, Pakistan
        FinTechProfessor.com
        https://asdocx.com
        Check out my asdoc program, which sends outputs to MS Word.
        For more flexibility, consider using asdocx which can send Stata outputs to MS Word, Excel, LaTeX, or HTML.

        Comment


        • #5
          I used to use feed r(table) into Mata to manipulate estimation results, until I discovered Roger Newson's parmest package (SSC).
          Steve Samuels
          Statistical Consulting
          [email protected]

          Stata 14.2

          Comment

          Working...
          X