Announcement

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

  • Coefplot after gsem

    I have a question about the coefplot command following gsem models. I am trying to run complier average treatment effectmodels with the gsem command.

    My problem is that when I try using coefplot, it only seems to plot the control variables (listed on the 4th line of the code below), whereas I need the coefplot of the treatment. I tried using the keep and drop options, but since the treatment does not even appear in the list of variables of the coefplot, it did not make a difference. Does anyone know how I might be able to fix this?

    Here is the code I used:

    gsem ///
    (1: petition <- i.treatment@0 corruption_pol corruption_brazilians trust_congress corruption_bureaucracy impartiality credibility competence trust_prosecutor) ///
    (2: petition <- i.treatment) ///
    (C <- i.male income education age i.race) ///   
    (1: m_check <- _cons@-15, logit) ///
    (2: m_check <- _cons@15, logit), ///      
    lclass(C 2)

    estimates store petition

    coefplot petition



    Thank you!

  • #2
    I haven’t been able to figure this out either. I’ll bump the post just in case someone who does know the answer is back from a richly deserved break and can now chime in.
    -------------------------------------------
    Richard Williams, Notre Dame Dept of Sociology
    StataNow Version: 19.5 MP (2 processor)

    EMAIL: [email protected]
    WWW: https://academicweb.nd.edu/~rwilliam/

    Comment


    • #3

      Use option coeflegend to see how the coefficients are striped.
      Code:
      gsem, coeflegend
      Based on your model specification, I hazard a guess that you want
      something like the following, which will plot all the coefficients for
      the petition outcome.
      Code:
      coefplot (petition, keep(petition:))
      It is not clear if the treatment is binary, but if it is and you
      only want the fitted treatment coefficient, then my second guess is
      Code:
      coefplot (petition, keep(1.treatment#2.C))
      Here is an example, with data, where I fit a latent class model for a
      linear outcome with a binary (0/1) predictor and some other continuous
      predictors. The first call to coefplot plots all the fitted
      coefficients (and intercepts) for my outcome variable, here the
      1.C and 2.C identify which class the coefficients
      (and intercepts) belong to. The second call plots the fitted
      coefficients for the binary predictor, from each class.
      Code:
      sysuse auto
      
      gsem mpg <- i.foreign turn trunk, lclass(C 2)
      gsem, coeflegend
      est store fit
      
      coefplot (fit, keep(mpg:)), name(try1) title(Try #1)
      
      coefplot (fit, keep(1.foreign#1.C 1.foreign#2.C)), name(try2) title(Try #2)
      
      graph export try1.png, replace name(try1)
      graph export try2.png, replace name(try2)
      Here are the graphs.


      Click image for larger version

Name:	try1.png
Views:	1
Size:	78.9 KB
ID:	1728419
      Click image for larger version

Name:	try2.png
Views:	1
Size:	46.0 KB
ID:	1728420

      Comment


      • #4
        Dear Jeff, thank you so much for the thorough and thoughtful response! Your suggestions worked perfectly.

        Comment


        • #5
          You are welcome.

          Comment

          Working...
          X