Bookmark and Share

Notice: On March 31, it was announced that Statalist is moving from an email list to a forum. The old list will shut down on April 23, and its replacement, is already up and running.

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

Re: st: IVQR with two endogenous regressors using -ivqreg-

From   Katie Farrin <>
Subject   Re: st: IVQR with two endogenous regressors using -ivqreg-
Date   Fri, 31 May 2013 13:09:31 -0400

Thanks much.

I guess if the program still won't work for me I should think of
another method.  Because IVQR first uses OLS to make predictions for
endogenous variables (much like in the first stage of 2SLS), does
anyone see a problem with running two regressions, one for each
endogenous variable (on all of the exogenous model regressors plus the
relevant instrument), saving the predicted 'yhat' values, and using
those in place of the endogenous regressors in the -bsqreg- command?
I don't have any experience doing two-stage estimators manually (i.e.,
without an IV methods command in Stata) so I'm not sure if this would
be a reasonable alternative.


On Fri, May 31, 2013 at 12:57 PM, Nick Cox <> wrote:
> Thanks for the details.  I note there is no help file.
> On your question (2)
> qui regress `endo' `allinstr' if `touse'
> predict dhat, xb
> -dhat- is a predicted response after the previous regression.
> qui qreg `lhs' `dhat' `inexog' if `touse', q(`quantil')
> predict iner if `touse', resid
> -iner- ditto. They should be dropped later in the program, so should
> be temporary variables.
> Presumably the program crashed for you before that.
> Nick
> On 31 May 2013 17:42, Katie Farrin <> wrote:
>> Thank you, Nick,
>> I posted earlier regarding this program and have contacted the author,
>> but have not heard back.  The program is accessible not through Stata
>> but through an online search (I am not sure why this is the case,
>> either).
>> The (unpublished) Stata Journal article written by Do Won Kwak is
>> where the author describes the program; I downloaded the program from
>> this professor's page (requires some scrolling but it's through a link
>> in the fourth option for "IVQR"):
>> Reference: Kwak, D. (2010). Implementation of instrumental variable
>> quantile regression (IVQR) methods.  Accessible through Kwak's job
>> market page
>> I would prefer to use an IVQR method in my work as I have evidence of
>> heterogeneity of effects for my regressors of interest; however, I
>> also have an endogeneity problem.  This user-written code is the only
>> thing I've found so far that I can work with to address such a model.
>> On another note, I guess I was also hoping that the conformability
>> error might be common to instrumental variables methods.  I have read
>> elsewhere (Statalist archives) that it may be due to a variance
>> covariance matrix operation problem; I have income variables that I
>> have scaled down (from dollars to thousands of dollars) and several
>> indicator variables, so it may be an issue of different scale.
>> However, I'm confused as to why the scale wouldn't be a problem in
>> previous regressions (using -regress- and -bsqreg-) that I have
>> performed using the same set of regressors.
>> Any help is much appreciated.
>> Best,
>> Katie
>> On Fri, May 31, 2013 at 12:24 PM, Nick Cox <> wrote:
>>> You are in strange territory here.
>>> First, it is hard for anyone else even to look at this code as
>>> -findit- can't find it and you don't give a location. Longstanding
>>> Statalist practice is to explain where user-written software can be
>>> found, as the FAQ does spell out.  You do clearly state that you only
>>> hope for attention from people familiar with the program, but that's
>>> our convention. (Sometimes people not familiar with a program can look
>>> inside quickly and say something helpful.)
>>> Second, it sounds as if -ivqreg- creates permanent variables without
>>> reference to what you asked. Is that documented in the help? It's not
>>> going to help you at all, but I'll opine that's poor programming
>>> practice if undocumented, and a sign that you have (what shall we say)
>>> a program that is work in progress.
>>> Third, if this program is documented then there should be an author
>>> email for support. I have not been following closely but there have
>>> been various questions about this program and I've not noticed an
>>> author replying. If that's so, the clear implication is that the
>>> author is not on Statalist and it is a good idea to contact him, her
>>> or them directly.
>>> Nick
>>> On 31 May 2013 17:08, Katie Farrin <> wrote:
>>>> Hi, Statalisters,
>>>> I am using the -ivqreg- user-written command to evaluate the effects
>>>> of source-specific income increases on nutritional outcomes.  However,
>>>> I have two endogenous regressors, a dummy that indicates that a
>>>> household has chosen to farm tobacco and a (continuous) variable for
>>>> tobacco profits; these endogenous regressors are clearly related but
>>>> not the same.
>>>> I would like to instrument the endogenous dummy variable with GIS data
>>>> on the distance to the nearest tobacco auction floor and the tobacco
>>>> profits with the deviation from ten-year average rainfall.   I use the
>>>> following code in Stata:
>>>> *instumental variables quantile regression
>>>> ivqreg ln_dietarydiversity maize_thousands emp_inc_thousands
>>>> bus_profits_thousands livestock_thousands remittances_thousands /*
>>>> */ ln_price_tomato age_hh_head male married durables_thousands
>>>> years_education hh_size /*
>>>> */ chitipa karonga nkhatabay rumphi mzimba kasungu nkhotakota ntchisi
>>>> dowa salima mchinji dedza ntcheu /*
>>>> */ mangochi machinga zomba chiradzulu blanytyre mwanza thyolo mulanje
>>>> phalombe chikwawa nsanje balaka /*
>>>> */ March April May June August September October November
>>>> (tobacco_thousands tobacco=deviation_tot_rainfall_wet_2010
>>>> dist_auction), robust first
>>>> I have two questions:
>>>> (1) when running this code I get a conformability error (r(503)), and
>>>> I do not know why this is occurring (this is very similar to the code
>>>> I run for regular QR using -bsqreg- without any problems) - any advice
>>>> would be greatly appreciated on how to run this code without
>>>> generating such an error;
>>>> (2) when I run the code, before the error message, Stata saves two new
>>>> variables to my working data set, "dhat" and "iner."  I have looked at
>>>> the user-written -ivqreg- but cannot figure out what these are (I am
>>>> assuming they are predicted values, but of what I do not know because
>>>> they are not similar in range to my endogenous variable values) - if
>>>> anyone is familiar with -ivqreg- and could give me some insight as to
>>>> what these variables are I'd appreciate it.
>>> *
>>> *   For searches and help try:
>>> *
>>> *
>>> *
>> *
>> *   For searches and help try:
>> *
>> *
>> *
> *
> *   For searches and help try:
> *
> *
> *
*   For searches and help try:

© Copyright 1996–2016 StataCorp LP   |   Terms of use   |   Privacy   |   Contact us   |   Site index