*! _fcoint_cv_feg2.ado -- FEG2 critical values
*! Banerjee & Lee (working paper) Tables 1a-1d
program define _fcoint_cv_feg2, rclass
  syntax, n(integer) k(integer) tobs(integer) model(string) rho2(real)
  if `n' < 1 local n = 1
  if `n' > 2 local n = 2
  if `k' < 1 local k = 1
  if `k' > 5 local k = 5
  local rho_idx = round(`rho2' * 10)
  if `rho_idx' < 1 local rho_idx = 1
  if `rho_idx' > 10 local rho_idx = 10
  * n=1, k=1, constant
  local f2_1_1_1_1  "-3.198 -2.520 -2.167 -3.192 -2.517 -2.159"
  local f2_1_1_2_1  "-3.544 -2.876 -2.522 -3.522 -2.863 -2.509"
  local f2_1_1_3_1  "-3.791 -3.136 -2.787 -3.761 -3.119 -2.775"
  local f2_1_1_4_1  "-4.001 -3.357 -3.014 -3.960 -3.331 -2.991"
  local f2_1_1_5_1  "-4.177 -3.542 -3.203 -4.125 -3.511 -3.180"
  local f2_1_1_6_1  "-4.340 -3.710 -3.377 -4.277 -3.667 -3.347"
  local f2_1_1_7_1  "-4.485 -3.860 -3.531 -4.401 -3.811 -3.497"
  local f2_1_1_8_1  "-4.620 -3.994 -3.673 -4.519 -3.940 -3.635"
  local f2_1_1_9_1  "-4.742 -4.122 -3.803 -4.629 -4.059 -3.760"
  local f2_1_1_10_1 "-4.858 -4.238 -3.923 -4.722 -4.167 -3.876"
  * n=1, k=2, constant
  local f2_1_2_1_1  "-3.069 -2.390 -2.028 -3.067 -2.385 -2.025"
  local f2_1_2_2_1  "-3.368 -2.693 -2.333 -3.357 -2.686 -2.331"
  local f2_1_2_3_1  "-3.602 -2.925 -2.567 -3.584 -2.921 -2.566"
  local f2_1_2_4_1  "-3.789 -3.119 -2.765 -3.762 -3.108 -2.756"
  local f2_1_2_5_1  "-3.959 -3.289 -2.935 -3.921 -3.270 -2.925"
  local f2_1_2_6_1  "-4.111 -3.443 -3.090 -4.058 -3.418 -3.075"
  local f2_1_2_7_1  "-4.247 -3.582 -3.232 -4.185 -3.552 -3.215"
  local f2_1_2_8_1  "-4.369 -3.710 -3.361 -4.300 -3.677 -3.340"
  local f2_1_2_9_1  "-4.491 -3.828 -3.483 -4.406 -3.792 -3.463"
  local f2_1_2_10_1 "-4.605 -3.943 -3.596 -4.498 -3.897 -3.575"
  * n=1, k=3, constant
  local f2_1_3_1_1  "-2.995 -2.320 -1.960 -2.998 -2.321 -1.962"
  local f2_1_3_2_1  "-3.265 -2.593 -2.235 -3.263 -2.593 -2.237"
  local f2_1_3_3_1  "-3.466 -2.795 -2.440 -3.462 -2.799 -2.446"
  local f2_1_3_4_1  "-3.644 -2.968 -2.614 -3.620 -2.965 -2.616"
  local f2_1_3_5_1  "-3.790 -3.117 -2.766 -3.770 -3.112 -2.767"
  local f2_1_3_6_1  "-3.919 -3.255 -2.901 -3.885 -3.240 -2.898"
  local f2_1_3_7_1  "-4.047 -3.374 -3.021 -4.002 -3.358 -3.018"
  local f2_1_3_8_1  "-4.160 -3.486 -3.135 -4.114 -3.471 -3.132"
  local f2_1_3_9_1  "-4.270 -3.595 -3.243 -4.208 -3.572 -3.237"
  local f2_1_3_10_1 "-4.377 -3.695 -3.341 -4.301 -3.669 -3.333"
  * n=1, k=4, constant
  local f2_1_4_1_1  "-2.962 -2.290 -1.933 -2.970 -2.296 -1.936"
  local f2_1_4_2_1  "-3.219 -2.547 -2.192 -3.222 -2.557 -2.199"
  local f2_1_4_3_1  "-3.405 -2.740 -2.385 -3.397 -2.744 -2.395"
  local f2_1_4_4_1  "-3.558 -2.896 -2.548 -3.549 -2.900 -2.554"
  local f2_1_4_5_1  "-3.698 -3.033 -2.687 -3.680 -3.037 -2.695"
  local f2_1_4_6_1  "-3.818 -3.156 -2.809 -3.794 -3.154 -2.818"
  local f2_1_4_7_1  "-3.928 -3.268 -2.927 -3.904 -3.269 -2.936"
  local f2_1_4_8_1  "-4.039 -3.372 -3.029 -3.999 -3.366 -3.034"
  local f2_1_4_9_1  "-4.142 -3.465 -3.124 -4.091 -3.458 -3.129"
  local f2_1_4_10_1 "-4.234 -3.557 -3.212 -4.170 -3.545 -3.217"
  * n=1, k=5, constant
  local f2_1_5_1_1  "-2.952 -2.273 -1.915 -2.958 -2.283 -1.924"
  local f2_1_5_2_1  "-3.189 -2.522 -2.167 -3.192 -2.530 -2.178"
  local f2_1_5_3_1  "-3.365 -2.703 -2.357 -3.368 -2.718 -2.369"
  local f2_1_5_4_1  "-3.517 -2.860 -2.514 -3.511 -2.868 -2.525"
  local f2_1_5_5_1  "-3.638 -2.992 -2.647 -3.638 -2.997 -2.658"
  local f2_1_5_6_1  "-3.754 -3.109 -2.767 -3.742 -3.112 -2.780"
  local f2_1_5_7_1  "-3.854 -3.208 -2.872 -3.838 -3.214 -2.885"
  local f2_1_5_8_1  "-3.958 -3.304 -2.969 -3.929 -3.307 -2.983"
  local f2_1_5_9_1  "-4.047 -3.392 -3.058 -4.013 -3.391 -3.071"
  local f2_1_5_10_1 "-4.135 -3.476 -3.142 -4.089 -3.475 -3.156"
  * n=2, k=1, constant
  local f2_2_1_1_1  "-3.311 -2.642 -2.284 -3.298 -2.629 -2.275"
  local f2_2_1_2_1  "-3.696 -3.036 -2.684 -3.682 -3.019 -2.669"
  local f2_2_1_3_1  "-3.989 -3.333 -2.987 -3.949 -3.311 -2.968"
  local f2_2_1_4_1  "-4.219 -3.578 -3.239 -4.171 -3.548 -3.215"
  local f2_2_1_5_1  "-4.428 -3.788 -3.454 -4.362 -3.749 -3.423"
  local f2_2_1_6_1  "-4.608 -3.979 -3.651 -4.525 -3.930 -3.612"
  local f2_2_1_7_1  "-4.765 -4.148 -3.822 -4.684 -4.093 -3.782"
  local f2_2_1_8_1  "-4.924 -4.304 -3.983 -4.810 -4.239 -3.938"
  local f2_2_1_9_1  "-5.069 -4.448 -4.131 -4.936 -4.372 -4.077"
  local f2_2_1_10_1 "-5.203 -4.585 -4.269 -5.047 -4.498 -4.210"
  * n=2, k=2, constant
  local f2_2_2_1_1  "-3.244 -2.570 -2.206 -3.234 -2.560 -2.201"
  local f2_2_2_2_1  "-3.610 -2.942 -2.585 -3.588 -2.925 -2.575"
  local f2_2_2_3_1  "-3.884 -3.225 -2.873 -3.858 -3.207 -2.857"
  local f2_2_2_4_1  "-4.119 -3.466 -3.113 -4.077 -3.434 -3.090"
  local f2_2_2_5_1  "-4.323 -3.670 -3.324 -4.263 -3.631 -3.293"
  local f2_2_2_6_1  "-4.502 -3.851 -3.507 -4.432 -3.809 -3.478"
  local f2_2_2_7_1  "-4.668 -4.014 -3.675 -4.584 -3.970 -3.649"
  local f2_2_2_8_1  "-4.815 -4.164 -3.829 -4.724 -4.119 -3.806"
  local f2_2_2_9_1  "-4.952 -4.305 -3.972 -4.848 -4.258 -3.948"
  local f2_2_2_10_1 "-5.079 -4.437 -4.108 -4.960 -4.384 -4.079"
  * n=2, k=3-5 use k=2 values
  forvalues kk = 3/5 {
    forvalues rr = 1/10 {
      local f2_2_`kk'_`rr'_1 "`f2_2_2_`rr'_1'"
    }
  }
  local mi = 1
  if "`model'" == "trend" local mi = 2
  local cvstr = "`f2_`n'_`k'_`rho_idx'_`mi''"
  if "`cvstr'" == "" {
    local cvstr = "`f2_`n'_`k'_`rho_idx'_1'"
  }
  tokenize `cvstr'
  if `tobs' <= 100 {
    local cv1  = `1'
    local cv5  = `2'
    local cv10 = `3'
  }
  else {
    local cv1  = `4'
    local cv5  = `5'
    local cv10 = `6'
  }
  return scalar cv1  = `cv1'
  return scalar cv5  = `cv5'
  return scalar cv10 = `cv10'
end