Hi,
I'm trying to do a simulation analysis using Bernoulli trials to show the impacts of an instrumental variable on an outcome at varying levels of exposure misclassification, but am having trouble getting the axes to work. I was hoping to show three consecutive line plots that sort of build on each other and show the relationship between them all: 1. First, just showing the impact of the IV on the outcome, 2. Second, showing the impact of the IV on the exposure, and 3. Third, a line plot trying to see if you could recover the "true" IV-outcome value by dividing the previous two coefficients, or if the misclassification distorted things.
I think I have the first two plots set. However, the third plot (the "Recovered" IV) has some values WAY off the scale of the first two plot. I would like to keep the same scale as the first two plots (from -0.5-0.5), but can't seem to get the yscale option to narrow the axes below the range of values. Is there a way to sort of 'zoom' in on a plot, or re-scale a plot even if there are lines that go off/outside the plot area? I tried to attach a picture of my thought below

Best,
David K
I'm trying to do a simulation analysis using Bernoulli trials to show the impacts of an instrumental variable on an outcome at varying levels of exposure misclassification, but am having trouble getting the axes to work. I was hoping to show three consecutive line plots that sort of build on each other and show the relationship between them all: 1. First, just showing the impact of the IV on the outcome, 2. Second, showing the impact of the IV on the exposure, and 3. Third, a line plot trying to see if you could recover the "true" IV-outcome value by dividing the previous two coefficients, or if the misclassification distorted things.
I think I have the first two plots set. However, the third plot (the "Recovered" IV) has some values WAY off the scale of the first two plot. I would like to keep the same scale as the first two plots (from -0.5-0.5), but can't seem to get the yscale option to narrow the axes below the range of values. Is there a way to sort of 'zoom' in on a plot, or re-scale a plot even if there are lines that go off/outside the plot area? I tried to attach a picture of my thought below
Code:
clear input float(sensitivity specificity Outcome_Instrument Exposure_Instrument N Recovered) 1 1 .1979524 -.4920335 1 -.4023149 2 2 .19987273 -.4819921 2 -.4146805 3 3 .19539507 -.4677771 3 -.4177098 4 4 .20104007 -.4597873 4 -.4372458 5 5 .2047229 -.4529672 5 -.4519597 6 6 .20243862 -.4361559 6 -.4641428 7 7 .1974992 -.4341585 7 -.4549012 8 8 .19582623 -.4173126 8 -.4692555 9 9 .2010546 -.4110738 9 -.4890961 10 10 .1967768 -.40045735 10 -.4913802 11 11 .19767523 -.3924873 11 -.50364745 12 12 .2008805 -.3847532 12 -.52210224 13 13 .19796485 -.3689476 13 -.5365663 14 14 .1999267 -.3634688 14 -.5500519 15 15 .1994809 -.3563249 15 -.5598286 16 16 .2018367 -.3480236 16 -.5799513 17 17 .20599146 -.3277986 17 -.6284086 18 18 .19865766 -.3184249 18 -.623876 19 19 .20011953 -.3098217 19 -.6459183 20 20 .2029089 -.30025 20 -.6757999 21 21 .2080888 -.29368246 21 -.7085503 22 22 .1995148 -.27897725 22 -.7151652 23 23 .1976077 -.27036616 23 -.7308891 24 24 .19988205 -.26658177 24 -.7497964 25 25 .19182897 -.2517857 25 -.761874 26 26 .20020168 -.24253325 26 -.8254607 27 27 .1965113 -.22702724 27 -.8655847 28 28 .19766107 -.2154652 28 -.9173689 29 29 .2008289 -.2027534 29 -.9905081 30 30 .1916174 -.20003997 30 -.9578956 31 31 .1966161 -.191459 31 -1.0269357 32 32 .198951 -.18841814 32 -1.0559015 33 33 .204063 -.16891593 33 -1.2080745 34 34 .20354807 -.1616527 34 -1.259169 35 35 .1991173 -.14868827 35 -1.3391595 36 36 .19947542 -.14301188 36 -1.394817 37 37 .20163818 -.1326206 37 -1.5204136 38 38 .19430883 -.12471799 38 -1.5579857 39 39 .20011443 -.1109534 39 -1.8035898 40 40 .20225348 -.09691685 40 -2.0868762 41 41 .20048143 -.09399413 41 -2.1329145 42 42 .19841333 -.08790667 42 -2.2570908 43 43 .1984415 -.07816829 43 -2.538645 44 44 .20107444 -.06200787 44 -3.242725 45 45 .1953067 -.05473157 45 -3.568447 46 46 .20268 -.04104 46 -4.938597 47 47 .19368915 -.031254377 47 -6.197185 48 48 .20088837 -.019738225 48 -10.17763 49 49 .1990907 -.009663387 49 -20.60258 50 50 .2025213 .002430746 50 83.31651 51 51 .19561063 .01428216 51 13.696152 52 52 .1941956 .020707596 52 9.377988 53 53 .2012539 .02786657 53 7.222056 54 54 .20316187 .04094384 54 4.961964 55 55 .20232117 .04598163 55 4.4000435 56 56 .2005032 .06347003 56 3.1590216 57 57 .1951805 .06714247 57 2.90696 58 58 .20233296 .08042106 58 2.51592 59 59 .2021741 .08476795 59 2.38503 60 60 .19646654 .09524527 60 2.0627432 61 61 .19698767 .10367248 61 1.900096 62 62 .19643863 .11610924 62 1.6918433 63 63 .1971507 .12589702 63 1.565968 64 64 .1996607 .14129843 64 1.4130427 65 65 .20161334 .15394667 65 1.309631 66 66 .1998442 .1558119 66 1.282599 67 67 .2017871 .16800527 67 1.201076 68 68 .194406 .1838346 68 1.057505 69 69 .2035362 .19539367 69 1.0416725 70 70 .19774595 .2040449 70 .9691296 71 71 .1988621 .2163826 71 .9190301 72 72 .1973204 .222218 72 .8879586 73 73 .19914524 .23912475 73 .832809 74 74 .1982089 .24112913 74 .8220031 75 75 .199579 .247588 75 .8060932 76 76 .19763863 .26586318 76 .7433847 77 77 .2002576 .26751867 77 .7485743 78 78 .193235 .27984953 78 .6904961 79 79 .2020276 .29250795 79 .6906738 80 80 .20245902 .3024369 80 .6694257 81 81 .19859692 .3086454 81 .643447 82 82 .19645767 .3274992 82 .5998722 83 83 .19474263 .3249867 83 .5992326 84 84 .1981202 .3374746 84 .58706695 85 85 .20534445 .3510537 85 .5849374 86 86 .19819283 .3587771 86 .55241215 87 87 .20123222 .37194705 87 .54102385 88 88 .20099346 .381962 88 .5262132 89 89 .19806717 .3966859 89 .4993048 90 90 .20021266 .3975544 90 .5036107 91 91 .1971716 .41239235 91 .4781165 92 92 .1970549 .4160435 92 .4736401 93 93 .20152925 .43402845 93 .4643227 94 94 .20064393 .44297835 94 .452943 95 95 .2001314 .4509297 95 .4438195 96 96 .20209825 .459106 96 .4401995 97 97 .1991401 .4710231 97 .422782 98 98 .1967469 .47760025 98 .4119489 99 99 .19842264 .4916959 99 .4035475 end // OUTCOME graph twoway line Outcome_Instrument N /// || ,legend(on position(6) row(1) label(1 "Outcome-Instrument")) /// xlabel(0 "0%" 10 "10%" 20 "20%" 30 "30%" 40 "40%" 50 "50%" 60 "60%" 70 "70%" 80 "80%" 90 "90%" 100 "100%") /// ylabel(-0.5(0.1)0.5) /// yscale(range(-0.5 0.5)) /// text(0.4 10 "E+ Truth", box bcolor(gs16) size(small)) /// yline(0.4) /// text(0.2 10 "IV Truth", box bcolor(gs16) size(small)) /// yline(0.2) /// xtitle("Sensitivity & Specificity") ytitle("Risk Difference") title("Non-Differential Exposure Misclassification") subtitle("9.9 Million Simulations", size(small)) // OUTCOME + EXPOSURE graph twoway line Outcome_Instrument N /// || line Exposure_Instrument N /// || ,legend(on position(6) row(1) label(1 "Outcome-Instrument") label(2 "Exposure-Instrument")) /// xlabel(0 "0%" 10 "10%" 20 "20%" 30 "30%" 40 "40%" 50 "50%" 60 "60%" 70 "70%" 80 "80%" 90 "90%" 100 "100%") /// ylabel(-0.5(0.1)0.5) /// yscale(range(-0.5 0.5)) /// text(0.4 10 "E+ Truth", box bcolor(gs16) size(small)) /// yline(0.4) /// text(0.2 10 "IV Truth", box bcolor(gs16) size(small)) /// yline(0.2) /// xtitle("Sensitivity & Specificity") ytitle("Risk Difference") title("Non-Differential Exposure Misclassification") subtitle("9.9 Million Simulations", size(small)) // OUTCOME / EXPOSURE == TRUTH? graph twoway line Outcome_Instrument N /// || line Exposure_Instrument N /// || line Recovered N, /// || ,legend(on position(6) row(1) label(1 "Outcome-Instrument") label(2 "Exposure-Instrument") label(3 "Recovered IV?")) /// xlabel(0 "0%" 10 "10%" 20 "20%" 30 "30%" 40 "40%" 50 "50%" 60 "60%" 70 "70%" 80 "80%" 90 "90%" 100 "100%") /// ylabel(-0.5(0.1)0.5) /// yscale(off) /// text(0.4 15 "Truth", box bcolor(gs16)) /// note("9.9 Million Simulations") /// yline(0.4) /// xtitle("Sensitivity & Specificity") ytitle("Risk Difference") title("Risk Differences of Non-Differential Exposure Misclassification")
David K
Comment