Bookmark and Share

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]

Small bug in -ivhettest- fixed (was: RE: st: small bugs in -ivhettest-)


From   "Schaffer, Mark E" <[email protected]>
To   "[email protected]" <[email protected]>
Subject   Small bug in -ivhettest- fixed (was: RE: st: small bugs in -ivhettest-)
Date   Sun, 1 Sep 2013 10:49:54 +0000

Hi all.  Just a quick note to the list to say that the "_cons" bug in -ivhettest- mentioned below is indeed fixed.  Thanks to Federico for bringing it to my attention.

--Mark

> -----Original Message-----
> From: [email protected] [mailto:owner-
> [email protected]] On Behalf Of DE SOUZA Eric
> Sent: 14 August 2013 15:39
> To: [email protected]
> Subject: RE: st: small bugs in -ivhettest-
> 
> Both reproduced here.
> 
> As to 1), if you remove the underscore (name the variable -exprconstraint-
> instead of -expr_constraint-), then it works. So the problem comes from the
> underscore (in combination with cons?).
> 
> As to 2), ivhettest predates ivregress which was introduced in Stata 10 in
> replacement of ivreg, if I'm not mistaken. -ivregress- requires that you specify
> the estimation method even if it is 2sls, whereas -ivreg- considers it the default.
> I cannot check this because the help for -ivreg- just says that it is outdated and
> to use -ivregress- instead.
> 
> Using Stata 12.1
> 
> 
> Eric de Souza
> College of Europe
> Brugge (Bruges), Belgium
> http://www.coleurope.eu
> 
> 
> 
> -----Original Message-----
> From: [email protected] [mailto:owner-
> [email protected]] On Behalf Of Federico Belotti
> Sent: 14 August 2013 15:10
> To: [email protected]
> Subject: Re: st: small bugs in -ivhettest-
> 
> I'm so sorry. There is a small "bug" in my post as well :-)
> 
> Please consider the following as the code to reproduce the second mentioned
> error
> 
> 2) return code 301, that is "last estimates not found". The following lines
> reproduce the error
> 
> 	use http://fmwww.bc.edu/ec-p/data/hayashi/griliches76.dta
> 	ivregress lw s expr tenure rns smsa (iq=med kww age mrt)
> 	ivhettest
> 
> 
> Federico
> 
> On Aug 14, 2013, at 2:17 PM, Federico Belotti wrote:
> 
> > I am using -ivhettest- by Mark E. Schaffer, v1.1.6  4Feb2007 from SSC
> > with Stata 13.0 and I am getting two errors
> >
> > 1) return code 111, that is one of the independent variables in the
> > previously issued estimation command is not found during the execution
> > of -ivhettest-. The following lines reproduce the error
> >
> > 	use http://fmwww.bc.edu/ec-p/data/hayashi/griliches76.dta
> > 	gen expr_constraint = (expr<2)
> > 	ivreg2 lw s expr_constraint tenure rns smsa (iq=med kww age mrt)
> > 	ivhettest
> >
> > 2) return code 301, that is "last estimates not found". The following
> > lines reproduce the error
> >
> > 	use http://fmwww.bc.edu/ec-p/data/hayashi/griliches76.dta
> > 	ivreg2 lw s expr tenure rns smsa (iq=med kww age mrt)
> > 	ivhettest
> >
> >
> > As for the first issue, after investigation I see that the following line is
> responsible for the small bug (traced output):
> >
> >    - local cn : subinstr local cn "_cons" "`one'"
> >    = local cn : subinstr local cn "_cons" "__00000C"
> >
> > Basically this line returns the contents of "cn", with the first occurrence of
> "_cons" changed to "__00000C".
> > Unfortunately, one of the independent variables in the model contains in its
> name the word "_cons" which is mistakenly replaced, that is the variable
> "expr_constraint" becomes "expr__00000Ctraint", thus generating the
> aforementioned error.
> >
> > A quick workaround to avoid this issue is to change the names of the variables
> so as to remove the word "_cons".
> >
> > Since the word "_cons" in the e(b) parameter vector is always the last one (at
> least for the estimation commands for which -ivhettest- should work, i.e. -
> ivregress-, -ivreg2- and -regress-), a permanent workaround should be
> something like:
> >
> > 	local CoNs _cons
> > 	local cn "`:list cn - CoNs' `one'"
> >
> > in place of
> >
> > 	local cn : subinstr local cn "_cons" "`one'"
> >
> >
> >
> > As for the second issue, after investigation I see that the following line is
> responsible for the small bug (traced output):
> >
> > - if "`e(cmd)'" != "ivreg" & "`e(cmd)'" != "ivreg2" & "`e(cmd)'" !=
> > "ivgmm0" & "`e(cmd)'" != "regress" { = if "ivregress" != "ivreg" &
> > "ivregress" != "ivreg2" & "ivregress" != "ivgmm0" & "ivregress" !=
> > "regress" {
> >
> > Basically, the command should work with -ivregress- but this command has
> not been included in the list of the supported commands.
> > A quick workaround to avoid this issue is to use -ivreg2- or the out-of-date
> command -ivreg-.
> > The permanent workaround is to add -ivregress- to the list, that is
> > replace
> >
> > 	if "`e(cmd)'" != "ivreg" & "`e(cmd)'" != "ivreg2" & "`e(cmd)'" !=
> > "ivgmm0" & "`e(cmd)'" != "regress" {
> >
> > with
> >
> > 	if "`e(cmd)'" != "ivregress" & "`e(cmd)'" != "ivreg" & "`e(cmd)'" !=
> > "ivreg2" & "`e(cmd)'" != "ivgmm0" & "`e(cmd)'" != "regress" {
> >
> >
> > I hope these can be fixed in the next -ivhettest- update.
> >
> > Federico
> >
> > --
> > Federico Belotti, PhD
> > Research Fellow
> > Centre for Economics and International Studies University of Rome Tor
> > Vergata
> > tel/fax: +39 06 7259 5627
> > e-mail: [email protected]
> > web: http://www.econometrics.it
> >
> >
> > *
> > *   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/
> 
> --
> Federico Belotti, PhD
> Research Fellow
> Centre for Economics and International Studies University of Rome Tor Vergata
> tel/fax: +39 06 7259 5627
> e-mail: [email protected]
> web: http://www.econometrics.it
> 
> 
> *
> *   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/
> 
> *
> *   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/


© Copyright 1996–2018 StataCorp LLC   |   Terms of use   |   Privacy   |   Contact us   |   Site index