Announcement

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

  • Displaying Cause and Effect on Same coefplot

    Hi all,

    I'm currently working on a project using panel data trying to assess contractual language and the effect on firm outcomes. My supervisor has also asked me to test for firm status effect on contractual language. I wanting to show both of these on the same graph for the contractual terms as outcome and "cause" (using in quotes to make clear that I'm using the term "cause" loosely). Here are the regressions I'm running:

    Code:
    *** Regression for Takeover as Cause
    local i = 1
    foreach restraint of local restraints {
    reghdfe `restraint' treat_by_post, abs(fruns year) vce(cluster fruns)
    estimates store est_restraint_outcome_`i'
    local i = `i' + 1
    }
    
    *** Regression for Takeover as Outcome
    local i = 1
    foreach restraint of local restraints {
    keep if year >= 2013
    reghdfe treat_by_post `restraint', abs(fruns year) vce(cluster fruns)
    estimates store est_PE_outcome_`i'
    local i = `i' + 1
    }
    Within the macro
    Code:
    `restraints'
    are the variables "franchisee_noncompete", "right_to_purchase", "right_1st_refusal", and "excl_dealing".

    This is my code for my coefficient plot:

    Code:
    * Coefplot for Non-Competition Restraints
    coefplot ///
        (est_PE_outcome_1, label("`: variable label franchisee_noncompete'")) ///
        (est_restraint_outcome_1, label("`: variable label franchisee_noncompete'")) ///
        (est_PE_outcome_2, label("`: variable label right_to_purchase'")) ///
        (est_restraint_outcome_2, label("`: variable label right_to_purchase'")) ///
        (est_PE_outcome_3, label("`: variable label right_1st_refusal'")) ///
        (est_restraint_outcome_3, label("`: variable label right_1st_refusal'")) ///
        (est_PE_outcome_4, label("`: variable label excl_dealing'")) ///
        (est_restraint_outcome_4, label("`: variable label excl_dealing'")), ///
        pstyle(p1) ///
        xline(0) drop(_cons) legend(off) xtitle(Coefficient) ///
        note("Starting in 2013 for PE Takeover as Outcome" "Starting in 2009 for PE Takeover as Cause")
    When I run the code for my coefficient plot, I receive this image, attached:
    Click image for larger version

Name:	noncompetition_takeover_coefficients.jpg
Views:	1
Size:	23.9 KB
ID:	1769677


    The top and the bottom three confidence intervals are where PE takeover is the outcome. The four confidence intervals where it says "treat_by_post" are where PE takeover is the "cause". The first confidence interval line in the "treat_by_post" section corresponds to "franchisee_noncompete", the second corresponds to "right_to_purchase", etc.

    Is it possible to make the confidence interval lines in the "treat_by_post" section show up under a different color with the restraint that they correspond to? That is, there should be two lines (one for cause, the other for outcome) in the area marked by "Franchisee Bound by Noncompete", two lines in the area marked "Right to Purchase Assets", so on and so forth? Thanks for your help in advance.

  • #2
    Data example? See FAQ Advice # 12 for details on how to provide one. Note that coefplot is from SSC and reghdfe is from https://github.com/sergiocorreia/reghdfe.

    Comment


    • #3
      Hi Andrew, thanks for the response. Thanks for clarifying where reghdfe is from, I honestly didn't know. Here's a data example:

      Code:
      fruns    year    treat_by_post    franchisee_noncompete    right_to_purchase    right_1st_refusal    excl_dealing
      10012    2009    0    1    1    1    1
      10012    2010    0    0    0    0    0
      10012    2011    0    0    0    0    0
      10012    2012    0    0    1    0    0
      10012    2013    0    0    1    0    1
      10012    2014    0    0    1    1    0
      10012    2015    0    0    1    1    1
      10012    2016    0    0    1    1    0
      10012    2017    0    0    1    0    1
      10012    2018    0    1    1    1    1
      10012    2019    0    1    1    1    1
      10012    2020    0    0    0    0    0
      10012    2021    0    1    1    0    1
      10012    2022    0    1    1    1    1
      10012    2023    0    1    1    1    1
      10023    2009    0    0    1    1    0
      10023    2010    0    0    1    1    0
      10023    2011    0    0    1    1    0
      10023    2012    0    0    1    1    0
      10023    2013    0    0    1    1    0
      10023    2014    0    0    1    1    0
      10023    2015    0    0    1    1    0
      10023    2016    0    0    1    1    0
      10023    2017    0    0    1    1    0
      10023    2018    0    0    1    1    0
      10023    2019    0    0    1    1    0
      10023    2020    0    0    1    1    0
      10023    2021    1    0    1    1    0
      10023    2022    1    0    1    1    0
      10023    2023    1    0    1    1    0
      10036    2009    0    0    1    1    1
      10036    2010    0    0    1    1    1
      10036    2011    0    0    1    1    1
      10036    2012    0    0    1    1    1
      10036    2013    0    1    1    1    1
      10036    2014    1    0    1    0    0
      10036    2015    1    1    1    1    1
      10036    2016    1    1    1    1    1
      10036    2017    1    1    1    1    1
      10036    2018    1    1    1    1    1
      10036    2019    1    1    1    1    1
      10036    2020    1    1    1    1    1
      10036    2021    1    1    1    1    1
      10036    2022    1    1    1    1    1
      10036    2023    1    1    1    1    1


      Comment


      • #4
        Is this what you want? While it is possible to group the CIs positionally, here the colors and numbering define the groups.

        Code:
        * Example generated by -dataex-. For more info, type help dataex
        clear
        input int(fruns year) byte(treat_by_post franchisee_noncompete right_to_purchase right_1st_refusal excl_dealing)
        10012 2009 0 1 1 1 1
        10012 2010 0 0 0 0 0
        10012 2011 0 0 0 0 0
        10012 2012 0 0 1 0 0
        10012 2013 0 0 1 0 1
        10012 2014 0 0 1 1 0
        10012 2015 0 0 1 1 1
        10012 2016 0 0 1 1 0
        10012 2017 0 0 1 0 1
        10012 2018 0 1 1 1 1
        10012 2019 0 1 1 1 1
        10012 2020 0 0 0 0 0
        10012 2021 0 1 1 0 1
        10012 2022 0 1 1 1 1
        10012 2023 0 1 1 1 1
        10023 2009 0 0 1 1 0
        10023 2010 0 0 1 1 0
        10023 2011 0 0 1 1 0
        10023 2012 0 0 1 1 0
        10023 2013 0 0 1 1 0
        10023 2014 0 0 1 1 0
        10023 2015 0 0 1 1 0
        10023 2016 0 0 1 1 0
        10023 2017 0 0 1 1 0
        10023 2018 0 0 1 1 0
        10023 2019 0 0 1 1 0
        10023 2020 0 0 1 1 0
        10023 2021 1 0 1 1 0
        10023 2022 1 0 1 1 0
        10023 2023 1 0 1 1 0
        10036 2009 0 0 1 1 1
        10036 2010 0 0 1 1 1
        10036 2011 0 0 1 1 1
        10036 2012 0 0 1 1 1
        10036 2013 0 1 1 1 1
        10036 2014 1 0 1 0 0
        10036 2015 1 1 1 1 1
        10036 2016 1 1 1 1 1
        10036 2017 1 1 1 1 1
        10036 2018 1 1 1 1 1
        10036 2019 1 1 1 1 1
        10036 2020 1 1 1 1 1
        10036 2021 1 1 1 1 1
        10036 2022 1 1 1 1 1
        10036 2023 1 1 1 1 1
        end
        
        local restraints "franchisee_noncompete right_to_purchase right_1st_refusal excl_dealing"
        estimates clear
        *** Regression for Takeover as Cause
        local i = 1
        foreach restraint of local restraints {
        reghdfe `restraint' treat_by_post, abs(fruns year) vce(cluster fruns)
        estimates store er_`i'
        local i = `i' + 1
        }
        
        *** Regression for Takeover as Outcome
        local i = 1
        foreach restraint of local restraints {
        keep if year >= 2013
        reghdfe treat_by_post `restraint', abs(fruns year) vce(cluster fruns)
        estimates store ep_`i'
        local i = `i' + 1
        }
        
        * Coefplot for Non-Competition Restraints
        coefplot ///
            (*_1, label("`: variable label franchisee_noncompete'")) ///
            (*_2, label("`: variable label right_to_purchase'")) ///
            (*_3,  label("`: variable label right_1st_refusal'")) ///
            (*_4,  label("`: variable label excl_dealing'")), ///
             aseq swapnames xline(0) drop(_cons) legend(off) xtitle(Coefficient) ///
            eqrename(ep_1= "1" er_1="1" ep_2= "2" er_2="2" ep_3= "3" er_3="3" er_4= "4" ep_4="4") ///
            note("Starting in 2013 for PE Takeover as Outcome" "Starting in 2009 for PE Takeover as Cause")

        Click image for larger version

Name:	Graph.png
Views:	1
Size:	59.2 KB
ID:	1769711

        Comment


        • #5
          Thank you so much!! This is very close to what I'm looking for. Is there a way to make the blue interval lines go right next to each other, and the red interval lines go next to each other, and so on?

          Comment


          • #6
            For some reason, I can group 3 together, but if I try all 4, it reverts to grouping by coefficient names. I do not have time to figure it out. The following gets what you want and consistent spacing, but is only a second-best solution.

            Code:
            * Example generated by -dataex-. For more info, type help dataex
            clear
            input int(fruns year) byte(treat_by_post franchisee_noncompete right_to_purchase right_1st_refusal excl_dealing)
            10012 2009 0 1 1 1 1
            10012 2010 0 0 0 0 0
            10012 2011 0 0 0 0 0
            10012 2012 0 0 1 0 0
            10012 2013 0 0 1 0 1
            10012 2014 0 0 1 1 0
            10012 2015 0 0 1 1 1
            10012 2016 0 0 1 1 0
            10012 2017 0 0 1 0 1
            10012 2018 0 1 1 1 1
            10012 2019 0 1 1 1 1
            10012 2020 0 0 0 0 0
            10012 2021 0 1 1 0 1
            10012 2022 0 1 1 1 1
            10012 2023 0 1 1 1 1
            10023 2009 0 0 1 1 0
            10023 2010 0 0 1 1 0
            10023 2011 0 0 1 1 0
            10023 2012 0 0 1 1 0
            10023 2013 0 0 1 1 0
            10023 2014 0 0 1 1 0
            10023 2015 0 0 1 1 0
            10023 2016 0 0 1 1 0
            10023 2017 0 0 1 1 0
            10023 2018 0 0 1 1 0
            10023 2019 0 0 1 1 0
            10023 2020 0 0 1 1 0
            10023 2021 1 0 1 1 0
            10023 2022 1 0 1 1 0
            10023 2023 1 0 1 1 0
            10036 2009 0 0 1 1 1
            10036 2010 0 0 1 1 1
            10036 2011 0 0 1 1 1
            10036 2012 0 0 1 1 1
            10036 2013 0 1 1 1 1
            10036 2014 1 0 1 0 0
            10036 2015 1 1 1 1 1
            10036 2016 1 1 1 1 1
            10036 2017 1 1 1 1 1
            10036 2018 1 1 1 1 1
            10036 2019 1 1 1 1 1
            10036 2020 1 1 1 1 1
            10036 2021 1 1 1 1 1
            10036 2022 1 1 1 1 1
            10036 2023 1 1 1 1 1
            end
            
            local restraints "franchisee_noncompete right_to_purchase right_1st_refusal excl_dealing"
            estimates clear
            *** Regression for Takeover as Cause
            local i = 1
            foreach restraint of local restraints {
            reghdfe `restraint' treat_by_post, abs(fruns year) vce(cluster fruns)
            estimates store er_`i'
            local i = `i' + 1
            }
            
            *** Regression for Takeover as Outcome
            local i = 1
            foreach restraint of local restraints {
            keep if year >= 2013
            reghdfe treat_by_post `restraint', abs(fruns year) vce(cluster fruns)
            estimates store ep_`i'
            local i = `i' + 1
            }
            
            
            * Coefplot for Non-Competition Restraints
            coefplot ///
                (*_1, label("`: variable label franchisee_noncompete'")) ///
                (*_2, label("`: variable label right_to_purchase'")) ///
                (*_3,  label("`: variable label right_1st_refusal'")) ///
                (*_4,  label("`: variable label excl_dealing'")), ///
                 aseq  xline(0) drop(_cons) legend(off) xtitle(Coefficient) eqlab(, angle(vert)) ///
                 eqrename(ep_1=" " er_1="1" ep_2= "  " er_2="2" ep_3= "   " er_3="3" ep_4= "    " er_4="4") ///
                note("Starting in 2013 for PE Takeover as Outcome" "Starting in 2009 for PE Takeover as Cause")
            Click image for larger version

Name:	Graph.png
Views:	1
Size:	65.2 KB
ID:	1769724

            Comment


            • #7
              This is actually perfect! Thank you so much Andrew. I really appreciate your time and effort to help me out.

              Comment

              Working...
              X