Unit root with breaks testing for several time series at once

Share:

Dear visitor,

If you have not even heard about Gretl. Please don’t panic, I will walk you the way very well. All that fear about a new software will disappear. After all, if you are here maybe it is because many other more popular unit root tests are not suitable for your analysis. For example, you may need to apply an unit root test which allows for more than two breaks in the series. If that is your situation, you definitely may need to apply the Kapetanios (2005) test. Its code for Gretl was written by Ricardo Ramírez & Daniel Ventosa-Santaulària.

In the example, we will use two series: real UK GDP and investment at 2013 prices in millions of sterling pounds. Both series start in 1830 and end in 2016. The data can be downloaded here.

If you don’t have Gretl installed, download it. After installation, click in “File” > “Function packages” > “On server…” and in the “Search” bar type “Kapetanios” and it will appear. You just need to right click on it and press “Install”. After installation of the Kapetanios package, you will create an script file by clicking “File” > “Script files” > “New script” > “grelt script”. There you paste these lines of code:

include Kapetanios.gfn                             # load Kapetanios procedure
open G:\UK_gdp_investment.xls # load the excel file
setobs 1 1830 --time-series # set the data as time series

list dato = gdp inv                                # include in the list the two series in the excel file "gdp" and "inv"
loop i=1..2                                        # open the loop. As we have two series and we want to do the unit root tests to both the maximum numer is 2. If you have 20, you substitute 2 by 20
name = varname(dato[i])                            # store the name of the variable in the object "name". I do this because when you have 20 series you want to know easily which series the tests results refer to.
print name                                         # prints the name of the series
print "DRIFT"                                      # this prints that the following test is only with break in drift
Results=Kapetanios(dato[i],1,6,0.15,1)             # Kapetanios test considering 1 break in level
print "TREND"                                      # this prints that the following test is only with break in trend
Results=Kapetanios(dato[i],1,6,0.15,2)             # Kapetanios test considering 1 break in trend
print "BOTH"                                       # this prints that the following test is only with break in drift and trend
Results=Kapetanios(dato[i],1,6,0.15,3)             # Kapetanios test considering 1 break in level and trend
print "DIFFERENCE"                                 # this prints that the following test is for the difference of the series
Results=Kapetanios(diff(dato[i]),1,6,0.15,1)       # Kapetanios considering 1 break in level of the differenced series
endloop                                            # closes the loop

After pasting this, you save this in an script file by clicking in the “Save” button but don’t close the script file. Now in the script file editor you only need to  click the “Run” button in the editor or press “CONTROL +R” and you will get an output file with all the outputs for the series: the test with three breaks in level, the test with three breaks in trend, the test with three breaks in both and the test in level with the differenced series.

In the code when you look at the structure you see “(dato[i],1,6,0.15,1)”. The “1” is the number of breaks, the “6” is the maximum number of lags for the test, “0.15” is the trimming parameter, and the last number is the type of break (1 if you are considering for a level break, 2 if you are considering for trend break, and 3 if you are considering break in both).

Finally, you can click here to watch a YouTube video demonstrating how to run the code and explaining a little bit the output. If you click here, you can watch the video in Spanish.

I really hope you found this post useful. If there is any comment, correction, or question; feel free to reach me in Twitter (@ReynaldoSenra) as very probably you will get a very fast response. Spanish or English is ok.