@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@ INDEX OF GAUSS CODES AND DATA FILES FOR Geetesh Bhardwaj,Valentina Corradi, and Norman R. Swanson, June 2005, "A Simulation Based Specification Test for Diffusion Processes" IF YOU FIND ANY BUGS, OR HAVE ANY SUGGESTIONS TO IMPROVE SPEED PLEASE DO SEND YOUR COMMENTS TO bhardwaj@econ.rutgers.edu @@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@ ################################################################################################################# DATA ################################################################################################################# @@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@*/ File: ed1_w.txt This file contains the data for one-month Eurodollar deposits rate for the period January 6, 1971 - April 8, 2005 (1,789 weekly observations) Location: c: The codes expect the file ed1_w.txt is saved in c: @@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@*/ ################################################################################################################# CODES ################################################################################################################# /*@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@ REQUIRED GAUSS LIBRARIES (a) CML (b) PGRAPH @@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@*/ ***************************************************************************************************************** OUTLINE OF THE MAIN PROCEDURES ***************************************************************************************************************** /*@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@ * dgp_cir: Data Generation as CIR process * * dX(t)=phi*(X_bar-X(t))*dt+sig1*sqrt(X(t)*dW(t) * ***************************************************************************************************************** * Inputs: T - Length of time series * * h - discretization interval * * phi - mean reversion parameter Process * * X_bar - mean level * * sig1 - variance term * * start - starting value of the process * * Output: dat - time series * @@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@*/ /*@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@ * dgp_cirs: SAME AS dgp_cir BUT USES GLOBAL ERRORS UNLIKE dgp_cir WHERE ERRORS ARE GENERATED IN THE PROCEDURE * @@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@*/ /*@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@ * sgmm_cir: Returns the obj func to be minimized for estimating the parameters of OU process * * dX(t)=phi*(X_bar-X(t))*dt+sig1*sqrt(X(t)*dW(t) * ***************************************************************************************************************** * Inputs: b1 - starting values * * x1 - time series * * Output: obj - the objective function to be minimised * @@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@*/ /*@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@ * start_cir: Returns the starting values for the CIR process * * dX(t)=phi*(X_bar-X(t))*dt+sig1*sqrt(X(t)*dW(t) * ***************************************************************************************************************** * Inputs: y - time series * * Output: b - 1x3 vector of starting values for phi x_bar and sig1 * @@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@*/ /*@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@ * ineq_CIR: Single Factor Square Root Process Nonlinear Inequality constraint for optimization * ***************************************************************************************************************** * dX(t)=phi*(X_bar-X(t))*dt+sig1*sqrt(X(t)*dW(t) * * Nonlinear Inequality constraints * * 2*phi*X_bar >= sig11^2 * @@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@*/ /*@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@ * dgp_ou: Data Generation as OU process * * dX(t)=phi*(X_bar-X(t))*dt+sig2*dW(t) * ***************************************************************************************************************** * Inputs: T - Length of time series * * h - discretization interval * * phi - mean reversion parameter Process * * X_bar - mean level * * sig2 - variance term * * start - starting value of the process * * Output: dat - time series * @@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@*/ /*@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@ * dgp_ous: SAME AS dgp_ou BUT USES GLOBAL ERRORS UNLIKE dgp_ou WHERE ERRORS ARE GENERATED IN THE PROCEDURE * @@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@*/ /*@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@ * sgmm_ou: Returns the obj func to be minimized for estimating the parameters of OU process * * dX(t)=phi*(X_bar-X(t))*dt+sig2*dW(t) * ***************************************************************************************************************** * Inputs: b1 - starting values * * x1 - time series * * Output: obj - the objective function to be minimised * @@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@*/ /*@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@ * start_ou: Returns the starting values for the OU process * * dX(t)=phi*(X_bar-X(t))*dt+sig2*dW(t) * ***************************************************************************************************************** * Inputs: y - time series * * Output: b - 1x3 vector of starting values for phi x_bar and sig2 * @@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@*/ /*@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@ * est_cir: returns the SGMM estimates and standard errors for CIR process * ***************************************************************************************************************** * Inputs: x1 - time series * * Output: b_cir - estimates * * se_cir - GMM standard errors * * NOTE: THE ESTIMATES ARE NOT ANNUALISED VESRIONS REPORTED IN PAPER, ESTIMATES ARE WEEKLY * @@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@*/ /*@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@ * est_OU: returns the SGMM estimates and standard errors for OU process * ***************************************************************************************************************** * Inputs: x1 - time series * * Output: b_OU - estimates * * se_OU - GMM standard errors * @@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@*/ /*@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@ * Lden: returns the Kernal density * ***************************************************************************************************************** * Inputs: arg - the values at which the density is to evaluated * * v - The realized values of the series for which density is to be estimates * * Output: p - density * @@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@*/ /*@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@ * sim_Lden: returns the Kernal density for 1,2,4, and 12 step ahead simulations * ***************************************************************************************************************** * Inputs: x - The time series * * b1 - Estimated coefficients * * mod_ind - Model indicator: 1 for CIR, 2 for OU * * Output: arg - Points where density is evaluated * * den1 - 1 step ahead simulated density * * den2 - 2 step ahead simulated density * * den4 - 5 step ahead simulated density * * den12 - 12 step ahead simulated density * @@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@*/ /*@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@ * BCS_stat: Calculates The Test Statistics * ***************************************************************************************************************** * Inputs: xt - time series * * tao - a vector indicating the different step ahead conf. int. to be examined * * s - number of sample paths to be simulated * * mod_ind - model specification 1 for CIR and 2 for log ou * * xt_v - time series for calculating v * * h - discretization interval * * u_bar - confidence interval * * Output: vt - pre sup pre sum vt to use in bootstrap procedure * * sup_vt - Test statistics will have rows(tao) results * @@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@*/ /*@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@ * boot1: Generates the block bootstrap sample * ***************************************************************************************************************** * Inputs: dat1 - time series * * lval - block boot length * * Output: xb1 - bootstrap sample * @@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@*/ /*@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@ * BCS_boot: Calculates The Statistics * ***************************************************************************************************************** * Inputs: xt - time series * * tao - a vector indicating the different step ahead conf. int. to be examined * * s - number of sample paths to be simulated * * mod_ind - model specification 1 for CIR and 2 for log ou * * vt - pre sup pre sum vt returned by the BCS_stat * * bL - block boot length * * bs - number of bootstrap replication * * u_bar - confidence interval * * Output: b_sup_vt- boot strap distribution, sorted 100 rows and rows(tao) cols * * cv95 - 95% critical value * * cv90 - 90% critical value * * cv80 - 80% critical value * @@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@*/ ***************************************************************************************************************** OUTLINE OF THE THREE MAIN CODES ***************************************************************************************************************** /*@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@ FIG_DEN.G: Returns figures 2 and 3, both panels, also returns the data that plots the four figures The codes expect the data file 'ed1_w.txt' is saved in c: The results are saved in the following location; "c:\fig_data.out". In the data the first column is the “arg”, i.e. the 200 points at which the density for the observed series, and for various tao-step ahead simulated series is calculated. Second column “True” is the density of the observed series, third column “1-Step” is the density for one step ahead simulated series, fourth column “2-Step” is the density for two step ahead simulated series, fifth column “4-Step” is the density for four step ahead simulated series, and the last column “12-step” is the density for twelve step ahead simulated series. In all; four set of data matrices are returned for four figures. Further 'arg' is a grid of 200 points in the set [x_min, x_max] @@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@*/ /*@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@ EMP.G: code for the emperical section, generates Table 6 and 7. The codes expect the data file 'ed1_w.txt' is saved in c: The results are saved in the following location; "c:\emp.out". Currently the code is set to generate the statistics and the critical values (95%, 905 and 80%) for the full sample period of January 6, 1971 - April 8, 2005 (1,789 weekly observations), when the null is for OU process, boot length is 20, number of paths to be simulate is 10 times the length of time series, and the conf int is (meanc(xt)-1*stdc(xt))|(meanc(xt)+1*stdc(xt). for getting the full table following choices should be changed. mod_ind is set to 2 /*Model indicator = 1 for CIR and 2 for OU*/ bl is set to 20 /*block length for the bootstrap*/ u_bar is set (meanc(xt)-1*stdc(xt))|(meanc(xt)+1*stdc(xt)); /*the interval u_bar*/ the other three choices of the interval are (meanc(xt)-0.25*stdc(xt))|(meanc(xt)+0.25*stdc(xt)), (meanc(xt)-0.5*stdc(xt))|(meanc(xt)+0.5*stdc(xt)), and (meanc(xt)-2*stdc(xt))|(meanc(xt)+2*stdc(xt)); S is set to 10*(rows(xt)-tao[rows(tao)]); it can be set to 20 or 30 times the sample size. @@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@*/ /*@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@ MC.G: Code for the Monte Carlo section, generates Table 1 to 4. The results are saved in the following location; "c:\MC.out". currently the ocde is set to run the power experiment for CIR peocess; to get all the variations of tables 1 to 4 change the following T=400; /*Sample size, other option is 800*/ true_ind=1; /*True indicator, this will determine the true DGP Process 1 for CIR 2 for OU if you cahnge this remember to change the parameter values*/ mod_ind=2; /*Model indicator, the model this is the one that is fit under the null 1 for CIR 2 for OU*/ tao=1|2|4|12; /*Sets the value of tao*/ /*Model Parameters*/ /* for the OU process the choices are (0.10,-2.00, 0.30), these should be used if true_ind=2 */ Phi_1=0.30; p_bar_1=0.05; sig1_1=0.10; S=10*(T-tao[rows(tao)]); /*selects the number of simulation paths other choices include 20*(rows(xt)-tao[rows(tao)]); and 30*(rows(xt)-tao[rows(tao)]);*/ bs=100; /*number of bootstrap replications*/ bl=20; /*block length for the bootstrap*/ u_bar=(meanc(xt)-1*stdc(xt))|(meanc(xt)+1*stdc(xt)); /*the interval u_bar*/ the other three choices of the interval are (meanc(xt)-0.25*stdc(xt))|(meanc(xt)+0.25*stdc(xt)), (meanc(xt)-0.5*stdc(xt))|(meanc(xt)+0.5*stdc(xt)), and (meanc(xt)-2*stdc(xt))|(meanc(xt)+2*stdc(xt)); @@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@*/