Announcement

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

  • Marginsplot with boottest confidence intervals

    Dear Statalist,

    I am trying to estimate some marginal effects using my dataset and wild-bootstrap the marginal effects using boottest. And I want to graph the marginsplot with the bootstrapped CIs. But I have trouble figuring out a way to do this.

    Using the nlsw88 dataset for example,

    Code:
    sysuse nlsw88.dta
    regress wage tenure ttl_exp collgrad south#union, cluster(industry)
    margins south
    boottest, margins
    I tried to use the post option after margins to store the margins results e(b) first, and then use the boottest command and return list to get and store r(CI). However, it doesn't work.

    Could someone give me a hint? Thank you so much!
    Last edited by Victoria Wong; 06 Oct 2021, 21:41.

  • #2
    Your syntax is a bit different from what is described here: https://www.statalist.org/forums/for...-with-boottest

    Maybe David Roodman can comment on your question.
    Best wishes

    (Stata 16.1 MP)

    Comment


    • #3
      This is an interesting question. There is no easy way to do what you want here. And there may be no easy way for me to change that. margins produces point estimates and standard errors, which marginsplot looks for and uses in making graphs. boottest does not produce standard errors, because those imply the assumption that the parameter estimate follows a classical distribution such as the normal or t, and the reason for using the bootstrap is the concern that those distributions may be wrong.

      The best solution I have found is to use Ben Jann's coefplot program, which you can install with "ssc install coefplot". Here is an example:

      Code:
      sysuse nlsw88
      regress wage tenure ttl_exp collgrad south#union, cluster(industry)
      margins south
      boottest, margins nograph
      
      cap mat drop b
      cap mat drop CI
      local i 1
      while "`r(b_`i')'" != "" {  // gather the b's and CI's from boottest
        mat b = nullmat(b), r(b_`i')
        mat CI = nullmat(CI), r(CI_`i')'
        local ++i
      }
      mat colnames b = 0.south 1.south
      coefplot mat(b), ci(CI)
      Note that this code will fail if a boottest CI consists of more than one (disjoint) piece, as sometimes happens after instrumental variables estimation.

      Comment


      • #4
        Originally posted by David Roodman View Post
        This is an interesting question. There is no easy way to do what you want here. And there may be no easy way for me to change that. margins produces point estimates and standard errors, which marginsplot looks for and uses in making graphs. boottest does not produce standard errors, because those imply the assumption that the parameter estimate follows a classical distribution such as the normal or t, and the reason for using the bootstrap is the concern that those distributions may be wrong.

        The best solution I have found is to use Ben Jann's coefplot program, which you can install with "ssc install coefplot". Here is an example:

        Code:
        sysuse nlsw88
        regress wage tenure ttl_exp collgrad south#union, cluster(industry)
        margins south
        boottest, margins nograph
        
        cap mat drop b
        cap mat drop CI
        local i 1
        while "`r(b_`i')'" != "" { // gather the b's and CI's from boottest
        mat b = nullmat(b), r(b_`i')
        mat CI = nullmat(CI), r(CI_`i')'
        local ++i
        }
        mat colnames b = 0.south 1.south
        coefplot mat(b), ci(CI)
        Note that this code will fail if a boottest CI consists of more than one (disjoint) piece, as sometimes happens after instrumental variables estimation.
        Thank you so much, David!

        Comment

        Working...
        X