* This takes the UK.CAT example from the manual, * and adds instructions required to generate impulse * responses from the CATS model. * * See comment lines below for more info: * * Revision history: * July 7, 2004: * * Various updates in recent weeks to handle seasonal dummies properly * October 31, 2003: * * Add code to handle additional deterministic variables (tested with CIMEAN) * October 28, 2002: * * Change "com row = " line to reference K and L, not the hard-coded "5" and "3" of original example * * Add code to correctly support CIDRIFT and CIMEAN models calendar 1972 1 4 ; * rem: The starting -year -period periodicity allocate 1987:2 ; * rem: The date for the last observation open data c:\cats.104\uk.wk1 ; * rem: The datafile (a spreadsheet file) data(format=wks,org=obs) / p1 p2 e12 i1 i2 doilp0 doilp1 set p1_p2 / = p1 - p2 ; * rem: Two lines with data transformations set difp1 / = p1 - p1{1} open copy uk.out source C:\CATS.104\catsmain.src * * Execute CATS, specify your model, and do your * analysis. * * After selecting and estimating the desired model, * you will need to select the "Short Run Matrices" * operation, so that all the required coefficients * will be stored into global variables. * * Once you have completed this step, Quit out of CATS * and continue with the remainder of the program. * @cats(proc=I1,lags=4,dettrend=cidrift) 1972:2 1987:2 # p1_p2 e12 difp1 i1 i2 * Depending on choice of deterministic variables, * you may need a trend variable: set trend = t * Create first differences: diff p1_p2 / dp1_p2 diff e12 / de12 diff i1 / di1 diff i2 / di2 diff difp1 / ddifp1 * Define the VAR in error-correction form. Note * the lag length. Options for deterministic * variables depending on option choice in CATS: system 1 to 5 var dp1_p2 de12 ddifp1 di1 di2 lags 1 to 3 * CIDRIFT: det p1_p2{1} e12{1} difp1{1} i1{1} i2{1} constant trend * CIMEAN: *det p1_p2{1} e12{1} difp1{1} i1{1} i2{1} constant * DRIFT: *det p1_p2{1} e12{1} difp1{1} i1{1} i2{1} constant * If you have seasonal dummies, include them in this order * for DRIFT or CIDRIFT: * det p1_p2{1} e12{1} difp1{1} i1{1} i2{1} seasons{-10 to 0} constant * Use this order for CIMEAN: * det p1_p2{1} e12{1} difp1{1} i1{1} i2{1} constant seasons{-10 to 0} end(system) * Define identities--one for each variable. * These relate the differenced series to * the level series: equation(identity) id_p1p2 p1_p2 # dp1_p2 p1_p2{1} associate id_p1p2 # 1.0 1.0 equation(identity) id_e12 e12 # de12 e12{1} associate id_e12 # 1.0 1.0 equation(identity) id_i1 i1 # di1 i1{1} associate id_i1 # 1.0 1.0 equation(identity) id_i2 i2 # di2 i2{1} associate id_i2 # 1.0 1.0 equation(identity) id_difp1 difp1 # ddifp1 difp1{1} associate id_difp1 # 1.0 1.0 * Below are the gobal variables defined by CATS, * which contain the estimated coefficients: display 'The Pi matrix:' dis %pimat dis ; display 'Coefficients on deterministic variables: (not defined for CIMEAN unless using seasonal dummies)' dis detvarmat dis ; dis 'Short run coefficients:' dis ###.### shortrunvarmat * * If you did not specify a rank, or any restrictions, you * could reproduce the unrestricted results by simply doing: * * estimate(outsigma=v) * * at this point. * If you did specify a rank, impose restrictions, etc., you will * instead need to assign the coefficients estimated by CATS * to the appropriate equations, as shown below: * Set K = # of equations, L = # of lags in ECM form, * ADD = # of additional deterministic variables * (not including TREND or CONSTANT terms, which are set using DRIFT, CID, and CIM variables, as noted below * or seasonal dummies, handled by SDUM) * DRIFT = 1 if using DRIFT, = 0 if NOT using DRIFT * CID = 1 if using CIDRIFT, = 0 if NOT using CIDRIFT * CIM = 1 if using CIMEAN, = 0 if NOT using CIMEAN * SDUM = # of seasonal dummies (seasonal periods -1, for example, for monthly, SDUM=11) compute k = 5 compute L = 3 compute drift = 0 compute cid = 1 compute cim = 0 compute add = 0 compute sdum = 0 compute d = drift+cid+add dec vec[vec] eqcoeffs(k) do n=1,k * Dimensions coefficient arrays: compute numcoeff = (k*L)+k+d+cid+cim+sdum dim eqcoeffs(n)(numcoeff) * Copy short-run coefficients do c = 1,k*L com row = (1+(c-1)/L) + k*(%clock(c,L)-1) com eqcoeffs(n)(c) = shortrunvarmat(n,row) end com offset = k*L * Copy coefficients from Pi matrix do c=offset+1,offset+k com eqcoeffs(n)(c) = %pimat(n,c-offset) end compute offset = offset+k * If *not* CIMEAN: if cim==0 { do c=offset+1,offset+d com eqcoeffs(n)(c+sdum) = detvarmat(n,c-offset+sdum) end if cid==1 { * Get TREND coefficient if CIDRIFT model: if sdum==0 { compute offset = offset+d do c=offset+1,offset+cid com eqcoeffs(n)(c) = %pimat(n,k+1) end } else { com eqcoeffs(n)(numcoeff) = %pimat(n,k+1) } } } else { * Get CONSTANT coefficient if CIMEAN model: do c=offset+1,offset+cim com eqcoeffs(n)(c) = %pimat(n,k+1) end compute offset = offset+cim } * Get seasonal dummies if any: if sdum>0 { do c=offset+1,offset+sdum com eqcoeffs(n)(c) = detvarmat(n,c-offset) end } * Get additional exogenous I(0) variables, if any: if add>0 { do c=offset+1,offset+add com row = K*L+(c-offset) com eqcoeffs(n)(c) = shortrunvarmat(n,row) end } end do i=1,k associate i eqcoeffs(i) end * This generates impulse responses for 10 equations * (5 ECM equations plus 5 identities) for 24 steps, * generating responses for shocks to each of the * 5 equations, using a Choleski factorization of V: * * impulse(window='irfs from CATS results',results=catsirfs) 10 24 * %sigma # 1 # 2 # 3 # 4 # 5 # id_p1p2 # id_e12 # id_i1 # id_i2 # id_difp1 * Compare this to the results produced by estimating * the unrestricted model: * estimate(outsigma=v) impulse(window='irfs from ESTIMATE results',results=olsirfs) 10 24 * v # 1 # 2 # 3 # 4 # 5 # id_p1p2 # id_e12 # id_i1 # id_i2 # id_difp1