"delayspectral" package for gretl, by Sven Schreiber If you use it in a publication, please cite the following paper (and read the theory there, with a slightly changed notation): Breitung, Jörg, and Schreiber, Sven (2016): "Assessing Causality and Delay within a Frequency Band", Journal publication: "Econometrics and Statistics", vol 6 (2018), 57-73 (or IMK Working Paper 165, available at http://www.boeckler.de/imk_5279.htm?produkt=HBS-006295) The standard interface function 'phasedelay()' takes the following arguments to estimate an ARDL equation: - series y, LHS/target variable - series x, RHS/causal variable - list cond, further exogenous variables - py, lag order of y, default 4 (can be zero to omit lagged endogenous terms) - px, lag order of x, default 4 (at least 1; note that contemporaneous terms are not used) - cover, nominal conf. interval coverage prob., default 0.95 - plotting, boolean switch, default 1 (yes, do plots) - wc, boolean switch, default 1 (yes, include a constant term) The standard interface produces a plot (if not switched off) and returns a matrix: 1st col: frequency points 2nd col: 'raw' phase shifts (0;2pi) 3rd col: standard error of the phase (asympt.) 4th col: the 'unwrapped' phase 5th col: the 'unwrapped' time delay 6th col: lower CI bound of that time delay 7th col: upper CI bound of that time delay 8th col: |F_a|^2 = (1-c_a*)^2 + s_a*^2 9th col: |F_b*|^2 = s_b*^2 + c_b*^2 10th col: D = c_rho = c_b* (1-c_a*) - s_a* s_b* The 8th and 9th columns are plotted in a second graph. These values must not be too close to zero fo the method to work. The example script with the "hall" data also shows that in that case around frequency 3.0/3.1 this condition fails. The 'getPhaseARDL()' function is more low-level because it directly takes the coefficient vector (and covariance matrix). The underlying ARDL model notation is as follows (omitting the error term, and ignoring deterministic as well as further exogenous terms which can be added as conditioning variables for the estimation): a(L) y_t = b(L) x_{t-1} <=> y_t = a*(L) y_t + b*(L) x_t <=> y_t = [b(L)/a(L)] x_{t-1} Note that this is a reduced form since b*(L) = b(L)L (and a*(L) also starts at lag 1). Arguments: - matrix r: stacked coefficient vector b* and a* - matrix fpoints: vector of frequencies at which to evaluate the formulas - int p: the first p elements of r belong to b*, rest to a* - matrix pointer rCov (optional): covariance matrix of r vector (Is needed when the standard errors of the phase is wanted.) Returns 6-col matrix: - col 1: repeats the frequencies - col 2: phase shifts (range 0;2pi, not unwrapped) - col 3: standard errors of the phase (only if rCov was passed, else zeros) - col 4: as 8th col above in 'phasedelay' - col 5: as 9th col above in 'phasedelay' - col 6: as 10th col above in 'phasedelay' -------------- Index of functions (including private ones): - atan2wrapper: returns matrix - getS_C_J(): returns matrix - getPhaseARDL(): returns matrix; calls getS_C_J() - phaseunwrap(): returns matrix - phasedelay: returns matrix; interface function calls getPhaseARDL(), phaseunwrap ------------- Changelog: 1.0 March 2019, switch to gretl's built-in atan2 function, require 2018d because of that; add example for getPhaseARDL, internal replacement of 'isnull' and 'colnames'. 0.6 July 2016, inclusion of constant term by default, require gretl >= 2015c because of the use of string arrays internally 0.5 June 2016, initial public release