Hi all,

I am currently working on a project examining multiple regulations with regards to companies disclosure. I created a time variable PTA_T0 to indicate the relative time period to the respective event for each company that is a) affected by the regulation and b) not-affected being the control group which I previously matched using psmatch2. My variable of interest is bid-ask spread. My regression looks like this:
Code:
reghdfe basmed_ln difference-in-difference_dummy $controls, absorb($FixedEffects) vce(cluster $cluster_var)
Brief outline of my variables:
basmed_ln: bid-ask spread
difference-in-difference_dummy = 1 for firm-year observations that fall under a specific regulation in year t, 0 otherwise
lnmcap = size of firm (control)
country_id = FE
SIC_year_ID = industry_year FE
id_firm
id_year
PTA_T0 = Relative Time to events
interaction_Perc_Discl = Ratio of regulated firms within an industry*difference-in-difference_dummy
High_Ratio = 1 for firms in industries with above mean regulated firms, 0 otherwise
treatment= equals 1 for all firms being affected by a regulation during the whole sample period, 0 otherwise. All firms with treatment=0 are thus my control observations.

Fixed_effects = country and industry_year
cluster SE = id_firm


Now my actual question:
For one of my sub-analyses I included the interaction term interaction_Perc_Discl=(High_Ratio*difference_in_d ifference_dummy) to test whether firms in an industry with a high portion of regulated firms show different effects than firms in industries with a low share of regulated firms. I do find a significant effect but this might be due to two possible reasons.

To see which of both reasons istrue, I wanted to plot a graph that separately shows the development of bid-ask spread (y-axis) on relative time (x-axis = PTA_T0) for firms that belong to the treatment group (1) and firms that belong to the control group (0).

Below plot was created using twoway but it displayes manually created means for each period instead of the predicted results (including controls, FE and clustered standard errors) of my model:
Code:
twoway (line basmed_mean Time_Relativ if treatment== 1) (line basmed_mean Time_Relativ if treatment== 0), legend(lab (1 "Treated firms") lab(2 "Non treated firms")) ylabel(#4) xlabel(#3, grid) saving(High_Ratio, replace)
High_Ratio.gph


I tried using margins and marginplot, however failed to get it working.

Is it possible to create the above graph that shows the development of my control and treatment group separatly on bid-ask spread with regards to relative time using the predicted values of my model?

Something like
Code:
reghdfe basmed_ln difference-in-difference_dummy $controls if High_Ratio==1, absorb($FixedEffects) vce(cluster $cluster_var)
plot...

Code:
reghdfe basmed_ln difference-in-difference_dummy $controls if High_Ratio==0, absorb($FixedEffects) vce(cluster $cluster_var)
plot...

Code:
* Example generated by -dataex-. To install: ssc install dataex
clear
input float(basmed_ln difference-in-difference_dummy size country_id) long(SIC_year_ID id_firm) int id_year float(PTA_T0 interaction_Perc_Discl High_Ratio treatment)
 -3.320228 0  9.118335 47 200679  164 2006  .           0 0 0
 -2.944439 0  8.715224 47 200613  165 2006  .           0 0 0
-2.1972246 0  8.058643 47 200713  165 2007  .           0 0 0
 -7.971255 1 18.124908 47 200613  166 2006  .  .005948127 0 1
  -7.44259 1   17.7384 47 200813  166 2008  .  .022237407 0 1
 -7.680541 1 18.169271 47 200913  166 2009  .  .024406027 0 1
 -8.211482 1 18.551058 47 201013  166 2010  .   .02747349 0 1
 -9.598933 1 18.551058 47 201113  166 2011  .  .027479546 0 1
  -8.86817 1 18.337801 47 201213  166 2012  .    .0395843 0 1
  -5.61434 0 10.463103  6 200635 3418 2006  .           0 1 0
 -3.265928 0 10.863967  6 201235 3418 2012  .           0 1 0
-4.7416344 0 11.510733  6 200613 3445 2006  .           0 0 0
-2.2550929 0  9.982484  6 201213 3445 2012  .           0 0 0
 -5.861337 0   11.3679  6 200637 3449 2006  .           0 0 0
-3.2056856 0 10.770273  6 201237 3449 2012  .           0 0 0
  -5.61097 0 11.652322  6 200650 3467 2006  .           0 0 0
 -2.850188 0  9.446835  6 201250 3467 2012  .           0 0 0
-4.1208506 0 10.491552  6 200622 3472 2006  .           0 0 0
  -2.56365 0 10.353384  6 201222 3472 2012  .           0 0 0
 -5.182374 0 10.481112  6 200628 3477 2006  .           0 0 0
   -2.5825 0  9.667449  6 201228 3477 2012  .           0 0 0
 -5.924637 0   10.6145  6 200628 3549 2006  .           0 0 0
 -2.759109 0  9.506957  6 201228 3549 2012  .           0 0 0
 -5.151962 0  10.96863  6 200628 3606 2006  .           0 0 0
-4.5717063 0 12.502864  6 201228 3627 2012  .           0 0 0
 -3.834311 0 11.251067  3 200751 3663 2007  .           0 0 0
 -2.953926 0   11.1325  3 200951 3663 2009  .           0 0 0
-3.2148714 0 11.243476  3 201251 3663 2012  .           0 0 0
 -3.256233 0 11.169773  3 200715 3694 2007  .           0 0 0
-3.1964736 0 10.797144  3 200815 3694 2008  .           0 0 0
         . 0 10.923958  3 200915 3694 2009  .           0 0 0
  -4.21952 0 10.312646  3 201215 3694 2012  .           0 0 0
 -3.336196 0 12.663836 46 200610 3714 2006 -1           0 0 1
-3.2883964 1  11.02832 46 200810 3714 2008  1   .02106361 0 1
 -3.207766 0 11.873937 46 200673 3776 2006 -1           0 0 1
 -3.633952 0 11.526227 46 200773 3776 2007  0           0 0 1
 -6.910086 0 15.655524 47 200820 3792 2008  .           0 0 0
 -7.381951 0 15.962542 47 200920 3792 2009  .           0 0 0
 -3.894156 0 12.195345 46 200610 3989 2006 -1           0 0 1
 -3.417225 1 10.380715 46 200810 3989 2008  1   .02106361 0 1
 -3.336637 1  11.12253 46 200910 3989 2009  2  .011502698 0 1
  -3.63043 1  11.12253 46 201010 3989 2010  .    .4587699 1 1
-3.6756494 1  11.12253 46 201110 3989 2011  .    .4587918 1 1
-3.4499886 1 10.845836 46 201210 3989 2012  .  .014759017 0 1
         . 0  13.49822 47 200636 4074 2006  .           0 0 0
 -8.277412 0 16.237894 47 200736 4198 2007  .           0 0 0
 -7.057416 0 15.121365 47 201236 4198 2012  .           0 1 0
-4.5720286 0 11.770842  5 200244 4251 2002  .           0 0 1
  -5.05741 0 13.605292  5 200644 4251 2006 -1           0 0 1
 -5.437183 0 13.805799  5 200744 4251 2007  0           0 0 1
 -4.970325 1 13.208112  5 200844 4251 2008  1 .0032726014 0 1
 -4.785635 1  13.66624  5 200944 4251 2009  2  .003792791 0 1
 -4.950415 1  13.66624  5 201044 4251 2010  . .0043469896 0 1
 -5.146007 1  13.66624  5 201144 4251 2011  .  .005584912 0 1
 -5.676829 1 13.772735 46 201214 4297 2012  .   .13012215 0 1
         . 0 14.390542 23 200544 4417 2005  .           0 0 0
 -4.827085 0 14.003877  5 200549 4561 2005  .           0 1 0
-3.5459104 0  14.14124  5 201249 4561 2012  .           0 0 0
         . 0         .  5 200040 4569 2000  .           0 0 0
         . 0 12.650236  5 200140 4569 2001  .           0 0 0
         . 0 12.605046  5 200240 4569 2002  .           0 0 0
         . 0 12.693962  5 200340 4569 2003  .           0 0 0
         . 0 15.043018  5 200440 4569 2004  .           0 0 0
 -6.102965 0  13.64866  5 200540 4569 2005  .           0 0 0
   -6.5815 0  16.35932  5 200640 4569 2006  .           0 0 0
 -7.474796 0 16.402273  5 200740 4569 2007  .           0 0 0
 -6.865859 0 15.567888  5 200840 4569 2008  .           0 0 0
 -7.422154 0 16.231985  5 200940 4569 2009  .           0 0 0
 -7.258422 0 16.231985  5 201040 4569 2010  .           0 0 0
         . 0 16.231985  5 201140 4569 2011  .           0 0 0
         . 0  15.55035  5 201240 4569 2012  .           0 0 0
-4.6756706 0 12.397792  5 200030 4570 2000  .           0 0 0
 -5.010227 0 12.828575  5 200330 4570 2003  .           0 0 0
 -5.388084 0  13.41636  5 200430 4570 2004  .           0 0 0
 -5.108953 0 14.102242  5 200530 4570 2005  .           0 0 0
 -5.628379 0 16.714933  5 200020 4575 2000  .           0 0 0
 -6.536502 0 19.405006  5 201220 4575 2012  .           0 0 0
-1.1249635 0  6.768493  5 200120 4605 2001  .           0 0 0
-2.2943718 0  7.649693  5 200420 4605 2004  .           0 0 0
 -2.594769 0  8.922658  5 200520 4605 2005  .           0 0 0
-1.9259722 0  7.922986  5 200620 4605 2006  .           0 0 0
 -3.854764 0  9.464983  5 200720 4605 2007  .           0 0 0
 -4.391457 0   9.43612  5 200820 4605 2008  .           0 0 0
-2.3013039 0 10.030869  5 201220 4605 2012  .           0 0 0
 -5.793928 0 11.161948  5 200233 4614 2002  .           0 0 0
 -5.867146 0 11.589887  5 200333 4614 2003  .           0 0 0
 -5.466807 0  11.42081  5 200433 4614 2004  .           0 0 0
 -4.872102 0  11.11543  5 200533 4614 2005  .           0 0 0
 -4.558668 0 11.626254  5 200633 4614 2006  .           0 0 0
-4.4389977 0 12.381034  5 200733 4614 2007  .           0 0 0
 -3.968369 0 12.275524  5 200833 4614 2008  .           0 0 0
-1.9124888 0  8.454892  5 200487 4633 2004  .           0 0 0
-2.5670595 0  10.00211  5 200587 4633 2005  .           0 0 0
-2.4566245 0 10.342613  5 200687 4633 2006  .           0 0 0
  -.904404 0  10.89533  5 200987 4633 2009  .           0 0 0
 -2.629685 0  10.89533  5 201087 4633 2010  .           0 0 0
 -1.820469 0  10.89533  5 201187 4633 2011  .           0 0 0
  -.328504 0 11.275835  5 201287 4633 2012  .           0 1 0
 -.6683375 0  11.41812  5 200050 4640 2000  .           0 0 0
-2.5218875 0 11.557832  5 200150 4640 2001  .           0 0 0
end