Announcement

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

  • Confidence interval storage

    Does anyone know where confidence interval outputs of a logit are stored? I recently ran:

    Code:
    proportion hlthpln1, over(acaint)
    lincom _b[_prop_2:1] - _b[_prop_2:0]
    which returned some confidence intervals. I'm looking to export those confidence intervals. I can't seem to find them when running:

    Code:
    ereturn list
    or
    Code:
    return list
    For example, the Proportion column is stored as a matrix in
    Code:
    e(b)
    . I can't seem to find the equivalent for the Confidence intervals.

    Attached is my output (I know screenshots are frowned upon, but it was much easier than copy/pasting and reformatting line by line).

    Click image for larger version

Name:	Screen Shot 2017-09-16 at 21.53.51.png
Views:	1
Size:	28.2 KB
ID:	1410725



  • #2
    You can find them in the matrix stored in r(table) after -proportion- (or any other estimation command).

    If you are looking for the confidence intervals displayed by -lincom-, they are not stored anywhere. However -lincom- leaves r(df), r(se) and r(estimate) in r(), and you can calculate the upper and lower confidence limits from there.

    Code:
    display r(estimate) + r(se)*invt(r(df), 0.025) // LOWER LIMIT
    display r(estimate) + r(se)*invt(r(df), 0.975) // UPPER LIMIT
    In the future, please do NOT post screen shots of Stata output. Show Stata output by copying from your log file or the results window and pasting into the Forum editor between code delimiters. If you are not familiar with code delimiters, see FAQ #12. The problem with screen shots is two-fold: as often as not they are not readable by others, and, even when they are, if one wanted to copy/paste some of your code to try working with it or modifying it or testing it, that is not possible from an image. If you use code delimiters, there is no need to reformat the code line by line: in fact if you use code delimiters the end result will be a perfectly readable and completely faithful copy of what Stata gave you. And that is precisely what is needed: you should not edit it in any way. Just learn to use code delimiters properly and you will see that they are superior to screen shots.

    Comment


    • #3
      I tried creating a Matrix with r(table) and it didn't seem to create any output. This was my code:

      Code:
      matrix a = r(table)
      putexcel A8=matrix(a)
      I also tried directly, to no avail:

      Code:
      putexcel A8=matrix(r(table))
      As for the code delimiters, in FAQ 12, it seems to imply that "[CODE][/ CODE]" are the delimiters, but copy and pasting a log file and surrounding the output (which pastes unformatted) with "[CODE][/ CODE]" doesn't produce formatted output. Is there a tutorial on using delimiters anywhere? A google search didn't help, either.

      Comment


      • #4
        Originally posted by Ameen Barghi View Post
        I tried creating a Matrix with r(table) and it didn't seem to create any output. This was my code:

        Code:
        matrix a = r(table)
        putexcel A8=matrix(a)
        You need to do that right after the estimation command. lincom overwrites the r-returns from the previous command and that would include r(table).

        Try the following and take a look at what's happening and when. It should help clear up what you need to do.
        Code:
        version 15.0
        
        clear *
        
        set seed 1410728
        quietly set obs 100
        
        quietly generate byte A = .
        export excel using Book1.xlsx, sheet(Sheet1)
        
        quietly replace A = mod(_n, 2)
        generate byte O = runiform() > 0.5
        
        *
        * Begin here
        *
        proportion O, over(A)
        
        matrix list r(table)
        matrix define A = r(table)
        matrix define A = A["ll".."ul", 1...]
        matrix list A
        
        lincom _b[_prop_2:1] - _b[_prop_2:0]
        matrix define B = (r(estimate) + r(se) * invt(r(df), 0.025) \ ///
            r(estimate) + r(se) * invt(r(df), 0.975))
        matrix list B
        
        matrix define A = A, B
        
        putexcel set Book1.xlsx, sheet(Sheet1) modify
        putexcel A8 = matrix(A), names
        
        exit

        Comment

        Working...
        X