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]

st: small bugs in -ivhettest-


From   Federico Belotti <[email protected]>
To   Stata List <[email protected]>
Subject   st: small bugs in -ivhettest-
Date   Wed, 14 Aug 2013 14:17:47 +0200

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/


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