Announcement

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

  • Problem with specifying the transform() option of coefplot to compute percentage changes

    Dear all,

    I am calling the coefplot command after estimating several models using the teffects ipwra command. I would like to display results in terms of percentage changes (i.e., coefficient/potential outcome mean) instead of the outcome unit, such that we can better understand their magnitude and compare this magnitude across indicators (this is for a non-technical audience). I was able to use the transform() command to divide each coefficient but it divides them by the potential outcome mean of the last outcome (i.e., coef_outcome1/POM_outcome3) instead of the respective outcome (i.e., coef_outcome1/POM_outcome1).

    Here is the code I am using:
    coefplot ${graph`i'}, ///
    coeflabels(r1vs0.$treatment= `"${lab_graph`i'}"', labsize(medium)) ///
    rescale(r1vs0.$treatment=100) ///
    transform( r1vs0.$treatment = (@/_b[POmean:0.$treatment]) ) ///
    ylabel(, notick labgap(0)) xline(0) legend(off) ///
    xtitle("Impact in %", margin(t+2) size(*1.4)) ///
    xsize(30cm) scale(1.2) ///
    graphregion(color(white)) bgcolor(white) ///
    format(%9.2f) mlabposition(12) mlabgap(*2) mlabel(cond(@pval<.001, string(@b, "%9.2fc") + "***", cond(@pval<.01, string(@b, "%9.2fc") + "**", cond(@pval<.05, string(@b, "%9.2fc") + "*", string(@b, "%9.2fc"))))) mlabsize(medium)

    And what I obtain (see figure).

    However the values for the first two outcomes are wrong, as explained above. Any suggestion? In this example, I only have binary outcome, however putting results on the same scale will be even more meaningful when I want to also display continuous outcomes. I have seen people expressing everything in terms of units of standard deviation, but I feel this is hard to grasp for a non-technical audience. Any alternative approach that would serve my purpose is also welcome. Thank you in advance !!!
    Click image for larger version

Name:	Results_1.png
Views:	1
Size:	42.9 KB
ID:	1674655

  • #2
    coefplot is from SSC (FAQ Advice #12).

    _b[POmean:0.$treatment]

    is just a scalar, and cannot be generalized to mean different things in different contexts. Provide a reproducible example using dataex for any code suggestions. Alternatively, you can use one of Stata's datasets to do this.

    Comment


    • #3
      Thank you Andrew, here is a code calling the cattaneo2 web database:

      ************************************************** ************************************************** *******************

      *Use available dataset
      clear all
      webuse cattaneo2

      ************************************************** ******************************
      *List of outcome variables
      global outcome lbweight deadkids alcohol
      *Define your treatment variable
      local treatment "mbsmoke"
      *Define the matching variables:
      local matching "mmarried c.mage##c.mage fbaby medu"
      *Define your list of covariates covariates
      local covariates "prenatal1 mmarried mage fbaby"
      *Generate identifiers for coefplots
      local number=0
      ************************************************** ******************************

      *Estimation using IPWRA
      foreach outcome of global outcome {
      teffects ipwra (`outcome' `covariates', probit) (`treatment' `matching', probit) , atet aequations
      local number=`number'+1
      estimates store O`number'
      }

      //Graphical illustration of results

      global lab_graph1 ""Outcome 1 " " " " " " " "Outcome 2 " " " " " " " " Outcome 3 ""

      coefplot O1 O2 O3 , ///
      coeflabels(r1vs0.`treatment'= `"${lab_graph1}"', labsize(medium)) ///
      rescale(r1vs0.`treatment'=100) ///
      transform( r1vs0.`treatment' = (@/_b[POmean:0.`treatment']) ) ///
      ylabel(, notick labgap(0)) xline(0) legend(off) ///
      xtitle("Impact in %", margin(t+2) size(*1.4)) ///
      xsize(30cm) scale(1.2) ///
      graphregion(color(white)) bgcolor(white) ///
      format(%9.2f) mlabposition(12) mlabgap(*2) mlabel(cond(@pval<.001, string(@b, "%9.2fc") + "***", cond(@pval<.01, string(@b, "%9.2fc") + "**", cond(@pval<.05, string(@b, "%9.2fc") + "*", string(@b, "%9.2fc"))))) mlabsize(medium)

      ************************************************** ************************************************** *************************

      Comment


      • #4
        I would like to display results in terms of percentage changes (i.e., coefficient/potential outcome mean) instead of the outcome unit
        Why not just calculate this ratio using nlcom?

        Code:
        *Use available dataset
        clear all
        webuse cattaneo2
        
        ************************************************** ******************************
        *List of outcome variables
        global outcome lbweight deadkids alcohol
        *Define your treatment variable
        local treatment "mbsmoke"
        *Define the matching variables:
        local matching "mmarried c.mage##c.mage fbaby medu"
        *Define your list of covariates covariates
        local covariates "prenatal1 mmarried mage fbaby"
        *Generate identifiers for coefplots
        local number=0
        ************************************************** ******************************
        
        *Estimation using IPWRA
        foreach outcome of global outcome {
        teffects ipwra (`outcome' `covariates', probit) (`treatment' `matching', probit) , atet aequations
        nlcom _b[ATET:r1vs0.`treatment']/_b[POmean:0.`treatment'], post
        local number=`number'+1
        estimates store O`number'
        }
        
        //Graphical illustration of results
        
        global lab_graph1 ""Outcome 1 " " " " " " " "Outcome 2 " " " " " " " " Outcome 3 ""
        
        coefplot O1 O2 O3 , ///
        coeflabels( _nl_1= `"${lab_graph1}"', labsize(medium)) ///
        rescale(_nl_1=100) ///
        ylabel(, notick labgap(0)) xline(0) legend(off) ///
        xtitle("Impact in %", margin(t+2) size(*1.4)) ///
        xsize(30cm) scale(1.2) ///
        graphregion(color(white)) bgcolor(white) ///
        format(%9.2f) mlabposition(12) mlabgap(*2) mlabel(cond(@pval<.001, string(@b, "%9.2fc") + "***", cond(@pval<.01, string(@b, "%9.2fc") + "**", cond(@pval<.05, string(@b, "%9.2fc") + "*", string(@b, "%9.2fc"))))) mlabsize(medium)
        Click image for larger version

Name:	Graph.png
Views:	1
Size:	15.7 KB
ID:	1675009

        Comment


        • #5
          That works perfectly, thank you for the suggestion!

          Comment

          Working...
          X