Hi everyone,
I am creating a combined marginsplot (graphs attached as .png) for the data below. The code (below) estimates a logit model for the binary variable defect with gender (0, 1) and treatment (0, 1, 2) as independent variables. I then calculate the marginal effects with respect to gender for treatment and use marginsplot to generate a graph for gender = 0 and another graph for gender = 1 and then finally combine the two graphs next to each other. Even though I set the yvalue range (0 0.8), the two y-axes are not formatted the same - they have different vertical tick marks. Also for the x-axis label, rather than 1.treat and 2.treat I would like "Asymmetric" and "Private (respectively). I'd also like to delete the chart titles. Any help would be much appreciated!
Code:
quietly logit defect i.gender i.treat
margins if gender==0, dydx(treat)
marginsplot, ytitle("Marginal Effect on Pr(Defect)") xtitle("Treatment") yscale(range(0 0.8)) name(a, replace)
margins if gender==1, dydx(treat)
marginsplot, ytitle("Marginal Effect on Pr(Defect)") xtitle("Treatment") yscale(range(0 0.8)) nodraw name(b, replace)
graph combine a b
I am creating a combined marginsplot (graphs attached as .png) for the data below. The code (below) estimates a logit model for the binary variable defect with gender (0, 1) and treatment (0, 1, 2) as independent variables. I then calculate the marginal effects with respect to gender for treatment and use marginsplot to generate a graph for gender = 0 and another graph for gender = 1 and then finally combine the two graphs next to each other. Even though I set the yvalue range (0 0.8), the two y-axes are not formatted the same - they have different vertical tick marks. Also for the x-axis label, rather than 1.treat and 2.treat I would like "Asymmetric" and "Private (respectively). I'd also like to delete the chart titles. Any help would be much appreciated!
Code:
quietly logit defect i.gender i.treat
margins if gender==0, dydx(treat)
marginsplot, ytitle("Marginal Effect on Pr(Defect)") xtitle("Treatment") yscale(range(0 0.8)) name(a, replace)
margins if gender==1, dydx(treat)
marginsplot, ytitle("Marginal Effect on Pr(Defect)") xtitle("Treatment") yscale(range(0 0.8)) nodraw name(b, replace)
graph combine a b
Code:
* Example generated by -dataex-. To install: ssc install dataex clear input byte(treat defect gender age baseline asymm private) str6 catgender str10 cattreat 1 1 1 19 0 1 0 "Female" "Asymmetric" 1 1 1 19 0 1 0 "Female" "Asymmetric" 1 1 1 19 0 1 0 "Female" "Asymmetric" 1 1 1 21 0 1 0 "Female" "Asymmetric" 1 0 1 18 0 1 0 "Female" "Asymmetric" 1 1 1 20 0 1 0 "Female" "Asymmetric" 1 1 0 21 0 1 0 "Male" "Asymmetric" 1 1 0 18 0 1 0 "Male" "Asymmetric" 1 1 0 18 0 1 0 "Male" "Asymmetric" 1 1 1 21 0 1 0 "Female" "Asymmetric" 1 0 1 19 0 1 0 "Female" "Asymmetric" 1 1 0 18 0 1 0 "Male" "Asymmetric" 1 1 1 19 0 1 0 "Female" "Asymmetric" 1 1 1 18 0 1 0 "Female" "Asymmetric" 1 0 0 21 0 1 0 "Male" "Asymmetric" 1 1 1 19 0 1 0 "Female" "Asymmetric" 1 0 0 24 0 1 0 "Male" "Asymmetric" 1 1 0 21 0 1 0 "Male" "Asymmetric" 1 1 1 21 0 1 0 "Female" "Asymmetric" 1 1 0 21 0 1 0 "Male" "Asymmetric" 0 1 1 21 1 0 0 "Female" "Common" 0 1 1 18 1 0 0 "Female" "Common" 0 0 1 18 1 0 0 "Female" "Common" 0 1 1 20 1 0 0 "Female" "Common" 0 1 1 20 1 0 0 "Female" "Common" 0 1 0 19 1 0 0 "Male" "Common" 0 0 0 22 1 0 0 "Male" "Common" 0 0 1 20 1 0 0 "Female" "Common" 0 0 1 19 1 0 0 "Female" "Common" 0 0 0 21 1 0 0 "Male" "Common" 0 1 0 18 1 0 0 "Male" "Common" 0 0 0 18 1 0 0 "Male" "Common" 0 1 1 21 1 0 0 "Female" "Common" 0 0 1 18 1 0 0 "Female" "Common" 0 0 0 21 1 0 0 "Male" "Common" 0 1 0 21 1 0 0 "Male" "Common" 0 1 1 22 1 0 0 "Female" "Common" 0 1 1 20 1 0 0 "Female" "Common" 0 1 1 21 1 0 0 "Female" "Common" 0 0 0 21 1 0 0 "Male" "Common" 2 1 1 23 0 0 1 "Female" "Private" 2 1 0 24 0 0 1 "Male" "Private" 2 1 1 22 0 0 1 "Female" "Private" 2 1 1 21 0 0 1 "Female" "Private" 2 1 1 20 0 0 1 "Female" "Private" 2 1 0 22 0 0 1 "Male" "Private" 2 1 1 22 0 0 1 "Female" "Private" 2 1 1 21 0 0 1 "Female" "Private" 2 1 1 21 0 0 1 "Female" "Private" 2 1 0 23 0 0 1 "Male" "Private" 2 1 1 23 0 0 1 "Female" "Private" 2 1 0 24 0 0 1 "Male" "Private" 2 1 1 23 0 0 1 "Female" "Private" 2 1 1 21 0 0 1 "Female" "Private" 2 1 1 20 0 0 1 "Female" "Private" 2 0 0 22 0 0 1 "Male" "Private" 2 1 1 22 0 0 1 "Female" "Private" 2 1 1 21 0 0 1 "Female" "Private" 2 1 1 21 0 0 1 "Female" "Private" 2 1 0 23 0 0 1 "Male" "Private" 1 1 1 18 0 1 0 "Female" "Asymmetric" 1 1 0 22 0 1 0 "Male" "Asymmetric" 1 1 1 19 0 1 0 "Female" "Asymmetric" 1 1 1 19 0 1 0 "Female" "Asymmetric" 1 0 0 23 0 1 0 "Male" "Asymmetric" 1 1 0 23 0 1 0 "Male" "Asymmetric" 1 0 1 18 0 1 0 "Female" "Asymmetric" 1 1 1 21 0 1 0 "Female" "Asymmetric" 1 1 1 22 0 1 0 "Female" "Asymmetric" 0 0 1 21 1 0 0 "Female" "Common" 0 1 0 21 1 0 0 "Male" "Common" 0 1 1 . 1 0 0 "Female" "Common" 0 1 1 19 1 0 0 "Female" "Common" 0 1 0 21 1 0 0 "Male" "Common" 0 1 1 21 1 0 0 "Female" "Common" 0 1 1 21 1 0 0 "Female" "Common" 0 1 1 21 1 0 0 "Female" "Common" 0 1 1 21 1 0 0 "Female" "Common" 0 0 0 19 1 0 0 "Male" "Common" 1 1 1 21 0 1 0 "Female" "Asymmetric" 1 0 1 19 0 1 0 "Female" "Asymmetric" 1 1 1 21 0 1 0 "Female" "Asymmetric" 1 1 1 20 0 1 0 "Female" "Asymmetric" 1 1 0 19 0 1 0 "Male" "Asymmetric" 1 0 1 20 0 1 0 "Female" "Asymmetric" 1 1 1 20 0 1 0 "Female" "Asymmetric" 1 1 1 21 0 1 0 "Female" "Asymmetric" 1 0 0 18 0 1 0 "Male" "Asymmetric" 1 0 0 19 0 1 0 "Male" "Asymmetric" 1 1 0 24 0 1 0 "Male" "Asymmetric" 0 0 0 22 1 0 0 "Male" "Common" 0 0 1 20 1 0 0 "Female" "Common" 0 0 1 20 1 0 0 "Female" "Common" 0 0 0 18 1 0 0 "Male" "Common" 0 1 1 20 1 0 0 "Female" "Common" 0 0 0 19 1 0 0 "Male" "Common" 0 0 1 21 1 0 0 "Female" "Common" 0 0 1 19 1 0 0 "Female" "Common" 0 1 1 22 1 0 0 "Female" "Common" 0 1 0 23 1 0 0 "Male" "Common" end
Comment