{smcl} {* *! version 0.1.0 16sep2021 Tom Palmer}{...} {vieweralsosee "ivonesamplemr" "help ivonesamplemr"}{...} {vieweralsosee "xtile" "help xtile"}{...} {viewerjumpto "Syntax" "ivxtile##syntax"}{...} {viewerjumpto "Description" "ivxtile##description"}{...} {viewerjumpto "Options" "ivxtile##options"}{...} {viewerjumpto "Examples" "ivxtile##examples"}{...} {viewerjumpto "Stored results" "ivxtile##results"}{...} {viewerjumpto "References" "ivxtile##references"}{...} {viewerjumpto "Author" "ivxtile##author"}{...} {title:Title} {p 5} {bf:ivxtile} {hline 2} Perform estimation within quantiles of the first stage residuals prefix command {p_end} {marker syntax}{...} {title:Syntax} {p 8 12 2} {cmd:ivxtile} {cmd:,} {opt par(string)} [{opt sa:ving(filename [, replace])} {opt xtile_options}]{cmd::} {it:iv_cmd} {synoptset 30 tabbed}{...} {synopthdr} {synoptline} {synopt:{opt par:(string)}}Parameter from the {it:iv_cmd} (ivregress, ivreg2, ivmsmm, ivlsmm, ivtsps, ivtsri) to collect{p_end} {synopt:{opt sa:ving(filename [, replace])}}Save the within quantile estimation results to a dataset. Specify {cmd:replace} to overwrite an existing dataset{p_end} {synopt:{opt trace}}View the output from the {cmd:iv_cmd} in each quantile{p_end} {synopt:{opt xtile_options:}}{help xtile##options}{p_end} {marker description}{...} {title:Description} {pstd} {cmd:ivxtile} implements the command specified after the prefix within quantiles of the first stage residuals, as per {help ivxtile##burgess:Burgess et al., 2014}. {marker options}{...} {title:Options} {phang} Please see {help xtile##options} {marker examples}{...} {title:Examples} {pstd}Simulate data with different outcome-exposure relationships; y# outcome, x exposure, g instrumental variable (genotype).{p_end} {phang2}{cmd:.} {stata "use https://raw.githubusercontent.com/remlapmot/ivonesamplemr/main/data/ivmwdata, clear"}{p_end} {pstd}Plot outcome-exposure relationships{p_end} {phang2}{cmd:.} {stata "twoway line y1 x, sort(x)"}{p_end} {phang2}{cmd:.} {stata "twoway line y2 y3 y4 x, sort(x)"}{p_end} {phang2}{cmd:.} {stata "twoway line y5 x, sort(x)"}{p_end} {pstd}Use with different iv commands.{p_end} {phang2}{cmd:.} {stata "ivxtile, nq(5) par(x): ivregress 2sls y2 (x = g)"}{p_end} {phang2}{cmd:.} {stata "ivxtile, nq(10) par(b1): ivtsps y2 (x = g)"}{p_end} {pstd}Some binary outcome examples.{p_end} {phang2}{cmd:.} {stata "use https://raw.githubusercontent.com/remlapmot/ivonesamplemr/main/data/ivbinoutdata, clear"}{p_end} {phang2}{cmd:.} {stata "ivxtile, nq(5) par(b1): ivtsps y (x = z1 z2 z3), link(logadd)"}{p_end} {phang2}{cmd:.} {stata "ivxtile, nq(5) par(b1): ivtsps y (x = z1 z2 z3), link(logmult)"}{p_end} {phang2}{cmd:.} {stata "ivxtile, nq(5) par(b1): ivtsps y (x = z1 z2 z3), link(logit)"}{p_end} {phang2}{cmd:.} {stata "ivxtile, nq(5) par(b1): ivtsri y (x = z1 z2 z3), link(logadd)"}{p_end} {phang2}{cmd:.} {stata "ivxtile, nq(5) par(b1): ivtsri y (x = z1 z2 z3), link(logmult)"}{p_end} {phang2}{cmd:.} {stata "ivxtile, nq(5) par(b1): ivtsri y (x = z1 z2 z3), link(logit)"}{p_end} {phang2}{cmd:.} {stata "ivxtile, nq(5) par(x): ivlsmm y (x = z1 z2 z3)"}{p_end} {phang2}{cmd:.} {stata "ivxtile, nq(5) par(x): ivmsmm y (x = z1 z2 z3)"}{p_end} {pstd}Save the dataset of results.{p_end} {phang2}{cmd:.} {stata "ivxtile, nq(10) par(x) saving(ivxtileres): ivreg2 y2 (x = g)"}{p_end} {marker results}{...} {title:Stored results} {pstd} {cmd:ivxtile} does not store results in either e() or r() but does save the results dataset if the {cmd:saving()} option is specified.{p_end} {marker references}{...} {title:References} {marker burgess}{...} {phang} Burgess S, Davies N, Thompson SG, EPIC-InterAct Consortium. Instrumental variable analysis with a nonlinear exposure-outcome relationship. Epidemiology, 2014, 25, 6, 877-885. {browse "https://doi.org/10.1097/ede.0000000000000161":DOI} {p_end} {marker manxtile}{...} {phang} StataCorp. Stata Base Reference Manual. Release 16. pctile - Creating variable containing percentiles. 2016. {browse "https://www.stata.com/manuals/dpctile.pdf":URL} {p_end} {marker author}{...} {title:Author} {pstd} Tom Palmer, MRC Integrative Epidemiology Unit and Population Health Sciences, University of Bristol, UK. {browse "mailto:tom.palmer@bristol.ac.uk":tom.palmer@bristol.ac.uk}. {pstd} Development takes place on GitHub here {browse "https://github.com/remlapmot/ivonesamplemr"}. {pstd} Please report any bugs or issues you find, either by email or by creating an issue on the GitHub repository here {browse "https://github.com/remlapmot/ivonesamplemr/issues"}. {pstd} I welcome additions to the code, either by email or pull request on GitHub.