[R] Threshold Quantile Regression code CRASHES in R

Thomas Lumley tlumley at uw.edu
Tue Jul 17 21:58:17 CEST 2012

On Tue, Jul 17, 2012 at 2:00 AM, Christos Michalopoulos
<mixalopoulos_x at hotmail.com> wrote:
> I am working on a two stage threshold quantile regression model in R, and my aim is to estimate the threshold of the reduced-form equation (call it rhohat), and the threshold of the structural equation (call it qhat), in two stages. On the first stage, i estimate rhohat by quantile regression and obtain the fitted values. I use these fitted values to estimate qhat on the second stage. The code is as follows (thanks to Prof. Bruce Hansen, whose code i modified):


> #************************************************************#You can easily run it yourselves. The problem is that when i write, stqr_thresh_loop(n=200,reps=500) the code crashes and never gives me any result. I only get "the program has stopped responding". What am i doing wrong?                                         Thank you very much!!

I don't get a crash, I get what I would call a 'hang' -- R never
finishes working, and the operating system says it isn't responding to
messages, but R doesn't disappear.

This could be a bug or just a very slow piece of code, so the first
step is to run a smaller example and time it.

With a smaller number of reps, the code mostly works but sometimes
hangs.  On the Mac, you can use the Activity Monitor to sample the
process, and it turns out to be stuck in a compiled-code routine
called "rqbr", which looks like it's part of rq(), called from

Since the problem seems to be data-dependent, and happens with fairly
high frequency, you might want to use trace() to stick some sort of
data summary in before the call to rqbr, to see if anything obvious is
wrong with the data being passed in before things go wrong.


Thomas Lumley
Professor of Biostatistics
University of Auckland

More information about the R-help mailing list