I need to run multiple analyses where I keep adding more covariates to the model. I want to create a graph that would show the predicted probabilities of the main predictor variable, comparatively in those models.
Code:
* Example generated by -dataex-. To install: ssc install dataex clear input float(num_id death) double numeric_variable long categorical_variable 74 0 12.908 2 196 0 11.938 2 245 0 11.95 2 248 0 12.887 2 358 0 14.081 2 381 1 12.522 1 383 1 11.96 1 388 1 12.319 1 423 1 11.021 2 438 0 12.528 2 485 0 12.872 2 486 0 19.022 1 726 1 11.857 2 786 0 12.599 1 797 0 12.042 2 869 0 12.477 2 936 0 11.874 2 941 0 12.515 1 953 0 12.249 1 958 0 14.402 2 973 1 11.594 2 1016 0 13.465 2 1057 0 12.855 2 1073 0 13.538 2 1166 1 11.466 1 1256 1 11.803 2 1297 1 12.854 2 1313 1 12.001 1 1338 0 11.468 1 1363 0 14.151 1 1418 1 11.796 2 1455 1 12.334 1 1598 1 11.57 2 1617 0 12.148 2 1666 0 12.034 1 1697 0 12.916 1 1729 0 11.523 1 1754 0 11.497 1 1808 0 12.669 1 1848 0 11.467 2 1851 0 12.702 2 1876 0 12.205 2 1885 0 11.52 2 1992 0 11.701 1 2164 0 13.033 2 2278 1 12.499 2 2405 0 11.449 2 2466 0 12.192 1 2469 0 14.108 2 2505 0 12 1 2566 0 12.017 1 2598 0 11.459 1 2608 0 12.305 1 2619 0 13.217 1 2725 0 13.573 2 2736 0 12.789 2 2763 0 11.678 2 2798 0 13.111 2 2815 0 12.637 1 2833 0 11.826 2 2848 0 11.372 1 2873 0 11.55 2 2884 0 13.719 2 2900 0 11.383 2 2911 0 13.545 2 2921 0 12.395 2 2923 0 11.743 2 2934 0 13.961 2 2942 0 12.351 2 2953 0 14.234 2 3043 0 12.529 2 3054 0 13.733 1 3071 0 9.651 2 3090 0 11.929 2 3155 0 12.733 2 3164 0 12.999 2 3173 0 11.996 2 3209 0 11.989 2 3287 0 12.491 2 3325 0 12.712 2 3327 0 13.296 2 3388 0 12.166 2 3409 0 12.897 2 3411 0 12.291 2 3416 0 13.65 2 3417 0 12.913 2 3476 0 12 1 3479 0 11.604 2 3480 0 11.982 2 3781 0 12.866 2 3797 0 12.777 2 3809 0 12.125 1 3846 0 15.023 1 3917 0 11.613 2 3918 0 12.855 2 3948 0 13.18 2 3958 0 12.13 2 3963 0 13.95 2 3980 0 12.971 2 3995 0 14.037 2 end label values death YesNo label def YesNo 0 "No", modify label def YesNo 1 "Yes", modify label values categorical_variable for_profit_status label def for_profit_status 1 "No", modify label def for_profit_status 2 "Yes", modify
The commands that I have used:
logistic death i.categorical_variable
margins categorical_variable
marginsplot, name(model_1)
logistic death i.categorical_variable numeric_variable
margins categorical_variable
marginsplot, name(model_2)
graph combine model_1 model_2
Instead of two graphs side by side, I would like to have both lines (preferably in different colors) within the same graph since X and Y are the same. Plus, I would like to have the numbers correspond to each other so one can compare two models easily.
Thanks a lot.
Array
0 Response to Combine multiple graphs within one graph
Post a Comment