----------------------------------------------------------------------------------------- INDEX OF GAUSS CODES AND DATA FILES FOR Bhardwaj, Geetesh and Norman R. Swanson, Apr. 2004, "An Empirical Investigation of the Usefulness of ARFIMA Models for Predicting Macroeconomic and Financial Time Series" IF YOU FIND ANY BUGS PLEASE DO SEND YOUR COMMENTS TO bhardwaj@econ.rutgers.edu ----------------------------------------------------------------------------------------- CODES: ----------------------------------------------------------------------------------------- DATA GENERATION FOR MONTE CARLO SECTION : ----------------------------------------------------------------------------------------- ALL OF THE PROCEDURES FOR DATA GENERATION HAVE AN EXAMPLE OF HOW TO USE THEM ***************************************************************************************** dgarfima.g Format: y = dgARFIMA(b,p,d,q,mu,T,std,seed); Inputs: b: AR and MA parameters p: Length of AR vector q: Length of MA vector mu: Mean of ARFIMA series d: Differencing parameter (possibly Fractional), d= 0 for arma, Will give an error for d=1 std: Standard deviation of the error seed: Seed for random number generation T: Length of time series Output: ARFIMA series y~Tx1 ****************************************************************************************** dgarima.g Format: y = dgARIMA(b,p,d,q,mu,T,std,seed); Inputs: b:AR and MA parameters p:length of AR vector q:length of MA vector mu:mean d:differencing parameter d= 0 for arma, d=1 for ARIMA std:standard deviation of the error T:length of time series Output: ARIMA series y~Tx1 ARMA model: [1-phi(L)]*([1-L]^d)*[Y(t)-mu] = [1-theta(L)]e(t) ****************************************************************************************** dggarch.g Format: y=dgARMGAR(b,p,0, mu,T,k,omega,garchp,archp,df); Inputs: b: AR parameter p: Length of AR vector mu: Mean of ARFIMA series T: Length of time series k: Number of repetitions df: degrees of freedom leave blank if errors follow N(0,1); omega: constant in GARCH(1,1) garchp: GARCH Coefficient archp: ARCH Coefficient Output: AR(p)-GARCH(1,1) series y~TxK ****************************************************************************************** dgregime.g Format: y=dgregime(T,p00,p11,Std, Mu0,Mu1) DGP (y_t-mu_{s_t})= e_t e_t -- i.i.d. N(0,sigma^2) mu_{st} = (1-S_t)*mu_0 + S_t* mu_1 Pr[S_t=1|S_{t-1}=1]=p Pr[S_t=0|S_{t-1}=0]=q Inputs: std: Standard deviation of the error T: Length of time series p11=Pr[St=1/St-1=1] p00=Pr[St=0/St-1=0] Std=Error sigma Mu0=Mean in state 0 Mu1=Mean in state 1 Output: Y=generated Series, Tx1 ****************************************************************************************** ------------------------------------------------------------------------------------------ OTHER IMPORTANT PROCEDURES and Codes ------------------------------------------------------------------------------------------ ****************************************************************************************** diff_fra.g: FRACTIONALLY DIFFERENCES THE SERIES, BASICALLY RETURNS ((1-L)^d)*Yt Format: yd=diff_fra(y,d); ****************************************************************************************** ARFIcoef.g: RETURNS THE POLYNOMIAL (1-L)^d Format: b=ARFIcoef(d,l); Inputs: d: fractional differencing order l: prespecified lag trunctation Ouptut: b: THE POLYNOMIAL (1-L)^d ****************************************************************************************** gph.g RETURNS THE GPH ESTIMATE OF d. Inputs: times series y~Tx1 Ouptut: d: GPH estimate of d ****************************************************************************************** RR.g RETURNS THE RR ESTIMATE OF d. Inputs: times series y~Tx1 Ouptut: d: RR estimate of d ****************************************************************************************** WHI.g RETURNS THE WHI ESTIMATE OF d. Inputs: times series y~Tx1 Ouptut: d: WHI estimate of d ****************************************************************************************** filt_tab.g Generates the values for the Table 1 "Table Long Meory Filter" ****************************************************************************************** ****************************************************************************************** MC_4000.g Carries out the Monte Carlo Analysis for Sample size 4000, and returns the data for Tables 8.2. WHILE YOU ARE RUNNING THIS CODE YOU CAN EASILY EXPECT TO WAIT A FEW MONTHS FOR IT TO RUN. The codeassumes that the following directories exist for it to save the results, there are 35 of them in all corresponding to 35 ARFIMA DGPs that are considered for the Monte Carlo section of the paper, For details see Table 7 in the paper. D:\ARFI_rev\data\mc\4000\dg1, D:\ARFI_rev\data\mc\4000\dg2 D:\ARFI_rev\data\mc\4000\dg3, D:\ARFI_rev\data\mc\4000\dg4 D:\ARFI_rev\data\mc\4000\dg5, D:\ARFI_rev\data\mc\4000\dg6 D:\ARFI_rev\data\mc\4000\dg7, D:\ARFI_rev\data\mc\4000\dg8 D:\ARFI_rev\data\mc\4000\dg9, D:\ARFI_rev\data\mc\4000\dg10 D:\ARFI_rev\data\mc\4000\dg11, D:\ARFI_rev\data\mc\4000\dg12 D:\ARFI_rev\data\mc\4000\dg13, D:\ARFI_rev\data\mc\4000\dg14 D:\ARFI_rev\data\mc\4000\dg15, D:\ARFI_rev\data\mc\4000\dg16 D:\ARFI_rev\data\mc\4000\dg17, D:\ARFI_rev\data\mc\4000\dg18 D:\ARFI_rev\data\mc\4000\dg19, D:\ARFI_rev\data\mc\4000\dg20 D:\ARFI_rev\data\mc\4000\dg21, D:\ARFI_rev\data\mc\4000\dg22 D:\ARFI_rev\data\mc\4000\dg23, D:\ARFI_rev\data\mc\4000\dg24 D:\ARFI_rev\data\mc\4000\dg25, D:\ARFI_rev\data\mc\4000\dg26 D:\ARFI_rev\data\mc\4000\dg27, D:\ARFI_rev\data\mc\4000\dg28 D:\ARFI_rev\data\mc\4000\dg29, D:\ARFI_rev\data\mc\4000\dg30 D:\ARFI_rev\data\mc\4000\dg31, D:\ARFI_rev\data\mc\4000\dg32 D:\ARFI_rev\data\mc\4000\dg33, D:\ARFI_rev\data\mc\4000\dg34 D:\ARFI_rev\data\mc\4000\dg35 ****************************************************************************************** ****************************************************************************************** STOCK_DATA.g Carries out the analysis of the Historical S&P 500 absolute return data series. WHILE YOU ARE RUNNING THIS CODE YOU CAN EASILY EXPECT TO WAIT A FEW WEEKS FOR IT TO RUN. Assumes that the data file is saved in the following location D:\ARFI_rev\data\snpret.txt Assumes that the following directory exists for it to save results chdir D:\ARFI_rev\Results ****************************************************************************************** ------------------------------------------------------------------------------------------ The Following Porcedures Prepare the Data for the codes ------------------------------------------------------------------------------------------ ****************************************************************************************** File: snw_load.g Assumes that the data files for Stock and Watson Macro Economic Dataset, are stored in d:\paper\snwatson\data This procedire imports the data and returns a matrix of data (let us call it DAT) that has 215 Columns For all the Macro Economic Data Series. The procedure also returns a column vector giving a code of what transformation is used Stock and Watson, We call it diff_ind. For all the missing data points Stock and Watson have coded those observations as 1.0000000e+032 (some series were shorter than others). Also there are Six possible values that the diff_ind acn take, The following commands will prepare the data for the code. For the ith column (i:1 to 215). (where diff is a small procedure to do differencing) dec_rule = dat[.,i] .lt 1.0000000e+032; y = selif(dat[.,i],dec_rule); if (diff_ind[.,i] == 4) or (diff_ind[.,i] == 5) or (diff_ind[.,i] == 6); y=ln(y); endif; if (diff_ind[.,i] == 2) or (diff_ind[.,i] == 5); y=diff(y,1); elseif diff_ind[.,i] == 6; y=diff(y,2); endif; ****************************************************************************************** ------------------------------------------------------------------------------------------ DATA ------------------------------------------------------------------------------------------ ****************************************************************************************** Folder: ws_data The folder contains all the data files for Stock and Watson Macro Economic Dataset, the files have extention .p59, We have maintained the files in the way they were downloaded from the Web Site of Mark Watson ****************************************************************************************** File: SNPRET.txt This file contains the data for the historical time series of S&P 500 Returns ****************************************************************************************** The Five international stock index series Dax.txt : DAX, the German Stock INDEX Ft.txt : FT, London Stock INDEX Hsg.txt : HSG, Hong Kong Stock INDEX Nkk.txt : NKK, Nikkei Stock Index SP.txt : SP, Standard & Poor's Index ******************************************************************************************