use ../data/ivmwdata, clear
Moving window estimator
Read in simulated data with different outcome-exposure relationships; y#
outcome, x
exposure, g
instrumental variable (genotype).
Plot outcome-exposure relationships
twoway line y1 x, sort(x)
qui gr export ./img/ivmw-plot-01.svg, replace
twoway line y2 y3 y4 x, sort(x) legend(pos(6) rows(1))
qui gr export ./img/ivmw-plot-02.svg, replace
twoway line y5 x, sort(x)
qui gr export ./img/ivmw-plot-03.svg, replace
Example moving window fits.
window(3950) par(x): ivreg2 y1 (x = g)
ivmw, qui gr export ./img/ivmw-plot-04.svg, replace
Time variable: res_order, 1 to 4000
Delta: 1 unit
(running ivreg2 on estimation sample)
Rolling replications (51): .........10.........20.........30.........40.........50. done
file /var/folders/kt/7xskrb1n4_x2jkd9lt0rhybh0000gp/T//S_56858.000001 saved as .dta format
(rolling: ivreg2)
window(3950) par(x): ivreg2 y2 (x = g)
ivmw, qui gr export ./img/ivmw-plot-05.svg, replace
Time variable: res_order, 1 to 4000
Delta: 1 unit
(running ivreg2 on estimation sample)
Rolling replications (51): .........10.........20.........30.........40.........50. done
file /var/folders/kt/7xskrb1n4_x2jkd9lt0rhybh0000gp/T//S_56866.000001 saved as .dta format
(rolling: ivreg2)
window(3950) par(x): ivreg2 y3 (x = g)
ivmw, qui gr export ./img/ivmw-plot-06.svg, replace
Time variable: res_order, 1 to 4000
Delta: 1 unit
(running ivreg2 on estimation sample)
Rolling replications (51): .........10.........20.........30.........40.........50. done
file /var/folders/kt/7xskrb1n4_x2jkd9lt0rhybh0000gp/T//S_56877.000001 saved as .dta format
(rolling: ivreg2)
window(3950) par(x): ivreg2 y4 (x = g)
ivmw, qui gr export ./img/ivmw-plot-07.svg, replace
Time variable: res_order, 1 to 4000
Delta: 1 unit
(running ivreg2 on estimation sample)
Rolling replications (51): .........10.........20.........30.........40.........50. done
file /var/folders/kt/7xskrb1n4_x2jkd9lt0rhybh0000gp/T//S_56882.000001 saved as .dta format
(rolling: ivreg2)
window(3950) par(x): ivreg2 y5 (x = g)
ivmw, qui gr export ./img/ivmw-plot-08.svg, replace
Time variable: res_order, 1 to 4000
Delta: 1 unit
(running ivreg2 on estimation sample)
Rolling replications (51): .........10.........20.........30.........40.........50. done
file /var/folders/kt/7xskrb1n4_x2jkd9lt0rhybh0000gp/T//S_56896.000001 saved as .dta format
(rolling: ivreg2)
Change window size (e.g. for outcome y2).
window(3750) par(x): ivreg2 y2 (x = g)
ivmw, window(3000) par(x): ivreg2 y2 (x = g)
ivmw, window(2000) par(x): ivreg2 y2 (x = g)
ivmw, window(1000) par(x): ivreg2 y2 (x = g) ivmw,
Save the moving window dataset.
window(3950) par(x) saving(ivmw): ivreg2 y2 (x = g) ivmw,
Use different iv commands.
window(3950) par(x): ivregress 2sls y (x = z1 z2 z3)
ivmw, window(3950) par(x): ivregress liml y (x = z1 z2 z3)
ivmw, window(3950) par(x): ivregress gmm y (x = z1 z2 z3)
ivmw, window(3950) par(x): ivlsmm y (x = z1 z2 z3)
ivmw, window(3950) par(x): ivmsmm y (x = z1 z2 z3)
ivmw, window(3950) par(b1): ivtsps y (x = z1 z2 z3)
ivmw, window(3950) par(b1): ivtsps y (x = z1 z2 z3), link(logadd)
ivmw, window(3950) par(b1): ivtsps y (x = z1 z2 z3), link(logmult)
ivmw, window(3950) par(b1): ivtsps y (x = z1 z2 z3), link(logit)
ivmw, window(3950) par(b1): ivtsri y (x = z1 z2 z3)
ivmw, window(3950) par(b1): ivtsri y (x = z1 z2 z3), link(logadd)
ivmw, window(3950) par(b1): ivtsri y (x = z1 z2 z3), link(logmult)
ivmw, window(3950) par(b1): ivtsri y (x = z1 z2 z3), link(logit) ivmw,