FLEXIBLE FOURIER FORM IN UNIT ROOTS- JONES & ENDERS
FLEXIBLE FOURIER FORM IN UNIT ROOTS- JONES & ENDERS
Hi Tom,
Not sure if this the right place to post this but I'm having difficulties replicating the UR tests.
The code runs fine for the DF part but creates error when trying to compute UR for all commodities as it can't find the lagselect src file (## CP18. LAGSELECT is not the Name of a PROCEDURE. (Did you forget to SOURCE?))
And it is also giving error when computing the KPSS version (## SR10. Missing Values And/Or SMPL Options Leave No Usable Data Points).
I appreciate any help with this.
Thanks.
Jamal
On the Use of the Flexible Fourier Form in Unit Roots Tests, Endogenous Breaks, and Parameter Instability. (With Paul Jones) in Ma and Wohar "Recent Advances in Estimating Nonlinear Time Series." Springer. (2014) (Data and Code at http://www.time-series.net/fourier_papers)
Not sure if this the right place to post this but I'm having difficulties replicating the UR tests.
The code runs fine for the DF part but creates error when trying to compute UR for all commodities as it can't find the lagselect src file (## CP18. LAGSELECT is not the Name of a PROCEDURE. (Did you forget to SOURCE?))
And it is also giving error when computing the KPSS version (## SR10. Missing Values And/Or SMPL Options Leave No Usable Data Points).
I appreciate any help with this.
Thanks.
Jamal
On the Use of the Flexible Fourier Form in Unit Roots Tests, Endogenous Breaks, and Parameter Instability. (With Paul Jones) in Ma and Wohar "Recent Advances in Estimating Nonlinear Time Series." Springer. (2014) (Data and Code at http://www.time-series.net/fourier_papers)
Re: FLEXIBLE FOURIER FORM IN UNIT ROOTS- JONES & ENDERS
@LAGSELECT is a older user-supplied procedure. The similar procedure which we maintain ourselves is @ADFAUTOSELECT. However, here is the older procedure file.
@KPSS doesn't allow for embedded missing values. If you ask for a specific range that would include some lost data points, @KPSS will fail.
@KPSS doesn't allow for embedded missing values. If you ask for a specific range that would include some lost data points, @KPSS will fail.
Re: FLEXIBLE FOURIER FORM IN UNIT ROOTS- JONES & ENDERS
Hi ,
I have 5 if statements. When I run the program with only the first 2 if statements, it correctly executes and replicates results, however when I include the 3rd, 4th and 5th if statements, it does not. I tried a "5" branch decision with no success. I appreciate any help. Thanks.
Jamal
if k == 1
linreg(noprint) dy * cap_T ; # constant
com phi1 = y(1) - %beta(1)
set s_tilde * cap_T = y - phi1 - %beta(1)*t
dif s_tilde * cap_T ds_tilde
lin(noprint) dy 1 cap_T ; # s_tilde{1} constant dsin1 dcos1
com tstats(k,j)(i) = %tstats(1)
exc(noprint) ; # dsin1 dcos1
com ftests(k,j)(i) = %cdstat
if k == 2
linreg(noprint) dy * cap_T ; # constant
com phi1 = y(1) - %beta(1)
set s_tilde * cap_T = y - phi1 - %beta(1)*t
dif s_tilde * cap_T ds_tilde
lin(noprint) dy 2 cap_T ; # s_tilde{1} constant dsin1 dcos1 dsin2 dcos2
com tstats(k,j)(i) = %tstats(1)
exc(noprint) ; # dsin1 dcos1 dsin2 dcos2
com ftests(k,j)(i) = %cdstat
if k == 3
linreg(noprint) dy * cap_T ; # constant
com phi1 = y(1) - %beta(1)
set s_tilde * cap_T = y - phi1 - %beta(1)*t
dif s_tilde * cap_T ds_tilde
lin(noprint) dy 3 cap_T ; # s_tilde{1} constant dsin1 dcos1 dsin2 dcos2 dsin3 dcos3
com tstats(k,j)(i) = %tstats(1)
exc(noprint) ; # dsin1 dcos1 dsin2 dcos2 dsin3 dcos3
com ftests(k,j)(i) = %cdstat
if k == 4
linreg(noprint) dy * cap_T ; # constant
com phi1 = y(1) - %beta(1)
set s_tilde * cap_T = y - phi1 - %beta(1)*t
dif s_tilde * cap_T ds_tilde
lin(noprint) dy 4 cap_T ; # s_tilde{1} constant dsin1 dcos1 dsin2 dcos2 dsin3 dcos3 dsin4 dcos4
com tstats(k,j)(i) = %tstats(1)
exc(noprint) ; # dsin1 dcos1 dsin2 dcos2 dsin3 dcos3 dsin4 dcos4
com ftests(k,j)(i) = %cdstat
if k == 5
linreg(noprint) dy * cap_T ; # constant
com phi1 = y(1) - %beta(1)
set s_tilde * cap_T = y - phi1 - %beta(1)*t
dif s_tilde * cap_T ds_tilde
lin(noprint) dy 5 cap_T ; # s_tilde{1} constant dsin1 dcos1 dsin2 dcos2 dsin3 dcos3 dsin4 dcos4 dsin5 dcos5
com tstats(k,j)(i) = %tstats(1)
exc(noprint) ; # dsin1 dcos1 dsin2 dcos2 dsin3 dcos3 dsin4 dcos4 dsin5 dcos5
com ftests(k,j)(i) = %cdstat
I have 5 if statements. When I run the program with only the first 2 if statements, it correctly executes and replicates results, however when I include the 3rd, 4th and 5th if statements, it does not. I tried a "5" branch decision with no success. I appreciate any help. Thanks.
Jamal
if k == 1
linreg(noprint) dy * cap_T ; # constant
com phi1 = y(1) - %beta(1)
set s_tilde * cap_T = y - phi1 - %beta(1)*t
dif s_tilde * cap_T ds_tilde
lin(noprint) dy 1 cap_T ; # s_tilde{1} constant dsin1 dcos1
com tstats(k,j)(i) = %tstats(1)
exc(noprint) ; # dsin1 dcos1
com ftests(k,j)(i) = %cdstat
if k == 2
linreg(noprint) dy * cap_T ; # constant
com phi1 = y(1) - %beta(1)
set s_tilde * cap_T = y - phi1 - %beta(1)*t
dif s_tilde * cap_T ds_tilde
lin(noprint) dy 2 cap_T ; # s_tilde{1} constant dsin1 dcos1 dsin2 dcos2
com tstats(k,j)(i) = %tstats(1)
exc(noprint) ; # dsin1 dcos1 dsin2 dcos2
com ftests(k,j)(i) = %cdstat
if k == 3
linreg(noprint) dy * cap_T ; # constant
com phi1 = y(1) - %beta(1)
set s_tilde * cap_T = y - phi1 - %beta(1)*t
dif s_tilde * cap_T ds_tilde
lin(noprint) dy 3 cap_T ; # s_tilde{1} constant dsin1 dcos1 dsin2 dcos2 dsin3 dcos3
com tstats(k,j)(i) = %tstats(1)
exc(noprint) ; # dsin1 dcos1 dsin2 dcos2 dsin3 dcos3
com ftests(k,j)(i) = %cdstat
if k == 4
linreg(noprint) dy * cap_T ; # constant
com phi1 = y(1) - %beta(1)
set s_tilde * cap_T = y - phi1 - %beta(1)*t
dif s_tilde * cap_T ds_tilde
lin(noprint) dy 4 cap_T ; # s_tilde{1} constant dsin1 dcos1 dsin2 dcos2 dsin3 dcos3 dsin4 dcos4
com tstats(k,j)(i) = %tstats(1)
exc(noprint) ; # dsin1 dcos1 dsin2 dcos2 dsin3 dcos3 dsin4 dcos4
com ftests(k,j)(i) = %cdstat
if k == 5
linreg(noprint) dy * cap_T ; # constant
com phi1 = y(1) - %beta(1)
set s_tilde * cap_T = y - phi1 - %beta(1)*t
dif s_tilde * cap_T ds_tilde
lin(noprint) dy 5 cap_T ; # s_tilde{1} constant dsin1 dcos1 dsin2 dcos2 dsin3 dcos3 dsin4 dcos4 dsin5 dcos5
com tstats(k,j)(i) = %tstats(1)
exc(noprint) ; # dsin1 dcos1 dsin2 dcos2 dsin3 dcos3 dsin4 dcos4 dsin5 dcos5
com ftests(k,j)(i) = %cdstat
Re: FLEXIBLE FOURIER FORM IN UNIT ROOTS- JONES & ENDERS
You need {...} around the controlled instructions (see Blocks of Statements on that page) when there's more than one, so for your first case:
if k == 1
{
linreg(noprint) dy * cap_T ; # constant
com phi1 = y(1) - %beta(1)
set s_tilde * cap_T = y - phi1 - %beta(1)*t
dif s_tilde * cap_T ds_tilde
lin(noprint) dy 1 cap_T ; # s_tilde{1} constant dsin1 dcos1
com tstats(k,j)(i) = %tstats(1)
exc(noprint) ; # dsin1 dcos1
com ftests(k,j)(i) = %cdstat
}
(It's also a good idea to indent the controlled lines. Use Edit-Indent Lines)
if k == 1
{
linreg(noprint) dy * cap_T ; # constant
com phi1 = y(1) - %beta(1)
set s_tilde * cap_T = y - phi1 - %beta(1)*t
dif s_tilde * cap_T ds_tilde
lin(noprint) dy 1 cap_T ; # s_tilde{1} constant dsin1 dcos1
com tstats(k,j)(i) = %tstats(1)
exc(noprint) ; # dsin1 dcos1
com ftests(k,j)(i) = %cdstat
}
(It's also a good idea to indent the controlled lines. Use Edit-Indent Lines)
Re: FLEXIBLE FOURIER FORM IN UNIT ROOTS- JONES & ENDERS
I'm running and combining quiet few Enders and Lee Fourier Unit root programs. Some with success and some not.
I managed to get the DF and LM UR tests for cumulative frequency working but Attached is the single frequency program where the DF part runs fine (I hope) but the LM version is giving me all sort of trouble.
Different errors when I modify the program but this one is persistent (## SR10. Missing Values And/Or SMPL Options Leave No Usable Data Points
The Error Occurred At Location 764, Line 17 of loop/block).
I appreciate any help.
Thanks.
I managed to get the DF and LM UR tests for cumulative frequency working but Attached is the single frequency program where the DF part runs fine (I hope) but the LM version is giving me all sort of trouble.
Different errors when I modify the program but this one is persistent (## SR10. Missing Values And/Or SMPL Options Leave No Usable Data Points
The Error Occurred At Location 764, Line 17 of loop/block).
I appreciate any help.
Thanks.
Last edited by jhusein on Tue Apr 30, 2019 4:31 pm, edited 1 time in total.
Re: FLEXIBLE FOURIER FORM IN UNIT ROOTS- JONES & ENDERS
There's something wrong with this:
set s_tilde = s_tilde - %beta(2*k)*sine(k) - %beta(2*k+1)*cosine(k)
s_tilde on the right side isn't defined previously, so this will give NA's.
set s_tilde = s_tilde - %beta(2*k)*sine(k) - %beta(2*k+1)*cosine(k)
s_tilde on the right side isn't defined previously, so this will give NA's.
Re: FLEXIBLE FOURIER FORM IN UNIT ROOTS- JONES & ENDERS
Sorry but its still not working!
Re: FLEXIBLE FOURIER FORM IN UNIT ROOTS- JONES & ENDERS
What did you change that to? The problem is with
lin(noprint) dy start * ; # s_tilde{1} reglist ds_tilde{1 to lags-1}
Something in that (presumably s_tilde, since ds_tilde is defined from it), is all NA's.
lin(noprint) dy start * ; # s_tilde{1} reglist ds_tilde{1 to lags-1}
Something in that (presumably s_tilde, since ds_tilde is defined from it), is all NA's.
Re: FLEXIBLE FOURIER FORM IN UNIT ROOTS- JONES & ENDERS
I appreciate you taking the time. Changed to this.
do k = 1,5
set sine(k) = sin(2.*%pi*k*t/%nobs) ; dif sine(k) / dsine(k)
set cosine(k) = cos(2.*%pi*k*t/%nobs) ; dif cosine(k) / dcosine(k)
com aic_min = 10000000.
enter(varying) reglist ; # constant sine(k) cosine(k)
lin(noprint) y start * resids ; # y{1 to lags} reglist
compute aic = %nobs*log(%rss) + 2.*(%nreg)
if (aic < aic_min); com aic_min = aic , kstar = k
compute reglist = || constant ||
enter(varying) reglist ; # reglist dsine(k) dcosine(k)
set s_tilde = y - %beta(1)*t
end do k
lin(noprint) dy start * resids ; # reglist
set s_tilde = s_tilde - %beta(2*k)*sine(k) - %beta(2*k+1)*cosine(k)
dif s_tilde / ds_tilde
lin(noprint) dy start * ; # s_tilde{1} reglist ds_tilde{1 to lags-1}
compute aic = %nobs*log(%rss) + 2.*(%nreg)
do k = 1,5
set sine(k) = sin(2.*%pi*k*t/%nobs) ; dif sine(k) / dsine(k)
set cosine(k) = cos(2.*%pi*k*t/%nobs) ; dif cosine(k) / dcosine(k)
com aic_min = 10000000.
enter(varying) reglist ; # constant sine(k) cosine(k)
lin(noprint) y start * resids ; # y{1 to lags} reglist
compute aic = %nobs*log(%rss) + 2.*(%nreg)
if (aic < aic_min); com aic_min = aic , kstar = k
compute reglist = || constant ||
enter(varying) reglist ; # reglist dsine(k) dcosine(k)
set s_tilde = y - %beta(1)*t
end do k
lin(noprint) dy start * resids ; # reglist
set s_tilde = s_tilde - %beta(2*k)*sine(k) - %beta(2*k+1)*cosine(k)
dif s_tilde / ds_tilde
lin(noprint) dy start * ; # s_tilde{1} reglist ds_tilde{1 to lags-1}
compute aic = %nobs*log(%rss) + 2.*(%nreg)
Re: FLEXIBLE FOURIER FORM IN UNIT ROOTS- JONES & ENDERS
Something's clearly wrong with that. You're defining stilde inside the k loop, using %beta(1)*t while the regression done in that doesn't have t even in it (the first regressor is y{1}). Then you're re-defining outside the k loop based upon the value of k. My suggestion to start is that you fix the number of lags (rather than trying to pick that) and get the calculation right for the Fourier part first.
Re: FLEXIBLE FOURIER FORM IN UNIT ROOTS- JONES & ENDERS
Thanks.TomDoan wrote:Something's clearly wrong with that. You're defining stilde inside the k loop, using %beta(1)*t while the regression done in that doesn't have t even in it (the first regressor is y{1}). Then you're re-defining outside the k loop based upon the value of k. My suggestion to start is that you fix the number of lags (rather than trying to pick that) and get the calculation right for the Fourier part first.
Re: FLEXIBLE FOURIER FORM IN UNIT ROOTS- JONES & ENDERS
Dear Tom;
I dlownloaded the lagselec and ran the code; however, I got "Statistics on Series TREND
Observations 2010
Sample Mean 1005.500000 Variance 336842.500000
Standard Error 580.381340 SE of Sample Mean 12.945398
t-Statistic (Mean=0) 77.672389 Signif Level (Mean=0) 0.000000
Skewness 0.000000 Signif Level (Sk=0) 1.000000
Kurtosis (excess) -1.200000 Signif Level (Ku=0) 0.000000
Jarque-Bera 120.600000 Signif Level (JB=0) 0.000000
## SR10. Missing Values And/Or SMPL Options Leave No Usable Data Points"
How can I solve it?
I dlownloaded the lagselec and ran the code; however, I got "Statistics on Series TREND
Observations 2010
Sample Mean 1005.500000 Variance 336842.500000
Standard Error 580.381340 SE of Sample Mean 12.945398
t-Statistic (Mean=0) 77.672389 Signif Level (Mean=0) 0.000000
Skewness 0.000000 Signif Level (Sk=0) 1.000000
Kurtosis (excess) -1.200000 Signif Level (Ku=0) 0.000000
Jarque-Bera 120.600000 Signif Level (JB=0) 0.000000
## SR10. Missing Values And/Or SMPL Options Leave No Usable Data Points"
How can I solve it?
Re: FLEXIBLE FOURIER FORM IN UNIT ROOTS- JONES & ENDERS
Why would you run a lag selection procedure on a deterministic time trend?