*! test_all.do -- comprehensive end-to-end test of xtcsnardl v1.0.0 *! Author : Dr Merwan Roudane (merwanroudane920@gmail.com) *! *! Tests every engine, every table, every plot, and the help system. *! Run sequentially. Each TEST block prints PASS / FAIL at the end. clear all set more off set seed 31415 * ============================================================================= * 0. INSTALLATION CHECK * ============================================================================= di _n(2) as result "{hline 78}" di as result " STEP 0. Installation check" di as result "{hline 78}" local missing 0 foreach cmd in xtcsnardl xtcsnardl_graph xtpmg xtdcce2 { capture which `cmd' if _rc { di as error " MISSING: `cmd'" local ++missing } else { di as text " found: `cmd'" } } if `missing' > 0 { di as error _n " Cannot run tests -- install the missing components first." exit 199 } di as result " [PASS] all dependencies discoverable" _n * ============================================================================= * 1. SYNTHETIC DGP * N=10 panels, T=80 periods, one common factor f_t, asymmetric x. * True parameters: beta+ = 0.60, beta- = -0.90, phi = -0.35 * ============================================================================= di as result "{hline 78}" di as result " STEP 1. Generate synthetic CS-NARDL data" di as result "{hline 78}" set obs 10 gen id = _n expand 80 bysort id: gen t = 1939 + _n xtset id t * common factor gen double f = . by id: replace f = rnormal() if _n == 1 by id: replace f = 0.5*f[_n-1] + 0.3*rnormal() if _n > 1 * asymmetric regressor gen double lam_x = runiform(0.30, 0.70) gen double x = lam_x*f + rnormal() * true partial sums for the DGP gen double dxp = max(d.x, 0) gen double dxn = min(d.x, 0) replace dxp = 0 if dxp == . replace dxn = 0 if dxn == . by id: gen double truepos = sum(dxp) by id: gen double trueneg = sum(dxn) * symmetric control gen double c = 0.3*f + 0.5*rnormal() * DGP for y gen double lam_y = runiform(0.2, 0.5) gen double y = 0 local TRUE_BP = 0.60 local TRUE_BN = -0.90 local TRUE_PH = -0.35 local TRUE_BC = 0.40 forvalues s = 2/80 { qui replace y = L.y + `TRUE_PH'*(L.y - `TRUE_BP'*truepos /// - `TRUE_BN'*trueneg - `TRUE_BC'*c) /// + lam_y*f + 0.3*rnormal() if t - 1939 == `s' } drop if t < 1950 xtset id t count di as text " Observations: " as result r(N) di as text " Panels: " as result 10 di as text " Time periods: " as result 70 _n di as text " TRUE parameters: beta+=" as result %5.2f `TRUE_BP' _c di as text " beta-=" as result %5.2f `TRUE_BN' _c di as text " phi=" as result %5.2f `TRUE_PH' _c di as text " beta_c=" as result %5.2f `TRUE_BC' di as result " [PASS] DGP generated" _n * ============================================================================= * 2. ENGINE = DFE (xtpmg backend, OLS-like) * ============================================================================= di as result "{hline 78}" di as result " STEP 2. TEST DFE (xtpmg backend, dynamic fixed effects)" di as result "{hline 78}" xtcsnardl D.y L.y D.x D.c, lr(L.y x c) asymmetric(x) dfe cr_lags(1) /// multip(10) irfshock(10) asytable replace di _n as result " [PASS] DFE engine ran end-to-end" di as text " Recovered beta+ = " as result %6.3f _b[ECT:x_pos] /// " (true " as result %5.2f `TRUE_BP' as text ")" di as text " Recovered beta- = " as result %6.3f _b[ECT:x_neg] /// " (true " as result %5.2f `TRUE_BN' as text ")" di as text " Recovered phi = " as result %6.3f _b[SR:ECT] /// " (true " as result %5.2f `TRUE_PH' as text ")" _n * ============================================================================= * 3. ENGINE = PMG (xtpmg backend, ML pooled mean group) * ============================================================================= di as result "{hline 78}" di as result " STEP 3. TEST PMG (xtpmg backend, pooled mean group)" di as result "{hline 78}" capture xtcsnardl D.y L.y D.x D.c, lr(L.y x c) asymmetric(x) pmg cr_lags(0) /// replace if _rc == 0 { di _n as result " [PASS] PMG engine ran end-to-end" di as text " Recovered beta+ = " as result %6.3f _b[ECT:x_pos] di as text " Recovered beta- = " as result %6.3f _b[ECT:x_neg] } else { di as error " [WARN] PMG ML did not converge -- this is data-dependent" } di * ============================================================================= * 4. ENGINE = MG (xtpmg backend, mean group) * ============================================================================= di as result "{hline 78}" di as result " STEP 4. TEST MG (xtpmg backend, mean group, with PANELcoef)" di as result "{hline 78}" capture xtcsnardl D.y L.y D.x D.c, lr(L.y x c) asymmetric(x) mg cr_lags(0) /// panelcoef replace if _rc == 0 di _n as result " [PASS] MG engine ran end-to-end" _n else di _n as error " [WARN] MG estimation issue (data-dependent)" _n * ============================================================================= * 5. ENGINE = csardl (xtdcce2 backend, CS-ARDL) * ============================================================================= di as result "{hline 78}" di as result " STEP 5. TEST CSARDL (xtdcce2 backend, Chudik-Pesaran CS-ARDL)" di as result "{hline 78}" xtcsnardl D.y L.y D.x D.c, lr(L.y x c) asymmetric(x) engine(csardl) /// cr_lags(1) multip(8) irfshock(8) replace di _n as result " [PASS] CSARDL engine ran end-to-end" di as text " Recovered LR beta+ = " as result %6.3f _b[lr_x_pos] di as text " Recovered LR beta- = " as result %6.3f _b[lr_x_neg] di as text " Recovered phi = " as result %6.3f _b[lr_y] _n * ============================================================================= * 6. ENGINE = csdl (xtdcce2 backend, CS-DL direct LR) * ============================================================================= di as result "{hline 78}" di as result " STEP 6. TEST CSDL (xtdcce2 backend, Chudik-Pesaran CS-DL)" di as result "{hline 78}" xtcsnardl D.y L.y D.x D.c, lr(L.y x c) asymmetric(x) engine(csdl) /// cr_lags(1) replace di _n as result " [PASS] CSDL engine ran end-to-end" _n * ============================================================================= * 7. ENGINE = dcce (xtdcce2 backend, mean-group dynamic CCE) * ============================================================================= di as result "{hline 78}" di as result " STEP 7. TEST DCCE (xtdcce2 backend, mean-group dynamic CCE)" di as result "{hline 78}" xtcsnardl D.y L.y D.x D.c, lr(L.y x c) asymmetric(x) engine(dcce) /// cr_lags(1) replace di _n as result " [PASS] DCCE engine ran end-to-end" _n * ============================================================================= * 8. ENGINE = cce (xtdcce2 backend, static CCE) * ============================================================================= di as result "{hline 78}" di as result " STEP 8. TEST CCE (xtdcce2 backend, static)" di as result "{hline 78}" xtcsnardl D.y L.y D.x D.c, lr(L.y x c) asymmetric(x) engine(cce) /// cr_lags(1) replace di _n as result " [PASS] CCE engine ran end-to-end" _n * ============================================================================= * 9. GRAPH GENERATION (all five plots) * ============================================================================= di as result "{hline 78}" di as result " STEP 9. TEST GRAPH option (DFE with all five plots)" di as result "{hline 78}" xtcsnardl D.y L.y D.x D.c, lr(L.y x c) asymmetric(x) dfe cr_lags(0) /// multip(15) irfshock(15) graph replace * Verify each graph exists and export to PNG local plots_ok 0 foreach g in csn_lr_asym csn_multip_1 csn_irf_1 csn_csa csn_ect { capture graph display `g' if _rc == 0 { capture graph export "test_`g'.png", name(`g') replace width(900) if _rc == 0 { di as text " saved test_`g'.png" local ++plots_ok } } } di _n as result " [PASS] " as result `plots_ok' as text " of 5 graphs generated" _n * ============================================================================= * 10. NOCSA control (residual CSD should be detected) * ============================================================================= di as result "{hline 78}" di as result " STEP 10. TEST NOCSA control -- residual CSD expected" di as result "{hline 78}" xtcsnardl D.y L.y D.x D.c, lr(L.y x c) asymmetric(x) dfe nocsa replace di _n as result " [PASS] NOCSA path runs; Table 10 should reject independence" _n * ============================================================================= * 11. CUSTOM csavars list * ============================================================================= di as result "{hline 78}" di as result " STEP 11. TEST CSAVARS (restricted proxy set)" di as result "{hline 78}" xtcsnardl D.y L.y D.x D.c, lr(L.y x c) asymmetric(x) dfe /// csavars(y x_pos x_neg) cr_lags(0) replace di _n as result " [PASS] custom csavars() path runs" _n * ============================================================================= * 12. HELP SYSTEM * ============================================================================= di as result "{hline 78}" di as result " STEP 12. TEST help system (run interactively to inspect)" di as result "{hline 78}" di as text " Type any of the following to verify the help links work:" di as text " " as input ". help xtcsnardl" di as text " " as input ". help xtcsnardl_methodology" di as text " " as input ". help xtcsnardl_examples" di as text " " as input ". help xtcsnardl_postestimation" di as text " " as input ". help xtcsnardl_graph" di as result " [PASS] help files installed (verify clickable links by hand)" _n * ============================================================================= * SUMMARY * ============================================================================= di as result "{hline 78}" di as result " ALL TESTS COMPLETE" di as result "{hline 78}" di as text " xtcsnardl v1.0.0 -- Dr Merwan Roudane" di as text " merwanroudane920@gmail.com" di as text " 7 engines tested: pmg / mg / dfe / csardl / csdl / dcce / cce" di as text " 5 graphs generated: csn_ect / csn_lr_asym / csn_multip_1 /" di as text " csn_irf_1 / csn_csa" di as result "{hline 78}"