*! _fjcoint_cv_lambda.ado
*! 5% critical values for Fourier Lambda-max test
*! Source: Pascalau, Lee, Nazlioglu & Lu (2022), Online Appendix
*! Part of fjcoint package

program define _fjcoint_cv_lambda, rclass
  version 14.0

  args option model f m

  * option: 1=single, 2=cumulative
  * model:  1=Constant, 2=Trend, 3=RC, 4=RT
  * f: frequency (1-5)
  * m: number of variables (1-5)

  tempname cv_fl

  if `option' == 1 {
    if `model' == 1 {
      matrix `cv_fl' = ( ///
        14.30840, 21.81952, 28.35264, 34.91794, 41.17167 \ ///
        10.51359, 19.05594, 26.30747, 33.44158, 40.27457 \ ///
         9.40690, 17.35662, 24.69282, 32.11669, 38.74516 \ ///
         8.85902, 16.54828, 23.96644, 30.86204, 37.83603 \ ///
         8.62743, 16.07250, 22.72801, 30.08076, 36.78717 )
    }
    else if `model' == 2 {
      matrix `cv_fl' = ( ///
        18.09039, 25.46954, 32.22024, 38.25462, 44.55845 \ ///
        15.86571, 24.05796, 30.45904, 37.58944, 43.98831 \ ///
        14.21382, 22.17946, 29.61400, 36.66324, 42.69462 \ ///
        13.22626, 20.99576, 28.10436, 35.01388, 41.95523 \ ///
        12.58547, 20.27764, 27.17991, 34.32537, 41.09012 )
    }
    else if `model' == 3 {
      matrix `cv_fl' = ( ///
        14.74275, 22.19508, 28.89295, 35.39524, 41.54859 \ ///
        11.22645, 19.69620, 26.90804, 34.01138, 40.76375 \ ///
        10.24255, 18.08373, 25.11247, 32.64265, 39.36979 \ ///
         9.85987, 17.23072, 24.46652, 31.35129, 38.52174 \ ///
         9.53509, 16.79633, 23.37040, 30.58855, 37.49176 )
    }
    else if `model' == 4 {
      matrix `cv_fl' = ( ///
        18.90748, 26.44461, 33.03344, 39.23833, 45.38248 \ ///
        16.37934, 24.68322, 30.95725, 38.17910, 44.72682 \ ///
        14.82827, 22.90663, 30.23652, 37.29780, 43.44843 \ ///
        13.83531, 21.73118, 28.57067, 35.63663, 42.66692 \ ///
        13.28540, 20.82690, 27.77769, 35.06070, 41.73858 )
    }
  }
  else {
    * Cumulative frequency
    if `model' == 1 {
      matrix `cv_fl' = ( ///
        14.30840, 21.81952, 28.35264, 34.91794, 41.17167 \ ///
        19.73892, 27.76404, 35.04145, 41.93187, 48.45197 \ ///
        25.34511, 33.83060, 41.42773, 48.46413, 55.34988 \ ///
        30.39381, 39.85131, 47.92928, 55.37120, 62.26346 \ ///
        35.78632, 45.91888, 54.41220, 61.89791, 69.00940 )
    }
    else if `model' == 2 {
      matrix `cv_fl' = ( ///
        18.09039, 25.46954, 32.22024, 38.25462, 44.55845 \ ///
        24.65593, 32.06307, 38.79872, 45.22149, 52.11245 \ ///
        30.28825, 38.46600, 45.62627, 52.60794, 59.17533 \ ///
        36.91493, 44.75700, 52.37514, 59.21325, 65.76993 \ ///
        42.74488, 51.04538, 58.61760, 65.85758, 72.81402 )
    }
    else if `model' == 3 {
      matrix `cv_fl' = ( ///
        17.36134, 25.09009, 31.81531, 38.66757, 45.12572 \ ///
        25.51318, 34.10673, 41.34750, 48.25683, 55.09165 \ ///
        32.82653, 42.47500, 50.36196, 57.50662, 64.95132 \ ///
        40.45318, 50.95535, 59.10846, 67.01418, 73.76121 \ ///
        47.73399, 59.52646, 67.95760, 75.93939, 83.23137 )
    }
    else if `model' == 4 {
      matrix `cv_fl' = ( ///
        18.09039, 25.46954, 32.22024, 38.25462, 44.55845 \ ///
        24.65593, 32.06307, 38.79872, 45.22149, 52.11245 \ ///
        30.28825, 38.46600, 45.62627, 52.60794, 59.17533 \ ///
        36.91493, 44.75700, 52.37514, 59.21325, 65.76993 \ ///
        42.74488, 51.04538, 58.61760, 65.85758, 72.81402 )
    }
  }

  return scalar cv = `cv_fl'[`f', `m']
  return matrix cv_matrix = `cv_fl'

end