%Version 2, March, 2009.
%These routines can be used by and distributed for non-profit academic purposes
%without any royalty except that the users must cite:
%Perron and Yabu (2009): "Estimating Deterministic Trends with an Integrated or
%Stationary Noise Component," Journal of Econometrics 151 (2009), 56-69.
%Perron and Yabu (2009): "Testing for Shifts in Trend with an Integrated or Stationary 
%Noise Component," Journal of Business and Economic Statistics 27 (2009), 369-396.
%for any other commercial use and/or comments,  please contact 
%Pierre Perron at perron at bu.edu.
%Even though we tried to make this program error-free we cannot be held
%responsible for any consequences that could result from remaining errors.
%Copyright, Pierre Perron and Tomoyoshi Yabu (2009).
%Traslated from Gauss to Matlab by Lola Gadea, 2017

%Read the data
load canada.txt %Annual GDP for the Canada from 1870 to 1986
y=canada;

%Choose a model from the following:
%Model=1: Y{t}=a0+a1*DU+b0*t+e{t} where DU=1(t>TB)
%Model=2: Y{t}=a0+b0*t+b1*DT+e{t} where DT=1(t>TB)*(t-TB)
%Model=3: Y{t}=a0+a1*DU+b0*t+b1*DT+e{t} where DU=1(t>TB) and DT=1(t>TB)*(t-TB)
model=3;  

criteria=2; %BIC if criteria=2, AIC if criteria=1

eps=0.15;	%chose a value from {0.01, 0.05, 0.10, 0.15, 0.25}

T=length(y); %size of the sample

kmax=fix(12*(T/100)^(1/4)); %maximum number of lag length

%***************************************
%Call the main function
%***************************************
qfgls(y,kmax,model, criteria,eps)
