Notice: On April 23, 2014, Statalist moved from an email list to a forum, based at statalist.org.

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

From |
"Schaffer, Mark E" <M.E.Schaffer@hw.ac.uk> |

To |
"statalist@hsphsun2.harvard.edu" <statalist@hsphsun2.harvard.edu> |

Subject |
st: RE: About weakiv |

Date |
Thu, 19 Dec 2013 11:57:34 +0000 |

Tak Wai, Does the issue come up when you don't use the -robust- version? You could double-check in that case against -condivreg-, which will report the CLR stat but only for the iid case. If it's specific to -robust-, maybe have a look at the Finlay-Magnusson 2009 SJ paper cited in the weakiv help file. They say at one point that: " For linear IV models under homoskedasticity, Andrews, Moreira, and Stock (2007) provide a formula for computing the p-value function of the CLR test (which is embedded in the condivreg command). Although this is not the correct p-value function when homoskedasticity is violated, our simulations indicate that it provides a good approximation." --Mark > -----Original Message----- > From: owner-statalist@hsphsun2.harvard.edu [mailto:owner- > statalist@hsphsun2.harvard.edu] On Behalf Of Chau Tak Wai > Sent: 19 December 2013 08:35 > To: statalist@hsphsun2.harvard.edu > Subject: st: About weakiv > > Dear Statalisters, > > I have a question about weakiv. I have tried to run some simulations to > understand the performance of CLR test. But in the following code with > 15 instruments and 1 endogenous regressor, the result seems to be far > from what it should be. I cannot spot the error of my code. So I would > like to ask if it's the problem of my code or a bug in the procedure. > > I may have coded things badly, so advice is welcome! > > Thank you very much in advance! > > The code is as follows: > > capture program drop sim_iv_clr_15 > program define sim_iv_clr_15, rclass > version 11 > syntax [, obs(integer 100) mu2k(real 3) b(real 1) rho(real 0.5) ] > drop _all > set obs `obs' > tempvar y x z1 z2 z3 z4 z5 z6 z7 z8 z9 z10 z11 z12 z13 z14 z15 u > gen `z1' = rnormal(0,1) > gen `z2' = rnormal(0,1) > gen `z3' = rnormal(0,1) > gen `z4' = rnormal(0,1) > gen `z5' = rnormal(0,1) > gen `z6' = rnormal(0,1) > gen `z7' = rnormal(0,1) > gen `z8' = rnormal(0,1) > gen `z9' = rnormal(0,1) > gen `z10' = rnormal(0,1) > gen `z11' = rnormal(0,1) > gen `z12' = rnormal(0,1) > gen `z13' = rnormal(0,1) > gen `z14' = rnormal(0,1) > gen `z15' = rnormal(0,1) > > gen `u' = rnormal(0,1) > > gen `x' = > sqrt(`mu2k'/`obs')*(`z1'+`z2'+`z3'+`z4'+`z5'+`z6'+`z7'+`z8'+`z9'+`z10'+`z11'+`z12 > '+`z13'+`z14'+`z15')+`u' > gen `y' = `b'*`x'+(`rho')*`u'+sqrt(1-`rho'^2)*rnormal(0,1) > > local z `z1' `z2' `z3' `z4' `z5' `z6' `z7' `z8' `z9' `z10' `z11' `z12' > `z13' `z14' `z15' > *check first stage > regress `x' `z' > return scalar fsf=e(F) > > ivregress 2sls `y' (`x' = `z'), robust > return scalar beta2sls=_b[`x'] > return scalar se2sls=_se[`x'] > > ivregress liml `y' (`x' = `z'), robust > return scalar betaliml=_b[`x'] > return scalar seliml=_se[`x'] > > ivreg2 `y' (`x'=`z' ), fuller(1) robust > return scalar betaf1=_b[`x'] > return scalar sef1=_se[`x'] > > ** check the related tests at null of true value > ivregress 2sls `y' (`x' = `z'), robust > weakiv, null(1.0) small > return scalar clrp=e(clr_p) > return scalar arp=e(ar_p) > return scalar wp=e(wald_p) > > **test at true value - 0.25 > ivregress 2sls `y' (`x' = `z'), robust > weakiv, null(0.75) small > return scalar clrpa=e(clr_p) > return scalar arpa=e(ar_p) > return scalar wpa=e(wald_p) > > **test at true value +0.25 > ivregress 2sls `y' (`x' = `z'), robust > weakiv, null(1.25) small > return scalar clrpb=e(clr_p) > return scalar arpb=e(ar_p) > return scalar wpb=e(wald_p) > > end > > local betatrue 1.0 > local nobs 100 > simulate fsf=r(fsf) beta2sls=r(beta2sls) se2sls=r(se2sls) /* > */ betaliml=r(betaliml) seliml=r(seliml) betaf1=r(betaf1) sef1=r(sef1)/* > */ clrp=r(clrp) arp=r(arp) wp=r(wp) clrpa=r(clrpa) arpa=r(arpa) > wpa=r(wpa) clrpb=r(clrpb) arpb=r(arpb) wpb=r(wpb), /* > */ reps(1000): sim_iv_clr_15, obs(`nobs') b(`betatrue') mu2k(1.0) rho(0.5) > > **I generate a dummy variable for rejection > gen clrtest=(clrp<0.05) > gen artest=(arp<0.05) > gen wtest=(wp<0.05) > > The results are then given by > For tests at true value > clrtest | 1000 .253 .4349485 0 1 > artest | 1000 .437 .4962633 0 1 > -------------+-------------------------------------------------------- > wtest | 1000 .355 .4787528 0 1 > > For tests at true - 0.25 > clrtesta | 1000 .324 .4682342 0 1 > -------------+-------------------------------------------------------- > artesta | 1000 .49 .5001501 0 1 > wtesta | 1000 .797 .4024338 0 1 > > For tests at true +0.25 > clrtestb | 1000 .351 .4775218 0 1 > artestb | 1000 .509 .5001691 0 1 > wtestb | 1000 .052 .2221381 0 1 > > So at least at the true value it is quite far from the nominal size of 0.05. > > Sincerely, > Tak Wai Chau > > * > * For searches and help try: > * http://www.stata.com/help.cgi?search > * http://www.stata.com/support/faqs/resources/statalist-faq/ > * http://www.ats.ucla.edu/stat/stata/ ----- Sunday Times Scottish University of the Year 2011-2013 Top in the UK for student experience Fourth university in the UK and top in Scotland (National Student Survey 2012) We invite research leaders and ambitious early career researchers to join us in leading and driving research in key inter-disciplinary themes. Please see www.hw.ac.uk/researchleaders for further information and how to apply. Heriot-Watt University is a Scottish charity registered under charity number SC000278. * * For searches and help try: * http://www.stata.com/help.cgi?search * http://www.stata.com/support/faqs/resources/statalist-faq/ * http://www.ats.ucla.edu/stat/stata/

**References**:**st: About weakiv***From:*Chau Tak Wai <chau.takwai@gmail.com>

- Prev by Date:
**Re: st: Foreach loop, panel data, and residuals** - Next by Date:
**Re: st: Foreach loop, panel data, and residuals** - Previous by thread:
**st: About weakiv** - Next by thread:
**st: Re: About weakiv** - Index(es):