Announcement

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

  • Reduce number of decimals in twostepweakiv output

    Hello, I was trying to use the twostepweakiv command to compute the AR 95% confidence intervals. The problem is that this command saves the interval as a string, so I cannot format the number of decimals included in the interval.
    The example below generates the table that I am trying to compute, except, it includes too many decimals for the confidence intervals. Any ideas of how to reduced the size? Alternatively, has anyone else found any ways of
    exporting the output of twostepweakiv into latex tables?


    use http://www.stata.com/data/jwooldridge/eacsap/mroz.dta
    generate byte poshours=(hours>0)

    eststo clear
    twostepweakiv 2sls lwage exper expersq (educ = fatheduc motheduc)
    local ar = e(ar_cset)
    local wald = e(wald_cset)
    eststo:ivregress 2sls lwage exper expersq (educ = fatheduc motheduc)

    estadd local arval "`ar'"
    estadd local waldval "`wald'"
    esttab using table.tex, se se(2) b(2) stats(arval waldval N, fmt(%15s %15s %12.0fc) labels("Schooling 95\% CI -- AR" "Schooling 95\% CI -- Wald" "N. of observations")) star(* 0.10 ** 0.05 *** 0.01) label nomtitles replace nogaps nonotes nonumber substitute(\_ _)

  • #2
    Here's an approach that may start you in a useful direction.
    Code:
    use http://www.stata.com/data/jwooldridge/eacsap/mroz.dta
    generate byte poshours=(hours>0)
    
    eststo clear
    twostepweakiv 2sls lwage exper expersq (educ = fatheduc motheduc)
    local ar = e(ar_cset)
    local wald = e(wald_cset)
    local arends = ustrregexra("`ar'", "[\[\],]", "")
    local ar_lo : word 1 of `arends'
    local ar_hi : word 2 of `arends'
    local ar : display "[ " %5.3f `ar_lo' ", " %5.3f `ar_hi' "]"
    eststo:ivregress 2sls lwage exper expersq (educ = fatheduc motheduc)
    estadd local arval "`ar'"
    estadd local waldval "`wald'"
    esttab /* using table.tex*/ , se se(2) b(2) stats(arval waldval N, fmt(%15s %15s %12.0fc) ///
      labels("Schooling 95\% CI -- AR" "Schooling 95\% CI -- Wald" "N. of observations")) ///
      star(* 0.10 ** 0.05 *** 0.01) ///
      label nomtitles replace nogaps nonotes nonumber substitute(\_ _)
    Code:
    ------------------------------------
    ------------------------------------
    years of schooling           0.06** 
                               (0.03)   
    actual labor mkt e~r         0.04***
                               (0.01)   
    exper^2                     -0.00** 
                               (0.00)   
    Constant                     0.05   
                               (0.40)   
    ------------------------------------
    Schooling 95\% CI ~R [ -0.021, 0.137]   
    Schooling 95\% CI ~d [-.003629, .126422]   
    N. of observations            428   
    ------------------------------------

    Comment


    • #3
      Thanks!!!

      Comment


      • #4
        I don't know if it was different version of Stata, but on my version I need to have an added space for the commands to work.
        local arends = ustrregexra("`ar'", "[\[\],]", " ") added space

        Comment


        • #5
          Richard Thomas Boylan -

          Perhaps if you had posted the code in post #4 using CODE delimiters it would be as readable as the code in post #2 is.

          Do take take a few moments to review the Statalist FAQ linked to from the top of the page, as well as from the Advice on Posting link on the page you used to create your post. Note especially sections 9-12 on how to best pose your question. It is particularly helpful to copy commands and output from your Stata Results window and paste them into your Statalist post using code delimiters [CODE] and [/CODE], and to use the dataex command to provide sample data, as described in section 12 of the FAQ.

          Comment


          • #6
            Sorry, I did not realize that. Here is my response using code delimters:

            I don't know if it was different version of Stata, but on my version I need to have an added space for the commands to work.


            Code:
            local arends = ustrregexra("`ar'", "[,]", " ")
                                                   added space

            Comment

            Working...
            X