Announcement

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

  • Coefplot interaction term - loop multiple sample, label x axis

    Dear all,

    I am estimating the coefficient of an interaction term for multiple samples. These samples are observations from different ranges of a variable measuring a distance (i.e. 5km, 10km, and so on until 50km).

    I am using coefplot to plot the coefficient estimate for the interaction (dummy*dummy) along with the confidence intervals.

    I want the x axis to display the different values of the distance rather than the interaction. In red in the attached image.

    Here is my code:

    HTML Code:
    local bandwidth 5 10 15 20 25 30 35 40 45 50
    foreach outcome in "outcome1" "outcome2" "outcome3"{
    foreach x of local bandwidth {
        display "`x'"    
        
    regress `outcome' i.dum1##i.dum2 if inrange(distance,-`x',`x')  /*
        */, vce(cluster `cluster') 
        
        est store disd_`x'_`outcome'
    }    
    coefplot (disd_5_`outcome', keep(1.dum1#1.dum2) mcolor(navy) levels(99 95 90)) /*
        */ (disd_10_`outcome', keep(1.dum1#1.dum2) mcolor(navy) levels(99 95 90)) /*
        */ (disd_15_`outcome', keep(1.dum1#1.dum2) mcolor(navy) levels(99 95 90)) /*
        */ (disd_20_`outcome', keep(1.dum1#1.dum2) mcolor(navy) levels(99 95 90)) /*
        */ (disd_25_`outcome', keep(1.dum1#1.dum2) mcolor(navy) levels(99 95 90)) /*
        */ (disd_30_`outcome', keep(1.dum1#1.dum2) mcolor(navy) levels(99 95 90)) /*
        */ (disd_35_`outcome', keep(1.dum1#1.dum2) mcolor(navy) levels(99 95 90)) /*
        */ (disd_40_`outcome', keep(1.dum1#1.dum2) mcolor(navy) levels(99 95 90)) /*
        */ (disd_45_`outcome', keep(1.dum1#1.dum2) mcolor(navy) levels(99 95 90)) /*
        */ (disd_50_`outcome', keep(1.dum1#1.dum2) mcolor(navy) levels(99 95 90)) /*
        */ , yline(0) graphregion(color(white)) bgcolor(white) legend(off) label vertical /*
         yscale(range(-0.1 0.1)) ymtick(-0.1(0.05)0.1) 
    }
    Attached Files

  • #2
    coefplot is from SSC (as you are asked to explain).

    I believe the numbering on the x-axis starts from 1 representing the first marker. So you can try

    Code:
    xlab(1 "5" 2 "10" 3 "15"...)
    where you fill in the rest until 50.

    Comment


    • #3
      Hi Andrew,

      This is not convenient since it changes only what is written in the blue rectangle on the image above. Basically under the blue rectangle is written
      HTML Code:
      1.dum1#1.dum2
      and with your proposition it then writes 5 but not the others. Am I making myself clear?

      coefplot is from SSC. Yes.

      Comment


      • #4
        If you provide a reproducible example (using dataex), I or someone else can try to resolve the issue. I cannot from the top of my head.

        Comment


        • #5
          Andrew, I do not think providing a reproducible example is needed for this question. I will solve the problem and answer the post.

          Comment

          Working...
          X