Hello Everyone,
I am having some trouble making clean graphs to visualize my marginal effects estimation. Here's my code and output so far:
And this is the output I get

What I’d like to do is plot a graph with own occupation (variable: ownoccupation) on the x-axis and have two separate lines representing males and females. If anyone has suggestions on how to structure the plot or fix my code, I’d really appreciate it!
Thanks!
I am having some trouble making clean graphs to visualize my marginal effects estimation. Here's my code and output so far:
Code:
mlogit pref_occupation i.ownoccupation i.src i.online i.gender i.education, robust Iteration 0: Log pseudolikelihood = -13282.785 Iteration 1: Log pseudolikelihood = -11668.247 Iteration 2: Log pseudolikelihood = -10981.983 Iteration 3: Log pseudolikelihood = -10884.593 Iteration 4: Log pseudolikelihood = -10873.422 Iteration 5: Log pseudolikelihood = -10870.89 Iteration 6: Log pseudolikelihood = -10870.337 Iteration 7: Log pseudolikelihood = -10870.211 Iteration 8: Log pseudolikelihood = -10870.192 Iteration 9: Log pseudolikelihood = -10870.189 Iteration 10: Log pseudolikelihood = -10870.189 Iteration 11: Log pseudolikelihood = -10870.189 Iteration 12: Log pseudolikelihood = -10870.189 Multinomial logistic regression Number of obs = 16,357 Wald chi2(78) = . Prob > chi2 = . Log pseudolikelihood = -10870.189 Pseudo R2 = 0.1816 --------------------------------------------------------------------------------- | Robust pref_occupation | Coefficient std. err. z P>|z| [95% conf. interval] ----------------+---------------------------------------------------------------- professional | ownoccupation | service | -.8940917 .2847678 -3.14 0.002 -1.452226 -.3359571 other | -1.303323 .1068865 -12.19 0.000 -1.512817 -1.09383 not mentioned | -.3219796 .2028157 -1.59 0.112 -.719491 .0755318 non working | -1.241871 .4696442 -2.64 0.008 -2.162357 -.3213852 | src | non brahmin uc | -.1151701 .119313 -0.97 0.334 -.3490192 .1186791 obc | .2114941 .1654971 1.28 0.201 -.1128743 .5358625 sc | .0286448 .1991675 0.14 0.886 -.3617162 .4190059 st | -.3998422 .2905227 -1.38 0.169 -.9692563 .1695719 not mentioned | -.0100743 .1470363 -0.07 0.945 -.2982601 .2781116 muslim | .3971867 .2161564 1.84 0.066 -.026472 .8208454 | 1.online | -1.04319 .0902244 -11.56 0.000 -1.220026 -.8663531 | gender | female | .4735972 .0769838 6.15 0.000 .3227117 .6244827 | education | graduate | .5282965 .3352096 1.58 0.115 -.1287022 1.185295 masters | .4077709 .3363395 1.21 0.225 -.2514424 1.066984 phd | 1.696606 .357825 4.74 0.000 .9952818 2.39793 not mentioned | -.0639402 .3778484 -0.17 0.866 -.8045095 .676629 | _cons | -2.277654 .3514456 -6.48 0.000 -2.966475 -1.588834 ----------------+---------------------------------------------------------------- government | ownoccupation | service | 2.256257 .2082479 10.83 0.000 1.848099 2.664416 other | -.4361484 .1593607 -2.74 0.006 -.7484897 -.1238071 not mentioned | -.4030562 .2354912 -1.71 0.087 -.8646105 .0584981 non working | .3177995 .4974802 0.64 0.523 -.6572437 1.292843 | src | non brahmin uc | -.4237183 .1890886 -2.24 0.025 -.7943252 -.0531115 obc | .0962057 .2742685 0.35 0.726 -.4413508 .6337621 sc | .4253105 .2965034 1.43 0.151 -.1558254 1.006446 st | -.3310767 .555433 -0.60 0.551 -1.419705 .7575519 not mentioned | -.1749856 .1961516 -0.89 0.372 -.5594357 .2094644 muslim | -.8893363 .6048934 -1.47 0.141 -2.074906 .296233 | 1.online | -2.082103 .1751364 -11.89 0.000 -2.425364 -1.738842 | gender | female | 2.024378 .1558544 12.99 0.000 1.718909 2.329847 | education | graduate | .0242001 .4462439 0.05 0.957 -.8504219 .8988221 masters | .0558391 .4398674 0.13 0.899 -.8062852 .9179634 phd | 1.069088 .4636787 2.31 0.021 .1602942 1.977881 not mentioned | .0806132 .4710325 0.17 0.864 -.8425935 1.00382 | _cons | -3.780747 .473357 -7.99 0.000 -4.70851 -2.852985 ----------------+---------------------------------------------------------------- other | ownoccupation | service | -.2109263 .185686 -1.14 0.256 -.5748643 .1530116 other | .1759044 .080241 2.19 0.028 .0186348 .333174 not mentioned | -.366258 .1419477 -2.58 0.010 -.6444703 -.0880457 non working | -.9108873 .4571337 -1.99 0.046 -1.806853 -.0149217 | src | non brahmin uc | .0322055 .1041606 0.31 0.757 -.1719455 .2363564 obc | -.0185698 .1987093 -0.09 0.926 -.4080329 .3708934 sc | .1857437 .2069245 0.90 0.369 -.2198209 .5913084 st | -.5219803 1.019264 -0.51 0.609 -2.519702 1.475741 not mentioned | .1561023 .109837 1.42 0.155 -.0591742 .3713788 muslim | .8956778 .2795174 3.20 0.001 .3478338 1.443522 | 1.online | -4.551922 .170437 -26.71 0.000 -4.885972 -4.217871 | gender | female | .3822263 .078165 4.89 0.000 .2290258 .5354269 | education | graduate | -.3747503 .2106787 -1.78 0.075 -.787673 .0381724 masters | -.2353686 .2049291 -1.15 0.251 -.6370224 .1662851 phd | -.8926128 .2627813 -3.40 0.001 -1.407655 -.3775709 not mentioned | -.4444305 .2250407 -1.97 0.048 -.8855023 -.0033588 | _cons | -.9114188 .2198657 -4.15 0.000 -1.342348 -.48049 ----------------+---------------------------------------------------------------- not_specified | ownoccupation | service | -.3150989 .2756285 -1.14 0.253 -.8553208 .2251231 other | -.5405966 .0704786 -7.67 0.000 -.6787322 -.4024611 not mentioned | -.8435431 .1441884 -5.85 0.000 -1.126147 -.560939 non working | -.5368937 .2895279 -1.85 0.064 -1.104358 .0305706 | src | non brahmin uc | -.1776186 .1059914 -1.68 0.094 -.3853579 .0301208 obc | .0288179 .1333259 0.22 0.829 -.232496 .2901318 sc | .0086869 .1526999 0.06 0.955 -.2905995 .3079732 st | -.2407253 .1701144 -1.42 0.157 -.5741434 .0926928 not mentioned | .2826444 .2263054 1.25 0.212 -.1609061 .7261949 muslim | .1901878 .1558986 1.22 0.222 -.1153677 .4957434 | 1.online | 18.34347 .069675 263.27 0.000 18.20691 18.48003 | gender | female | .7931785 .0615426 12.89 0.000 .6725572 .9137999 | education | graduate | 1.281536 .4198802 3.05 0.002 .4585854 2.104486 masters | 1.432796 .4212902 3.40 0.001 .6070819 2.258509 phd | 1.019674 .4231709 2.41 0.016 .1902739 1.849073 not mentioned | 1.007625 .4262255 2.36 0.018 .1722382 1.843011 | _cons | -21.68844 .4280108 -50.67 0.000 -22.52733 -20.84956 ----------------+---------------------------------------------------------------- not_mentioned | (base outcome) ----------------+---------------------------------------------------------------- not_working | ownoccupation | service | -18.59885 .2942519 -63.21 0.000 -19.17557 -18.02212 other | .6739505 .3224618 2.09 0.037 .041937 1.305964 not mentioned | 1.524725 .6721087 2.27 0.023 .2074164 2.842034 non working | -17.1756 .4124045 -41.65 0.000 -17.9839 -16.3673 | src | non brahmin uc | -.291478 .4326962 -0.67 0.501 -1.139547 .556591 obc | .4237774 .5158964 0.82 0.411 -.5873609 1.434916 sc | -.9972464 1.069131 -0.93 0.351 -3.092705 1.098212 st | -.3204934 1.065815 -0.30 0.764 -2.409452 1.768465 not mentioned | -.5709781 .5770595 -0.99 0.322 -1.701994 .5600376 muslim | .5960823 .6707334 0.89 0.374 -.7185311 1.910696 | 1.online | -.1673457 .3401364 -0.49 0.623 -.8340009 .4993094 | gender | female | -2.216526 .4532037 -4.89 0.000 -3.104789 -1.328263 | education | graduate | -.6996978 .7508931 -0.93 0.351 -2.171421 .7720257 masters | -.5986999 .7498328 -0.80 0.425 -2.068345 .8709454 phd | .3723765 1.035089 0.36 0.719 -1.65636 2.401113 not mentioned | -.9566029 1.051978 -0.91 0.363 -3.018443 1.105237 | _cons | -4.468166 .930433 -4.80 0.000 -6.291782 -2.644551 ---------------------------------------------------------------------------------
Code:
margins gender, at(ownoccupation) Predictive margins Number of obs = 16,357 Model VCE: Robust 1._predict: Pr(pref_occupation==professional), predict(pr outcome(1)) 2._predict: Pr(pref_occupation==government), predict(pr outcome(2)) 3._predict: Pr(pref_occupation==other), predict(pr outcome(3)) 4._predict: Pr(pref_occupation==not_specified), predict(pr outcome(4)) 5._predict: Pr(pref_occupation==not_mentioned), predict(pr outcome(5)) 6._predict: Pr(pref_occupation==not_working), predict(pr outcome(6)) At: 1.ownoccupation = .4530782 (mean) 2.ownoccupation = .0266553 (mean) 3.ownoccupation = .2995048 (mean) 4.ownoccupation = .2112857 (mean) 5.ownoccupation = .0094761 (mean) --------------------------------------------------------------------------------- | Delta-method | Margin std. err. z P>|z| [95% conf. interval] ----------------+---------------------------------------------------------------- _predict#gender | 1#male | .0393393 .0022242 17.69 0.000 .0349799 .0436987 1#female | .053918 .0027566 19.56 0.000 .0485151 .0593208 2#male | .004937 .0006961 7.09 0.000 .0035727 .0063013 2#female | .0285648 .0020404 14.00 0.000 .0245656 .032564 3#male | .0559012 .0022573 24.76 0.000 .051477 .0603255 3#female | .0663534 .0030328 21.88 0.000 .0604092 .0722976 4#male | .0533316 .0024065 22.16 0.000 .0486149 .0580483 4#female | .1184437 .0038993 30.38 0.000 .1108013 .1260862 5#male | .8433899 .0038423 219.50 0.000 .8358591 .8509207 5#female | .7324195 .0054253 135.00 0.000 .7217861 .7430528 6#male | .0031009 .0004947 6.27 0.000 .0021314 .0040705 6#female | .0003006 .0001325 2.27 0.023 .000041 .0005602 ---------------------------------------------------------------------------------
Code:
marginsplot
What I’d like to do is plot a graph with own occupation (variable: ownoccupation) on the x-axis and have two separate lines representing males and females. If anyone has suggestions on how to structure the plot or fix my code, I’d really appreciate it!
Thanks!
Comment