// coigamma_tables.ox written 26-06-2003 by Jurgen Doornik // prints tables for the critical values of the Trace and Max tests // based on the gamma-distribution approximations of Doornik (1998) #include #include #import static decl s_asCases = {"$H_z$", "$H_c$", "$H_{lc}$", "$H_l$", "$H_{ql}$"}; /////////////////////////////////////////////////////////////////////// TextToLatex(const s, const bIsMath) { decl i, j, c = sizeof(s), ch, bismath = bIsMath; decl sn = new string[2 * c]; for (i = j = 0; i < c; ++i, ++j) { ch = s[i]; if (ch == '$') bismath = !bismath; else if (ch == '%' || (!bismath && ch == '_') ) sn[j++] = '\\'; sn[j] = ch; } return sn[ : j - 1]; } PrintLatexTable(const sCaption, const sLabel, const asCol, asFmt, const mData, const asFootnotes) { decl i, ccol = sizec(mData), ascol, sfmt, asfmt, cfmt; if (ccol == 0) return; // construct column headers ascol = new array[ccol]; if (isarray(asFmt)) cfmt = sizeof(asFmt); else { cfmt = 1; asFmt = array(asFmt); } sfmt = cfmt > 1 ? "c" : "r"; for (i = 0, asfmt = {}; i < sizeof(ascol) - 1; ++i) { ascol[i] = TextToLatex(asCol[i], TRUE) ~ " &"; asfmt ~= (i < cfmt ? asFmt[i] : asFmt[cfmt - 1]) ~ " &"; sfmt ~= "r"; } ascol[i] = TextToLatex(asCol[i], TRUE) ~ " \\\\\n\\hline"; asfmt ~= (i < cfmt ? asFmt[i] : asFmt[cfmt - 1]) ~ " \\\\"; if (isstring(sCaption)) { println("\n\\begin{table}[!htb]"); println("\\caption{", TextToLatex(sCaption, FALSE), isstring(sLabel) ? "\\label{ta:" ~ sLabel ~ "}" : "", "}"); } println("\\["); println("\\begin{array}{", sfmt, "}"); print("\\hline\\hline"); println("%c", ascol, "%cf", asfmt, mData); println("\\hline"); if (isarray(asFootnotes)) { decl cfoot = sizeof(asFootnotes); for (i = 0; i < cfoot; ++i) println("\\multicolumn{", ccol, "}{l}{\\text{\\small ", TextToLatex(asFootnotes[i], FALSE), "}}", i < cfoot - 1 ? "\\vspace{-0.4ex}\\\\" : ""); } println("\\end{array}"); println("\\]"); if (isstring(sCaption)) println("\\end{table}"); } /////////////////////////////////////////////////////////////////////// PrintTable(const sTest, const iCase, mCrit, const vProb, const bLatex) { decl i, ascol, stitle; // construct column headers ascol = {"p-r"}; for (i = 0; i < sizerc(vProb); ++i) ascol ~= sprint("%#3.1f%%", 100 * vProb[i]); stitle = sprint("Asymptotic quantiles of ", sTest, " test for ", s_asCases[iCase]); mCrit = range(1, rows(mCrit))' ~ mCrit; if (bLatex) PrintLatexTable(stitle, sprint(sTest, iCase), ascol, {"%5.0f", "%#7.2f"}, mCrit, {"Generated from ox/lib/coigamma.ox, see Doornik(1998)"}); else println(stitle, "%c", ascol, "%cf", {"%5.0f", "%#7.2f"}, mCrit); } TraceTable(const iCase, const cN, const vProb, const bLatex) { decl gammapar, i, crit = <>, ascol; for (i = 1; i <= cN; ++i) { gammapar = GammaParTraceAsymp(iCase, i, 0); crit |= quangamma(vProb, gammapar[0], gammapar[1]); } PrintTable("Trace", iCase, crit, vProb, bLatex); } MaxTable(const iCase, const cN, const vProb, const bLatex) { decl gammapar, i, crit = <>, ascol; for (i = 1; i <= cN; ++i) { gammapar = GammaParMaxEvAsymp(iCase, i, 0); crit |= quangamma(vProb, gammapar[0], gammapar[1]); } PrintTable("Max", iCase, crit, vProb, bLatex); } /////////////////////////////////////////////////////////////////////// PrintPartialTable(const sTest, const iCase, mCrit, const vProb, const bIsPartial, const bLatex) { decl i, ascol, stitle; // construct column headers ascol = bIsPartial ? {"p_2", "p_1-r"} : {"s", "p-r-s"}; for (i = 0; i < sizerc(vProb); ++i) ascol ~= sprint("%#3.1f%%", 100 * vProb[i]); ascol ~= {"\\text{mean}", "\\text{var}"}; stitle = sprint("Asymptotic quantiles of ", sTest, " test for ", s_asCases[iCase]); if (bLatex) PrintLatexTable(stitle, sprint(sTest, iCase), ascol, {"%5.0f", "%5.0f", "%#7.2f"}, mCrit, {"Generated from ox/lib/coigamma.ox, see Doornik(1998)"} ~ (bIsPartial ? "$p_2$ is no of exogenous, $p_1$ number of endogenous variables." : "$s$ is no of I(1) and $p-r-s$ no of I(2) variables" ) ); else println(stitle, "%c", ascol, "%cf", {"%5.0f", "%#7.2f"}, mCrit); } PartialTable(const iCase, const cN, const vProb, const bLatex) { decl gammapar, i, j, crit = <>, ascol; for (i = 1; i <= cN; ++i) { for (j = 1; j <= cN - i + 1; ++j) { gammapar = GammaParI1CondAsymp(iCase, i + j, j, 0); crit |= i ~ j ~ quangamma(vProb, gammapar[0], gammapar[1]) ~ gammapar[0] / gammapar[1] ~ gammapar[0] / sqr(gammapar[1]); } } PrintPartialTable("Partial", iCase, crit, vProb, TRUE, bLatex); } /////////////////////////////////////////////////////////////////////// TraceI2Table(const iCase, const cN, const vProb, const bLatex) { decl gammapar, i, j, crit = <>, ascol; for (i = 0; i <= cN; ++i) { for (j = i == 0 ? 1 : 0; j <= cN - i; ++j) { gammapar = GammaParI2Asymp(iCase, 1, i, j); crit |= i ~ j ~ quangamma(vProb, gammapar[0], gammapar[1]) ~ gammapar[0] / gammapar[1] ~ gammapar[0] / sqr(gammapar[1]); } } PrintPartialTable("I2", iCase, crit, vProb, FALSE, bLatex); } /////////////////////////////////////////////////////////////////////// main() { decl blatex = TRUE; decl vprob = <0.5,0.75,0.8,0.85,0.9,0.95,0.975,0.99>; decl maxdim = 12; format(1000); if (blatex) { println("%% Copy of output saved to coigamma_tables.tex"); fopen("coigamma_tables.tex", "l"); println("\\documentclass[11pt]{article}"); println("\\usepackage{times,chicago,amsmath}"); println("\\addtolength{\\textheight}{5cm}"); println("\\addtolength{\\topmargin}{-2cm}"); println("\n\\begin{document}"); println("\\title{Asymptotic tables for cointegration tests based on the Gamma-distribution approximation}"); println("\\author{Jurgen A. Doornik\\\\"); println(" \\emph{Nuffield College, University of Oxford}"); println("}"); println("\\maketitle"); println("\nThese tables were generated using ox/lib/coigamma.ox, which implements"); println("the Gamma-distribution approximation of \\citeN{Doornik(98approx)}."); println("\nTables \\ref{ta:Trace0}--\\ref{ta:Trace4} replace Tables"); println("15.1--15.5 in \\citeN{Joha95}."); println("\nTables \\ref{ta:Partial0}--\\ref{ta:Partial3} replace Tables"); println("4,3,2 in: \\citeN{Harb98}."); println("\nTable \\ref{ta:I23} replaces Table 4 in"); println("\\citeN{RahbekKongstedJorgensen(1999)}."); println("\\bibliographystyle{chicago}"); println("\\bibliography{journals,jurgen,dynects}"); println("\\newpage"); } TraceTable(0, maxdim, vprob, blatex); TraceTable(1, maxdim, vprob, blatex); TraceTable(2, maxdim, vprob, blatex); TraceTable(3, maxdim, vprob, blatex); TraceTable(4, maxdim, vprob, blatex); MaxTable(0, maxdim, vprob, blatex); MaxTable(1, maxdim, vprob, blatex); MaxTable(2, maxdim, vprob, blatex); MaxTable(3, maxdim, vprob, blatex); MaxTable(4, maxdim, vprob, blatex); maxdim = 6; vprob = <0.5,0.8,0.9,0.95,0.975,0.99>; PartialTable(0, maxdim, vprob, blatex); PartialTable(1, maxdim, vprob, blatex); PartialTable(3, maxdim, vprob, blatex); TraceI2Table(3, 8, vprob, blatex); if (blatex) { println("\\end{document}"); } }