Threshold panel data model

Questions related to panel (pooled cross-section time series) data.
dalleyne
Posts: 5
Joined: Tue Mar 30, 2010 9:57 am

Threshold panel data model

Unread post by dalleyne »

Dear all,
I am using a panel threshold model devloped in winrats which is called panelthresh.prg. I want to graph the % rss to show the threshold valuses(points).Can some one say how this might be done.I suspect that the threshold values are reported as a matrix rather than a series.The program is reported as follows:

Code: Select all

*
* Replication file for Bruce Hansen(1999), "Threshold effects in non
* dynamic panels: estimation, testing and inference" Journal of
* Econometrics, vol 93, pp 345-368.
*
open data invest.txt
calendar(panelobs=15,a) 1973
data(format=free,org=columns) 1//1973:01 565//1987:01 inva vala cfa debta
*
* Do data transformations
*
set q  = vala
set q2 = vala^2
set q3 = vala^3
set qd = q*debta
*
* Set the threshold variable
*
set threshvar = debta{1}
*
* Set the control parameters
*
compute qn=400       ;* number of quantiles to examine
compute trim1=.01    ;* percentage to trim before search, single
compute trim2=.01    ;* percentage to trim before search, double
compute trim3=.05    ;* percentage to trim before search, triple
*
* Estimate the base model by FE
*
preg(method=fixed) inva
# q{1} q2{1} q3{1} debta{1} qd{1} cfa{1}
*
* Save the sum of squared residuals and the regressor list
*
compute rss0=%rss
compute baselist=%rlfromtable(%eqntable(0))
*
* Sort unique values for the threshold
*
set sorted = threshvar
order sorted
set unique = sorted<>sorted{1}
sample(smpl=unique) sorted
compute threshnobs=%nobs
**********************************
procedure MakeGammas gammas
type vector *gammas
option integer obs       %nobs
option integer quantiles obs
option real    trim      .01
*
local real    range base
local integer i
compute range=obs*(1-2*trim),base=obs*trim
dim gammas(quantiles)
ewise gammas(i)=sorted(fix(range*(i-1)/(qn-1)+base))
end
*********************************
*
* Single threshold
*
@MakeGammas(obs=threshnobs,quantiles=qn,trim=trim1) gammas
dec vect rssthr1(qn)
compute minrss=rss0
do i=1,qn
   set cf0 = cfa{1}*(threshvar<=gammas(i))
   preg(method=fixed,noprint) inva
   # baselist cf0
   compute rssthr1(i)=%rss
end do i
compute rss1  =%minvalue(rssthr1)
compute gamma1=gammas(%minindex(rssthr1))
compute ftest0=(rss0-rss1)/(rss1/%nobs)
*
disp "Single Threshold" gamma1
disp "Sum of Squared Residuals" rss1
disp "F Test vs 0 Threshold" ftest0
*
* Double threshold, by sequential analysis
*
dec vect rssthr2(qn)
do pass=1,2
   do i=1,qn
      compute test1=%min(gammas(i),gamma1)
      compute test2=%max(gammas(i),gamma1)
      set cf0 = cfa{1}*(threshvar<=test1)
      set cf2 = cfa{1}*(threshvar>test2)
      preg(method=fixed,noprint) inva
      # baselist cf0 cf2
      compute rssthr2(i)=%rss
   end do i
   compute gamma2=gammas(%minindex(rssthr2))
   if pass==2
      compute gamma1=gamma2
   else
      break
end
compute rss2  =%minvalue(rssthr2)
compute ftest1=(rss1-rss2)/(rss2/%nobs)
disp "Double Threshold" gamma1 gamma2
disp "Sum of Squared Residuals" rss2
disp "F Test vs 1 Threshold" ftest1
Dillon
TomDoan
Posts: 7814
Joined: Wed Nov 01, 2006 4:36 pm

Re: Threshold panel data model

Unread post by TomDoan »

(Edited August 2016)

The original question was based upon an old version of the program for the Hansen paper. The newer version uses the @PANELTHRESH procedure which has a GRAPH option to produce the requested graph.
Post Reply