Page 1 of 1

THRESHTEST - Regression with threshold breaks

PostPosted: Fri Nov 04, 2011 12:43 pm
by TomDoan
Attached is a revised version of the THRESHTEST procedure for testing for a threshold break in a linear regression, assuming homoscedatic errors. The newer version creates or sets several additional variables, such as %%BREAKVALUE as the optimal break.

threshtest.src
Procedure file (requires RATS 7.3 or later)
(7.25 KiB) Downloaded 76 times


@ThreshTest( options ) depvar start end
# list of explanatory variables

Options

THRESH=threshold series. If omitted, time is used. If this involves a lag, you need to create it as a separate series.

TRIM=fraction of values to skip at both ends [.15]

NREPS=number of bootstrap replications [0]
If you provide a positive value, this computes an approximate significance level by bootstrapping with random Normal draws.

SMPL=SMPL series for entries to skip

TITLE=title for report ["Test of Threshold Effect"]
[PRINT]/NOPRINT
GRAPH/[NOGRAPH]
If chosen, graphs the F-tests against the threshold values

Variables Defined

%CDSTAT Maximum test statistic
%SIGNIF Bootstrapped p-value
%RSS Minimal sum of squared residuals
%LOGL Maximal log likelihood
%%BREAKVALUE Threshold value at the optimal break


Example

Code: Select all
*
* Enders, Applied Econometric Time Series, 3rd edition
* Example from Section 7.6, pp 451-454
* Threshold model for unemployment
*
open data unrate_decimal.xls
calendar(m) 1960:1
data(format=xls,org=columns) 1960:01 2008:12 unrate
*
graph(footer="U.S. Unemployment Rate")
# unrate 1960:1 2008:12
*
set dur = unrate-unrate{1}
linreg dur / e
# constant dur{1 to 4 12}
@regcorrs(number=10)
@regreset(h=4)
@mcleodli(number=2) e
*
set esq = e^2
linreg e
# constant esq{1}
*
set dulagged = dur{1}
*
* Note that this graphs the F statistics, which will be reversed
* vertically from the graph for the sum of squared residuals (that is,
* the break is indicated by the highest value, not lowest).
*
@threshtest(threshold=dulagged,graph) dur
# constant dur{1 to 4 12}
disp "Sum of Squared Residuals" %rss
*
* Trying other delays
*
set dulagged2 = dur{2}
set dulagged3 = dur{3}
*
@threshtest(threshold=dulagged2) dur
# constant dur{1 to 4 12}
disp "Sum of Squared Residuals" %rss
@threshtest(threshold=dulagged3) dur
# constant dur{1 to 4 12}
disp "Sum of Squared Residuals" %rss
*
* Redo the estimates with the chosen delay
*
@threshtest(threshold=dulagged) dur
# constant dur{1 to 4 12}
*
* Estimate the two branches of the model.
*
linreg(smpl=dulagged>%%breakvalue) dur
# constant dur{1 to 4 12}
linreg(smpl=dulagged<=%%breakvalue) dur
# constant dur{1 to 4 12}

Re: THRESHTEST - Regression with threshold breaks

PostPosted: Tue Nov 20, 2012 4:12 am
by Poppelwops
Dear Tom, are there any plans to implement a threshold approach with endogenous threshold variable? (such as in http://www.economics.uoguelph.ca/Resear ... 2009_7.pdf, for instance). Best, Oliver

Re: THRESHTEST - Regression with threshold breaks

PostPosted: Wed Nov 21, 2012 8:18 am
by TomDoan
Not if there isn't more than that. I'm skeptical about any new technique where the authors haven't been able to come up with a convincing real-world application.

Re: THRESHTEST - Regression with threshold breaks

PostPosted: Mon Jan 14, 2013 11:11 am
by Poppelwops
Dear Tom,

many thanks for your reply (sorry for the late response). Since I am missing proper instruments for my (potentially endogenous) RHS variables, I decided to go back to the THRESHTEST proc.

One question regarding this: Is there an easy way to modify the code in order to allow for (regime-specific) heteroscedasticity?

Any help on this would be highly appreciated!

Many thanks in advance,

Oliver

Re: THRESHTEST - Regression with threshold breaks

PostPosted: Sun Jan 20, 2013 10:34 pm
by TomDoan
There's really no good way to modify @THRESHTEST, since it uses LM calculations to keep the computing time down. It would be easier to modify @MULTIPLEBREAKS. That does calculations based upon calculations of the regressions across each regime. Instead of keeping track of the sum of squared residuals for each interval:

compute intervalrss(s,e)=%rss

you would keep track of (minus the) subsample log likelihoods (since it's written to do a minimization rather than a maximization):

compute intervalrss(s,e)=%nobs=(e-s+1),+.5*%nobs*(log(%rss/%nobs)+1)

That will figure out the optimal regime breaks; you'll have to figure out how to adapt the output to handle the log likelihood

Re: THRESHTEST - Regression with threshold breaks

PostPosted: Fri May 10, 2013 7:03 pm
by cu_student
Tom,
If I am right, THRESHTEST tests only one structural break. Can THRESHTEST be used for testing 2 breaks (3 regimes)? If not, is there any simple way in RATS to get Hansens's bootstrapped p-values for 2 structural breaks?
Thanks

Re: THRESHTEST - Regression with threshold breaks

PostPosted: Fri May 10, 2013 8:06 pm
by TomDoan
cu_student wrote:Tom,
If I am right, THRESHTEST tests only one structural break. Can THRESHTEST be used for testing 2 breaks (3 regimes)? If not, is there any simple way in RATS to get Hansens's bootstrapped p-values for 2 structural breaks?
Thanks


For multiple breaks, use @MultipleBreaks (viewtopic.php?f=7&t=746). The same basic idea for the fixed regressor bootstrap could be applied to that, though the amount of number-crunching required would be rather substantial.

Re: THRESHTEST - Regression with threshold breaks

PostPosted: Sat May 11, 2013 1:21 pm
by cu_student
Thanks Tom for your quick reply.
Let me rephrase the question. Is there a procedure in RATS that gives me Hansen's bootstrap p-value, for an input of two known thresholds? I am not looking to estimate two thresholds, rather I want to check for the significance of different threshold values.

Re: THRESHTEST - Regression with threshold breaks

PostPosted: Sat May 11, 2013 1:39 pm
by cu_student
And to add to my previous question. Once I have accepted the presence of a threshold, is a model with one or two threshold preferable? Is there a procedure that gives a bootstrap p-value for a 1-threshold vs 2-threshold.

Thanks Tom

Re: THRESHTEST - Regression with threshold breaks

PostPosted: Sat May 11, 2013 5:53 pm
by moderator
So you aren't estimating the break values, but want to input them? You don't need to use bootstrapping in that case since that would have standard asymptotics.

Re: THRESHTEST - Regression with threshold breaks

PostPosted: Sat May 11, 2013 6:46 pm
by cu_student
Thanks moderator.

You are right. I dont want to estimate breaks. I have already used 2 methods to estimate best breaks. First is using the code in sms_5_2.rpf (viewtopic.php?f=30&t=948&p=3583&hilit=nonlinear+impulse+responses#p3402). My break values are -150 and +50. Second, I used the estimated break points from @mutiplebreaks is -200 and +50(as suggested by tom). My question is whether there is a procedure to test the statistical significance or get a p-value for my optimal threshold breaks, thats -150 and +50 or -200 and +50.(similar to the @threshtest which gives a p-value for the estimated threshold) And is there a way to get a p-value for a 1 break vs 2 break.

Thanks again for your time.

Re: THRESHTEST - Regression with threshold breaks

PostPosted: Mon May 13, 2013 11:04 am
by TomDoan
Hansen(1996)'s bootstrap procedure is very specifically designed for doing hypothesis testing, not for generating confidence intervals on parameters. There's also a problem with what you're trying to do that your two estimates are, in fact, estimates and estimates with the same data set and are thus highly correlated.

Re: THRESHTEST - Regression with threshold breaks

PostPosted: Mon May 13, 2013 12:55 pm
by Ana_Rita
TomDoan wrote:There's really no good way to modify @THRESHTEST, since it uses LM calculations to keep the computing time down. It would be easier to modify @MULTIPLEBREAKS. That does calculations based upon calculations of the regressions across each regime. Instead of keeping track of the sum of squared residuals for each interval:

compute intervalrss(s,e)=%rss

you would keep track of (minus the) subsample log likelihoods (since it's written to do a minimization rather than a maximization):

compute intervalrss(s,e)=%nobs=(e-s+1),+.5*%nobs*(log(%rss/%nobs)+1)

That will figure out the optimal regime breaks; you'll have to figure out how to adapt the output to handle the log likelihood


Hi Tom,

Since i want to perform the @THRESHTEST assuming heteroscedasticity and using one of the regressors as the threshold variable, i followed your advice and modified the procedure (attached). The output gives me RSS for 0 and 1 break, and according to BIC it finds one break to be the best (also, the break values output gives NA...not sure why).

In order to now adapt this result to get the Hansen test allowing for heteroscedastic errors, i believe i need to use the value i got for RSS from the @MULTIPLEBREAKS test (which is 0.756) so that in the @THRESHTEST procedure instead of having:

Code: Select all
*  Convert everything to F statistics
*
compute sigma = (%rss-ssqmax)/(%nobs-2*%nreg)
compute fmax  = (ssqmax/%nreg)/sigma
set ftests nb ne = (ssq/%nreg)/sigma


I would have something like:

Code: Select all
*  Convert everything to F statistics
*
compute sigma = (0.756-ssqmax)/(%nobs-2*%nreg)
compute fmax  = (ssqmax/%nreg)/sigma
set ftests nb ne = (ssq/%nreg)/sigma


This would then give me the corrected likelihood ratio. According to Hansen's paper the bootstrap technique under heteroscedastic errors also needs to be modified, could you please give some advice on how to do that?

I appreciate any help you can provide me with this!!

Many thanks!
Ana