Hello
I am trying to create a motivation type pf graph before my main estimation results. I have inflation as my variable and several control groups (dummy = 1,2,3) and 1 treated group (dummy = 0). I want to plot the mean/median over time just to show the trend and i am using the following code.
The issue I am facing is that I want the pre-treatment graph that is values below 0 for all groups to be more like parallel lines or following a similar trend so that after treatment can show how different groups are performing. But I am not able to do that. I generated the following dataset as a reference:
* Example generated by -dataex-. For more info, type help dataex
clear
input str3 country float(year hcpi_a treat year_of_treatment)
"AUS" 2000 10 0 2001
"AUS" 2001 3 0 2001
"AUS" 2002 2 0 2001
"BRA" 2000 5 0 2002
"BRA" 2001 12 0 2002
"BRA" 2002 3 0 2002
"CAN" 2000 4 0 2001
"CAN" 2001 2 0 2001
"CAN" 2002 1 0 2001
"AFG" 2000 11 1 0
"AFG" 2001 8 1 0
"AFG" 2002 5 1 0
"BOL" 2000 9 1 0
"BOL" 2001 5 1 0
"BOL" 2002 6 1 0
"ARG" 2000 4 2 0
"ARG" 2001 3 2 0
"ARG" 2002 3 2 0
"MOZ" 2000 3 2 0
"MOZ" 2001 2 2 0
"MOZ" 2002 4 2 0
"MEX" 2000 2 3 0
"MEX" 2001 1 3 0
"MEX" 2002 5 3 0
"CAM" 2000 6 3 0
"CAM" 2001 4 3 0
"CAM" 2002 5 3 0
end
[/CODE]
Can I please get some help?
I am trying to create a motivation type pf graph before my main estimation results. I have inflation as my variable and several control groups (dummy = 1,2,3) and 1 treated group (dummy = 0). I want to plot the mean/median over time just to show the trend and i am using the following code.
Code:
clear append using "\\Client\H$\Desktop\data\motivation_treated.dta" "\\Client\H$\Desktop\data\motivation_monetaryagg.dta" "\\Client\H$\Desktop\data\motivation_exchange.dta" "\\Client\H$\Desktop\data\motivation_other.dta" gen y_T = year replace y_T = 0 gen T_year=year if y_T == 0 bys country: egen tr_year=median(T_year) gen trr_year=year-tr_year bys trr_year: egen mean_inflation=median(hcpi_a) if treat == 0 bys trr_year: egen mean_inflation_monetary=median(hcpi_a) if treat == 1 bys trr_year: egen mean_inflation_exchange=median(hcpi_a) if treat == 2 bys trr_year: egen mean_inflation_other=median(hcpi_a) if treat == 3 twoway (line mean_inflation trr_year) (line mean_inflation_monetary trr_year) (line mean_inflation_exchange trr_year) (line mean_inflation_other trr_year)
* Example generated by -dataex-. For more info, type help dataex
clear
input str3 country float(year hcpi_a treat year_of_treatment)
"AUS" 2000 10 0 2001
"AUS" 2001 3 0 2001
"AUS" 2002 2 0 2001
"BRA" 2000 5 0 2002
"BRA" 2001 12 0 2002
"BRA" 2002 3 0 2002
"CAN" 2000 4 0 2001
"CAN" 2001 2 0 2001
"CAN" 2002 1 0 2001
"AFG" 2000 11 1 0
"AFG" 2001 8 1 0
"AFG" 2002 5 1 0
"BOL" 2000 9 1 0
"BOL" 2001 5 1 0
"BOL" 2002 6 1 0
"ARG" 2000 4 2 0
"ARG" 2001 3 2 0
"ARG" 2002 3 2 0
"MOZ" 2000 3 2 0
"MOZ" 2001 2 2 0
"MOZ" 2002 4 2 0
"MEX" 2000 2 3 0
"MEX" 2001 1 3 0
"MEX" 2002 5 3 0
"CAM" 2000 6 3 0
"CAM" 2001 4 3 0
"CAM" 2002 5 3 0
end
[/CODE]
Can I please get some help?
Comment