Page 1 of 1

Help with code please

Posted: Mon Jun 24, 2019 3:48 pm
by Ozmando
I am trying to use the panelthresh procedure in RATS to estimate a panel threshold model.

My regime variable (threshold variable) is FSD and I am basically interested in finding out the effect of fsd on my gini (dependent variable) at high and low FSD.

I was wondering how to modify the code to obtain theses effects. I am working on the code below
Thanks,
oz

Re: Help with code please

Posted: Mon Jun 24, 2019 3:48 pm
by Ozmando

Code: Select all

*
open data gini.txt
calendar(panelobs=15,a) 1993
data(format=free,org=columns) 1//1993:01 565//2007:01 gini fsd gdp gov agr corr
*
* Do data transformations
*
set q  = fsd
set q2 = fsd^2
set q3 = fsd^3
*set qd = q*debta
*
* Set the threshold and breaking variables
*
set threshvar = fsd{1}
set breakvar  = fsd{1}
*
@panelthresh(qn=40,t1=.01,thresh=threshvar,break=breakvar) gini
# q{1} q2{1} q3{1} gdp{1} qd{1} gov{1} agri{1} corr{1}
*
* The remainder requires RATS 8.1 or later for the panel bootstrap.
*
* Save the test statistics from the original data
*
compute sample1_0=%%ftest1_0
compute sample2_1=%%ftest2_1
*
* Get the FE residuals
*
preg(method=fixed) gini
# q{1} q2{1} q3{1} gdp{1} qd{1} gov{1} agri{1} corr{1}
set feresids = %resids
*
compute nboot=100
*
* For saving the bootstrapped statistics
*
set boot1_0 1 nboot = 0.0
set boot2_1 1 nboot = 0.0
infobox(action=define,lower=1,upper=nboot,progress) "Bootstrapping"
do draw=1,nboot
   boot(panel) pshuffle
   set(nopanel) bootinva = feresids(pshuffle(t))
   @panelthresh(qn=40,t1=.01,thresh=threshvar,break=breakvar,noprint) bootgini
   # q{1} q2{1} q3{1} gdp{1} qd{1} gov{1} agri{1} corr{1}
   compute boot1_0(draw)=%%ftest1_0
   compute boot2_1(draw)=%%ftest2_1
   infobox(current=draw)
end do draw
infobox(action=remove)
sstats(mean) 1 nboot (boot1_0>sample1_0)>>pvalue1_0 (boot2_1>sample2_1)>>pvalue2_1
disp "Bootstrapped p-values"
disp "For one break" pvalue1_0
disp "For two breaks" pvalue2_1


Re: Help with code please

Posted: Mon Jun 24, 2019 6:22 pm
by TomDoan
What's your base model? Have you read Hansen's paper to see what *his* model is and how the panel threshold effect works with it. It looks like you're taking his model and changing variable names, but that's not the correct approach.

Re: Help with code please

Posted: Tue Jun 25, 2019 5:39 am
by Ozmando
TomDoan wrote:What's your base model? Have you read Hansen's paper to see what *his* model is and how the panel threshold effect works with it. It looks like you're taking his model and changing variable names, but that's not the correct approach.
I have red the Hansen paper and tried his example.
But it seems that the results obtained from paneltresh do not offer the estimates of the FSD at the lower and higher regimes, which I am interested in.
The model I am using is gini = fsd+ gdp +gov+ agr+ corr+error.
where fsd is the threshold variable.
Thanks,
oz

Re: Help with code please

Posted: Tue Jun 25, 2019 9:19 am
by TomDoan
The "Q" variables in the Hansen paper are powers of a separate exogenous variable and have nothing to do with the effect of interest. "The non-linear terms in the regression...were included to reduce the possibility of spurious correlations due to omitted variables bias." You're actually duplicating your effect variable with your Q's. Note also that his threshold variable is different from the regressor to which it applies, while you're using the same variable for each. That's certainly OK, but note that a threshold effect like that can simply proxy for some other form of non-linearity.

Have you actually formulated and estimated the model without the threshold effect. That's the first step. Figure out what your model is with your data.

@PANELTHRESH tests for the threshold and estimates the threshold values. Once you have those, it's a simple matter of doing a fixed effects regression.

Re: Help with code please

Posted: Tue Jun 25, 2019 3:21 pm
by Ozmando
TomDoan wrote:The "Q" variables in the Hansen paper are powers of a separate exogenous variable and have nothing to do with the effect of interest. "The non-linear terms in the regression...were included to reduce the possibility of spurious correlations due to omitted variables bias." You're actually duplicating your effect variable with your Q's. Note also that his threshold variable is different from the regressor to which it applies, while you're using the same variable for each. That's certainly OK, but note that a threshold effect like that can simply proxy for some other form of non-linearity.

Have you actually formulated and estimated the model without the threshold effect. That's the first step. Figure out what your model is with your data.

@PANELTHRESH tests for the threshold and estimates the threshold values. Once you have those, it's a simple matter of doing a fixed effects regression.

Thanks Tom. I have taken a close look again and also looked at a R code which seems to implement it; I will try to modify the RATS code accordingly and hopefully that will work.
oz