*! xtpstat 1.0.0  23jul2026   (xtpdroot library)
*! PANIC panel stationarity test (Bai & Ng 2005): tests the stationarity of the
*! idiosyncratic component after extracting common factors by principal comps.
*!
*! Author : Dr Merwan Roudane  merwanroudane920@gmail.com
*!          https://github.com/merwanroudane
*! Part of the -xtpdroot- library : second-generation panel unit-root and
*! stationarity tests robust to cross-sectional dependence.
*!
*! Faithful port of the GAUSS routine BNG_PANICkpss by Saban Nazlioglu.
*!   Non-commercial use.
*!
*! References:
*!   Bai, J., Ng, S. (2004). A PANIC attack on unit roots and cointegration.
*!     Econometrica 72: 1127-1177.
*!   Bai, J., Ng, S. (2010). Panel unit root tests with cross-section dependence:
*!     a further investigation. Econometric Theory 26: 1088-1114.
*!   Nazlioglu, S., et al. (2021). Convergence in OPEC carbon dioxide emissions.
*!     Economic Modelling 100: 105498. <doi:10.1016/j.econmod.2021.105498>
*!
*! Step -> code map (see -help xtpstat methods-):
*!   common factors (Bai-Ng 2002 IC + PCA)       -> _xtps_fnumber2 / _xtps_pca
*!   idiosyncratic KPSS (SPC long-run variance)  -> _xtps_kpss / _xtps_alrv
*!   response-surface p-values                    -> _xtps_pval
*!   pooled Ppc, Pm, Zpc, W                       -> _xtps_run

program xtpstat, rclass
    version 14.0

    syntax varname(numeric ts) [if] [in] [ ,   ///
        METHod(string)                          ///
        MODel(string)                           ///
        Kmax(integer 5)                         ///
        ICfactor(integer 2)                     ///
        Factors(integer 0)                      ///
    ]

    if "`model'" == "" local model "trend"
    local model = lower("`model'")
    if      inlist("`model'","c","const","constant") local d 1
    else if inlist("`model'","t","trend","ct")       local d 2
    else {
        di as error "xtpstat: model() must be constant or trend."
        exit 198
    }

    * method: 0 = Yin-Wu (no CSD correction); 1 = PANIC (PCA); 2 = Hadri-Kurozumi CA
    if "`method'" == "" local method "panic"
    local method = lower("`method'")
    if      inlist("`method'","panic","pc","pca")        local mc 1
    else if inlist("`method'","yinwu","yw","none")       local mc 0
    else if inlist("`method'","hkca","ca","kurozumi")    local mc 2
    else {
        di as error "xtpstat: method() must be yinwu, panic or hkca."
        exit 198
    }

    quietly xtset
    local pv "`r(panelvar)'"
    local tv "`r(timevar)'"
    if "`pv'" == "" | "`tv'" == "" {
        di as error "xtpstat: data must be {help xtset}."
        exit 459
    }
    if "`r(balanced)'" != "strongly balanced" {
        di as error "xtpstat: requires a strongly balanced panel."
        exit 459
    }

    marksample touse
    markout `touse' `pv' `tv'
    quietly count if `touse'
    local NT = r(N)
    quietly levelsof `pv' if `touse', local(ids)
    local N : word count `ids'
    local T = `NT'/`N'
    if `T' != int(`T') | `N'*`T' != `NT' {
        di as error "xtpstat: unbalanced over the selected sample."
        exit 459
    }
    if `T' < 12 {
        di as error "xtpstat: need at least 12 time periods (found `T')."
        exit 2001
    }

    tempname R OUT
    mata: _xtps_run("`varlist'", "`touse'", `N', `T', `d', `kmax', `icfactor', `factors', `mc')
    matrix `R'   = r(pooled)
    matrix `OUT' = r(units)

    * ----- display -----------------------------------------------------------
    local mdesc = cond(`d'==1,"Constant","Constant and trend")
    local icfd  = cond(`icfactor'==1,"PCp",cond(`icfactor'==2,"ICp","AIC/BIC"))
    local mname = cond(`mc'==0,"Yin-Wu (no CSD correction)", ///
                  cond(`mc'==1,"PANIC (principal components)","Hadri-Kurozumi (cross-section aug.)"))
    local h0    = cond(`mc'==1,"idiosyncratic component is stationary","series are stationary")
    di ""
    di as text "Panel stationarity test: " as result "`mname'"
    di as text "{hline 62}"
    di as text "Panel var" _col(14) ": " as result "`pv'" ///
        as text _col(42) "N" _col(50) "= " as result %5.0f `N'
    di as text "Time var" _col(14) ": " as result "`tv'" ///
        as text _col(42) "T" _col(50) "= " as result %5.0f `T'
    if `mc'==1 {
        di as text "Model" _col(14) ": " as result "`mdesc'" ///
            as text _col(42) "Factors" _col(50) "= " as result %3.0f `R'[5,1] ///
            as text " (`icfd')"
    }
    else {
        di as text "Model" _col(14) ": " as result "`mdesc'"
    }
    di as text "H0: `h0'"
    di as text "{hline 62}"
    di as text "  Pooled test" _col(26) "Statistic" _col(42) "p-value"
    di as text "{hline 62}"
    _xtps_prow "P   (Fisher chi2)"  `R'[1,1] `R'[1,2]
    _xtps_prow "Pm  (standardized)" `R'[2,1] `R'[2,2]
    _xtps_prow "Z   (inverse-normal)" `R'[3,1] `R'[3,2]
    _xtps_prow "W   (Hadri LM)"     `R'[4,1] `R'[4,2]
    di as text "{hline 62}"
    local khdr = cond(`mc'==1,"idiosyncratic KPSS","KPSS")
    di as text "  Per-unit `khdr':"
    di as text "   id" _col(14) "KPSS" _col(28) "p-value"
    forvalues i = 1/`N' {
        di as text "  " %4.0f `OUT'[`i',1] _col(11) as result %9.4f `OUT'[`i',2] ///
            _col(28) %7.3f `OUT'[`i',3]
    }
    di as text "{hline 62}"
    di as text "Note: reject H0 (=> unit root / non-stationary) for large Ppc/Pm/W"
    di as text "      or very negative Zpc.  *** p<.01, ** p<.05, * p<.10."

    * ----- returns -----------------------------------------------------------
    return scalar Ppc  = `R'[1,1]
    return scalar Ppc_p= `R'[1,2]
    return scalar Pm   = `R'[2,1]
    return scalar Pm_p = `R'[2,2]
    return scalar Zpc  = `R'[3,1]
    return scalar Zpc_p= `R'[3,2]
    return scalar W    = `R'[4,1]
    return scalar W_p  = `R'[4,2]
    return scalar nf   = `R'[5,1]
    return scalar N    = `N'
    return scalar T    = `T'
    return matrix units = `OUT'
    return local  cmd  "xtpstat"
end

program _xtps_prow
    args label stat pval
    local star = cond(`pval'<0.01,"***",cond(`pval'<0.05,"**",cond(`pval'<0.10,"*","")))
    di as text "  " %-22s "`label'" as result _col(26) %9.3f `stat' ///
        _col(42) %7.3f `pval' "  `star'"
end


* =========================================================================
* Mata engine
* =========================================================================
version 14.0
mata:

real scalar _xtps_argmin(real colvector v)
{
    real scalar i, mn, mi
    mn = v[1]; mi = 1; i = 2
    while (i <= rows(v)) {
        if (v[i] < mn) {
            mn = v[i]
            mi = i
        }
        i = i + 1
    }
    return(mi)
}

real colvector _xtps_lagn_k(real colvector x, real scalar k)
{
    real scalar t
    t = rows(x)
    return((J(k,1,0)) \ x[1..t-k])
}

// ---- factor engine (shared) -------------------------------------------
void _xtps_pca(real matrix X, real scalar nf, real matrix Fhat, real matrix lambda, real matrix ehat)
{
    real scalar t, n
    real matrix evec, A
    real rowvector eval
    real colvector ord
    t = rows(X); n = cols(X)
    if (t < n) {
        A = X*X'
        symeigensystem(A, evec, eval)
        ord = order(eval', -1)
        Fhat = sqrt(t) * evec[., ord[1..nf]]
        lambda = luinv(cross(Fhat,Fhat)) * cross(Fhat,X)
        ehat = X - Fhat*lambda
    }
    else {
        A = X'X
        symeigensystem(A, evec, eval)
        ord = order(eval', -1)
        lambda = sqrt(n) * evec[., ord[1..nf]]
        Fhat = X*lambda/n
        ehat = X - Fhat*lambda'
    }
}

real scalar _xtps_fnumber2(real matrix X, real scalar kmax, real scalar ic)
{
    real scalar t, n, sigma2, k, mn
    real matrix Fhat, lambda, ehat, ICp
    real colvector V
    t = rows(X); n = cols(X)
    _xtps_pca(X, kmax, Fhat, lambda, ehat)
    sigma2 = sum(ehat:^2)/(n*t)
    mn = min((n,t))
    V = J(kmax,1,0)
    ICp = J(kmax,1,0)
    k = 1
    while (k <= kmax) {
        _xtps_pca(X, k, Fhat, lambda, ehat)
        V[k] = sum(ehat:^2)/(n*t)
        if (ic == 1)      ICp[k] = V[k] + k*sigma2*(n+t)/(n*t)*ln(mn)
        else if (ic == 2) ICp[k] = ln(V[k]) + k*(n+t)/(n*t)*ln(mn)
        else              ICp[k] = V[k] + k*sigma2*(ln(t)/t)
        k = k + 1
    }
    return(_xtps_argmin(ICp))
}

// ---- SPC prewhitened Bartlett long-run variance (Sul-Phillips-Choi 03) -
real scalar _xtps_alrv(real colvector e, real scalar lags)
{
    real scalar t, i, j, bic, minbic, kk, l, lrv, w, a, lrvre, sr
    real matrix temp
    real colvector rho, res, resl, r
    t = rows(e)
    if (lags <= 0) lags = 1
    minbic = 1e25
    rho = J(1,1,0)
    res = e
    i = 1
    while (i <= lags) {
        temp = e
        j = 1
        while (j <= i) {
            temp = temp , _xtps_lagn_k(e, j)
            j = j + 1
        }
        temp = temp[(i+1)..rows(temp), .]
         r = qrsolve(temp[.,2..cols(temp)], temp[.,1])
        resl = temp[.,1] - temp[.,2..cols(temp)]*r
        bic = ln(cross(resl,resl)/(t-lags)) + i*ln(t-lags)/(t-lags)
        if (bic < minbic) {
            minbic = bic
            kk = i
            rho = r
            res = resl
        }
        i = i + 1
    }
    // AR(1) approximation on prewhitened residuals
    sr = rows(res)
    a = qrsolve(res[1..sr-1], res[2..sr])
    l = trunc(1.1447*(4*a^2*t/((1+a)^2*(1-a)^2))^(1/3))
    lrv = cross(res,res)/t
    i = 1
    while (i <= l) {
        w = 1 - i/(l+1)
        lrv = lrv + 2*cross(res[1..sr-i], res[1+i..sr])*w/t
        i = i + 1
    }
    // Sul-Phillips-Choi (2003) boundary rule: min(recolored, T * long-run)
    lrvre = lrv/(1-sum(rho))^2
    lrv = min((lrvre, t*lrv))
    return(lrv)
}

// ---- idiosyncratic KPSS statistic -------------------------------------
real scalar _xtps_kpss(real colvector y, real matrix z)
{
    real scalar t, lrv, lm
    real colvector b, e1, S
    t = rows(y)
    b = qrsolve(z, y)
    e1 = y - z*b
    S = runningsum(e1)
    lrv = _xtps_alrv(e1, 5)
    lm = sum(S:^2)/(t^2*lrv)
    return(lm)
}

// ---- 221-percentile grid ----------------------------------------------
real colvector _xtps_pgrid()
{
    return((0.0001 \ 0.0002 \ 0.0005) \ ((1::9)/1000) \ (0.005:*(2::198)) \ ((991::999)/1000) \ (0.9995 \ 0.9998 \ 0.9999))
}

// ---- KPSS response-surface p-value (upper tail) -----------------------
real scalar _xtps_pval(real scalar test, real scalar T, real scalar model)
{
    real matrix params, Xw
    real colvector p, reg, cv, yv, bw, idx
    real scalar it, mn, mx, bands, lower, lo, hi, pval
    if (model == 1) params = _xtps_rs1()
    else            params = _xtps_rs2()
    it = 1/T
    reg = (1 \ it \ it^2 \ it^3 \ it^4)
    cv = params*reg
    p = _xtps_pgrid()
    mn = min(cv); mx = max(cv)
    if (test < mn) return(1)
    if (test > mx) return(0.0001)
    bands = 10
    idx = selectindex(cv :<= test)
    lower = max(idx)
    lo = lower - bands + 1
    hi = lower + bands
    if (lower < bands) {
        lo = 1
        hi = bands
    }
    if (lower > rows(cv)-bands) {
        lo = rows(cv) - bands - 1
        hi = rows(cv)
    }
    yv = invnormal(p[lo..hi])
    Xw = J(hi-lo+1,1,1) , cv[lo..hi] , cv[lo..hi]:^2
    bw = qrsolve(Xw, yv)
    pval = 1 - normal((1, test, test^2) * bw)
    if (pval > 1) pval = 1
    if (pval < 0) pval = 0.0001
    return(pval)
}

// ---- driver ------------------------------------------------------------
void _xtps_run(string scalar vname, string scalar touse, real scalar N, real scalar T, real scalar d, real scalar kmax, real scalar ick, real scalar forcenf, real scalar method)
{
    real colvector yv, kp, pval, ca
    real matrix Y, x, Fhat, lambda, ehat, series, det, z, units, pooled
    real scalar nf, i, P, Pm, Z, W, mu, vv, Tstat

    yv = st_data(., vname, touse)
    Y = rowshape(yv, N)'
    ca = J(rows(Y),1,0)

    if (method == 1) {
        // PANIC: PCA on differenced data, test the cumulated idiosyncratic
        x = Y[2..T,.] - Y[1..T-1,.]
        if (d == 2) x = x :- mean(x)
        if (forcenf > 0) nf = forcenf
        else             nf = _xtps_fnumber2(x, kmax, ick)
        _xtps_pca(x, nf, Fhat, lambda, ehat)
        series = _xtps_cumsum(ehat)
    }
    else {
        // Yin-Wu / Hadri-Kurozumi CA: test the raw series
        series = Y
        nf = .
        if (method == 2) ca = rowsum(Y)/N
    }
    Tstat = rows(series)
    if (d == 1) det = J(Tstat,1,1)
    else        det = J(Tstat,1,1) , (1::Tstat)

    kp   = J(N,1,.)
    pval = J(N,1,.)
    i = 1
    while (i <= N) {
        if (method == 2) z = det , ca
        else             z = det
        kp[i]   = _xtps_kpss(series[.,i], z)
        pval[i] = _xtps_pval(kp[i], Tstat, d)
        i = i + 1
    }

    P  = -2*sum(ln(pval))
    Pm = (P - 2*N)/sqrt(4*N)
    Z  = sum(invnormal(pval))/sqrt(N)
    if (d == 1) {
        mu = 1/6
        vv = 1/45
    }
    else {
        mu = 1/15
        vv = 11/6300
    }
    W  = sqrt(N)*(mean(kp) - mu)/sqrt(vv)

    units = (1::N) , kp , pval
    pooled = (P , chi2tail(2*N, P)) \ (Pm , 1-normal(Pm)) \ (Z , normal(Z)) \ (W , 1-normal(W)) \ (nf , .)
    st_matrix("r(units)", units)
    st_matrix("r(pooled)", pooled)
}

real matrix _xtps_cumsum(real matrix X)
{
    real matrix S
    real scalar j
    S = X
    j = 1
    while (j <= cols(X)) {
        S[.,j] = runningsum(X[.,j])
        j = j + 1
    }
    return(S)
}


// ---- PANIC-KPSS response-surface tables (221x5, model 1=const 2=trend) ----
// CV(p,T) = c1 + c2/T + c3/T^2 + c4/T^3 + c5/T^4 (appl3_panic rsf)
real matrix _xtps_rs1()
{
    string scalar s
    s = "0.01240 0.39950 -29.29040 1221.61310 -16747.36820 0.01390 0.12060 5.23440 -261.98010 3916.67280 0.01560 0.09270 8.45350 -347.15740 3945.12170 0.01690 0.11640 8.12330 -478.19240 7800.72300 0.01860 0.17260 0.71240 -115.72890 2283.60300 0.02000 0.10610 8.07380 -410.64940 6138.73010 0.02100 0.11760 5.13770 -237.37930 3309.77030 0.02190 0.10060 7.58500 -355.33160 5221.42210 0.02260 0.11170 6.17110 -296.22020 4437.97820 0.02320 0.09420 9.17500 -458.44140 7042.78450 0.02390 0.07050 12.26840 -581.72680 8581.05840 0.02430 0.10780 7.98250 -413.00360 6431.82300 0.02480 0.11130 6.71420 -342.46790 5327.89480 0.02720 0.05420 12.35150 -531.36360 7373.15850 0.02890 0.05160 14.81710 -696.75690 10277.77390 0.03050 0.06330 14.90890 -755.63270 11757.82380 0.03190 0.06140 14.92180 -739.99790 11344.62360 0.03320 0.07560 13.34450 -664.88990 10162.97500 0.03440 0.08650 11.26300 -546.65670 8164.58250 0.03560 0.08860 9.47140 -404.46350 5439.32360 0.03670 0.08270 10.75550 -481.38990 6791.15960 0.03770 0.09530 9.93360 -474.87170 7059.86620 0.03870 0.09470 10.18550 -496.79400 7628.28750 0.03970 0.09710 11.04150 -564.74580 8877.24440 0.04070 0.09240 10.56420 -504.82300 7597.95750 0.04160 0.10170 10.14850 -502.21930 7700.21720 0.04260 0.10810 9.23080 -468.74540 7374.78230 0.04350 0.08980 11.03490 -544.79820 8532.92300 0.04450 0.06020 14.63480 -709.34190 11013.46990 0.04540 0.04040 16.89420 -805.00480 12287.24130 "
    s = s + "0.04630 0.04290 16.35510 -775.51570 11868.49810 0.04710 0.06530 14.12190 -691.70300 10784.46800 0.04790 0.08530 11.50680 -564.84830 8815.93760 0.04870 0.09520 10.53490 -531.97960 8488.14690 0.04960 0.08840 11.66000 -586.25190 9319.69370 0.05040 0.07550 13.08260 -650.52200 10354.04730 0.05130 0.07500 12.93140 -634.36030 10000.72010 0.05210 0.07880 11.94830 -565.80710 8722.23810 0.05290 0.08240 11.66950 -566.27830 8945.35420 0.05370 0.09000 10.59850 -523.47240 8466.05010 0.05450 0.08530 11.30130 -548.02930 8701.52550 0.05530 0.07340 13.24520 -645.40660 10163.06240 0.05610 0.09550 10.69550 -529.41640 8410.89560 0.05690 0.08590 11.91110 -585.11480 9229.72940 0.05770 0.10470 9.39870 -463.56560 7345.94090 0.05840 0.10570 9.28170 -456.35600 7221.81480 0.05920 0.12740 6.99860 -363.79380 6004.73270 0.06000 0.10510 9.77190 -477.14410 7501.35730 0.06090 0.08070 12.63070 -595.61090 9108.37720 0.06170 0.06080 14.92980 -689.42530 10408.54530 0.06250 0.06780 14.34760 -668.79510 10154.83570 0.06330 0.05520 16.32790 -762.62270 11514.46880 0.06410 0.06030 15.60450 -724.57690 10880.79280 0.06490 0.08070 12.94570 -603.46210 9121.32750 0.06570 0.06990 14.11700 -654.53300 9885.87000 0.06650 0.06840 14.96190 -707.69750 10752.40490 0.06730 0.07690 13.52100 -631.14420 9515.82680 0.06810 0.05280 16.63120 -768.43270 11446.85860 0.06900 0.01730 21.53810 -997.01940 14831.52280 0.06990 -0.00070 23.72010 -1084.06770 15950.11620 "
    s = s + "0.07070 -0.00380 24.55110 -1135.49430 16836.23580 0.07150 -0.00920 25.84040 -1206.07330 17997.74210 0.07230 -0.02430 27.50700 -1260.83330 18559.60340 0.07320 -0.05840 31.75710 -1451.47840 21322.58850 0.07400 -0.04070 30.10200 -1396.20620 20723.07750 0.07480 -0.02230 28.29120 -1321.60130 19680.28180 0.07560 -0.01500 27.50090 -1290.08970 19251.20170 0.07640 0.01590 23.45890 -1101.03480 16418.57570 0.07730 0.00780 24.29950 -1136.93860 16943.88700 0.07820 0.01920 22.92390 -1083.84230 16325.32310 0.07900 0.02710 23.03910 -1116.36240 17027.80160 0.07980 0.05390 19.78020 -972.96850 14900.69230 0.08070 0.04840 20.36700 -999.23200 15339.64490 0.08150 0.05030 19.76910 -968.94820 14919.32320 0.08240 0.05440 19.29650 -948.40840 14585.97980 0.08330 0.05150 18.40550 -871.37790 13123.41380 0.08420 0.04720 19.14810 -905.07450 13606.12350 0.08510 0.04780 18.59240 -863.29300 12791.56230 0.08600 0.02700 21.61210 -999.17490 14709.91440 0.08700 0.01170 23.75970 -1086.56790 15773.33490 0.08790 0.01370 23.38030 -1061.65280 15315.24720 0.08880 -0.00050 25.74900 -1180.23380 17145.89640 0.08980 -0.00760 26.02770 -1187.29060 17300.37280 0.09060 0.04190 20.08080 -930.18960 13687.82600 0.09160 0.04660 18.90360 -856.57360 12427.40490 0.09240 0.06860 17.11030 -808.51830 12103.57670 0.09340 0.06750 17.29110 -806.98760 11924.69690 0.09440 0.06130 18.28970 -857.89350 12735.02460 0.09530 0.09710 13.75900 -656.12140 9899.85490 0.09620 0.11760 11.66840 -578.11250 8959.97780 "
    s = s + "0.09720 0.13430 9.59540 -487.92460 7698.32330 0.09820 0.15490 7.06400 -383.38190 6360.82150 0.09910 0.16000 7.04430 -386.17240 6335.93550 0.10020 0.14340 9.39680 -487.08070 7663.10770 0.10120 0.14640 8.95990 -473.08880 7608.40420 0.10220 0.18110 3.82680 -231.29460 4124.22350 0.10320 0.18190 4.86540 -303.31510 5433.18340 0.10430 0.17810 4.65680 -264.33820 4504.12130 0.10540 0.15560 7.75660 -407.13160 6619.29550 0.10650 0.15850 7.32180 -380.16940 6130.70470 0.10750 0.17750 4.96890 -279.35000 4775.18120 0.10860 0.18690 3.52110 -205.91330 3618.44190 0.10970 0.19080 3.77560 -235.16980 4227.49750 0.11090 0.17370 6.03910 -349.62560 6138.87560 0.11200 0.17140 6.43330 -370.39370 6460.52280 0.11310 0.20000 2.22850 -162.22030 3268.10980 0.11440 0.15420 7.63450 -382.43550 6191.26980 0.11550 0.15250 8.70490 -457.11870 7592.62690 0.11670 0.16200 6.86950 -351.42710 5835.37350 0.11790 0.18240 4.11060 -215.93770 3741.84560 0.11920 0.15820 7.23670 -370.64650 6246.67890 0.12040 0.15580 7.51810 -383.62380 6426.91490 0.12160 0.15940 7.35500 -383.03160 6461.64950 0.12280 0.16840 7.56080 -429.83940 7486.15140 0.12410 0.16050 9.63700 -551.00840 9536.58240 0.12530 0.18060 7.17870 -432.05510 7662.74570 0.12660 0.17530 7.83050 -447.74290 7656.32590 0.12800 0.12810 14.01890 -723.32870 11596.74560 0.12940 0.12080 14.02540 -700.96770 11079.19340 0.13080 0.08130 19.85440 -967.11020 14857.50330 "
    s = s + "0.13210 0.10710 16.55730 -826.93690 12908.54990 0.13350 0.13060 12.81200 -638.06180 10000.35470 0.13480 0.16660 9.27910 -494.36040 7969.87740 0.13630 0.15800 9.45270 -468.69450 7173.03910 0.13780 0.10310 18.06140 -917.13190 14350.77570 0.13940 0.09510 17.37580 -824.04830 12287.77660 0.14090 0.10370 15.69350 -717.19000 10329.78700 0.14230 0.14620 10.74320 -505.14230 7388.67980 0.14390 0.14970 9.71490 -444.62660 6377.82530 0.14540 0.17100 6.59920 -301.08130 4325.95920 0.14710 0.13010 9.94910 -402.63300 5404.27940 0.14870 0.11130 11.97140 -465.53140 5974.47730 0.15040 0.11500 12.36170 -502.75060 6605.42130 0.15190 0.15190 8.07480 -330.35340 4362.84260 0.15370 0.10350 14.37260 -627.23410 8873.07080 0.15540 0.10480 15.31770 -705.16950 10450.01010 0.15720 0.08790 17.18740 -795.00220 11857.70650 0.15900 0.08680 16.39260 -729.47900 10610.14260 0.16090 0.05450 20.02360 -881.25800 12656.05330 0.16270 0.03190 22.77050 -1005.23330 14409.32860 0.16450 0.05180 20.91580 -921.33030 12953.18450 0.16630 0.08410 17.32140 -773.45200 10885.73820 0.16830 0.02590 24.72610 -1106.24370 15819.88730 0.17030 0.03190 25.47730 -1206.16390 18117.72850 0.17240 -0.00930 30.70080 -1455.38010 22022.86930 0.17450 -0.04050 34.76580 -1632.88150 24434.24490 0.17660 -0.06260 37.73860 -1793.27800 27070.58580 0.17860 -0.00220 31.60270 -1551.52400 23782.61190 0.18070 0.01700 29.85170 -1500.82880 23500.81340 0.18280 0.02520 27.84250 -1358.81110 20786.43250 "
    s = s + "0.18510 0.00390 31.57010 -1533.46730 23291.33110 0.18730 0.00200 31.68720 -1525.83730 22884.29700 0.18950 0.08570 20.13510 -959.27310 14152.85160 0.19180 0.09110 20.55730 -1004.72400 14962.57820 0.19430 0.07750 20.85120 -965.25030 13833.60620 0.19700 -0.00330 29.84790 -1358.10800 19578.11740 0.19950 0.05330 22.68390 -1027.13520 14615.71490 0.20210 0.00180 28.55860 -1268.03890 17701.94420 0.20480 -0.00430 31.13920 -1447.67910 20940.14520 0.20740 0.04200 25.09550 -1166.83080 16659.00490 0.21010 0.03590 27.08800 -1272.30580 18175.27440 0.21310 -0.00270 29.33830 -1306.60290 18140.64490 0.21590 0.03940 24.37990 -1066.75740 14252.01980 0.21880 0.12690 13.42130 -605.63290 7957.22930 0.22170 0.20180 6.13330 -334.62270 4307.65300 0.22460 0.27470 -2.59940 13.21270 95.54750 0.22780 0.24590 2.85400 -294.10890 5286.94840 0.23100 0.29640 -2.03340 -126.94020 3326.78360 0.23440 0.32990 -6.57590 79.22330 282.14880 0.23780 0.37720 -10.89330 202.21900 -781.60870 0.24120 0.47240 -22.66750 721.20940 -8339.16960 0.24500 0.43790 -19.11630 587.43740 -6522.67740 0.24870 0.44910 -21.45770 716.90440 -8507.71120 0.25270 0.42700 -19.88750 693.96380 -8782.42800 0.25700 0.29580 -4.24280 64.39070 -732.29090 0.26120 0.26360 0.45790 -168.66300 2888.33090 0.26550 0.21950 7.89630 -560.97390 9054.09460 0.26990 0.23950 2.25310 -236.27600 4029.07630 0.27430 0.31870 -7.47870 254.05680 -3952.92410 0.27890 0.41090 -19.20600 843.27180 -13695.96870 "
    s = s + "0.28370 0.50980 -34.81600 1634.11970 -26064.26180 0.28940 0.38820 -26.60720 1480.95010 -25995.48340 0.29490 0.22150 -4.58260 539.32080 -13401.72130 0.30030 0.34740 -20.19260 1213.34770 -22825.00490 0.30630 0.30640 -11.89500 671.18760 -12752.24270 0.31240 0.34500 -16.81130 824.73790 -13919.86390 0.31840 0.57670 -48.53690 2214.56500 -32720.47700 0.32520 0.50880 -43.67690 2031.86830 -29511.88710 0.33190 0.63920 -60.33960 2796.09790 -40748.55780 0.33950 0.54790 -55.37920 2774.01050 -42499.46770 0.34700 0.54370 -48.53360 2325.72700 -35193.64070 0.35510 0.68430 -70.99600 3357.08370 -50009.11710 0.36410 0.55060 -57.62480 2750.58690 -40966.41550 0.37280 0.70600 -72.65010 3262.21130 -46969.03560 0.38300 0.60790 -63.85600 2847.86890 -40346.02190 0.39370 0.44150 -41.88830 1744.15530 -22916.56370 0.40500 0.44430 -46.74600 2003.24430 -26804.83090 0.41690 0.49780 -57.24740 2695.23750 -40522.23760 0.42950 0.90240 -113.57610 5203.05950 -75738.21850 0.44430 0.52270 -65.49790 3191.91960 -49594.96400 0.46090 0.34110 -63.64880 3667.32980 -62272.82540 0.47900 0.40090 -71.54630 3681.86080 -58193.70310 0.49870 0.60220 -116.10720 6126.03110 -98396.66900 0.52000 1.31200 -203.26450 9425.50020 -137806.60230 0.54590 1.62570 -268.90010 13110.58860 -199834.29950 0.58040 0.20830 -111.41940 6240.65370 -101669.57420 0.61980 -0.20310 -74.28910 4393.93970 -71981.45740 0.66970 0.15730 -147.26150 7935.20750 -128723.16660 0.73840 0.96300 -263.35940 12819.53450 -197019.52200 0.75850 0.45550 -208.29310 10279.01700 -161237.30990 "
    s = s + "0.78150 -0.32070 -148.00430 8596.00390 -151033.38750 0.81000 -1.70710 -53.79410 6361.89640 -137689.59630 0.83750 -1.84000 -36.10150 5231.58900 -120266.27100 0.87410 -3.38990 130.48280 -1919.35190 -18845.85070 0.92000 -6.30990 473.14940 -17326.31370 205222.12170 0.97590 -6.29280 364.28010 -10591.01430 92477.71800 1.05840 -8.82640 486.60910 -12080.96530 71842.25720 1.20020 -13.33310 758.61380 -21630.44010 194228.33090 1.35570 -24.70910 1995.51830 -78956.71950 1076765.01780 1.49480 -14.16860 340.75510 305.65850 -113814.77990 1.65110 -33.79910 2642.96020 -104156.99150 1425964.13810 "
    return(rowshape(strtoreal(tokens(s)), 221))
}

real matrix _xtps_rs2()
{
    string scalar s
    s = "0.01010 0.16020 -3.98700 224.82800 -3639.32550 0.01080 0.09700 6.67870 -365.81980 6280.08710 0.01180 0.14320 -0.71280 47.33310 -853.53060 0.01270 0.12810 3.23440 -204.20120 3801.35570 0.01390 0.10540 4.33650 -185.77460 2822.79750 0.01460 0.11350 3.20500 -129.58940 2001.33710 0.01520 0.11310 3.11600 -126.28410 1993.41290 0.01560 0.10530 4.32920 -185.63840 2885.93860 0.01610 0.11910 2.27100 -90.42330 1504.68750 0.01640 0.10380 4.49860 -185.84760 2710.72020 0.01680 0.11290 3.02760 -106.88800 1419.08600 0.01710 0.12360 1.53100 -28.36720 97.02250 0.01730 0.12400 1.54400 -30.86850 170.72310 0.01860 0.10960 2.90460 -82.29190 872.66340 0.01950 0.14440 -1.52680 130.92010 -2456.52690 0.02030 0.16330 -3.75270 222.97360 -3683.28180 0.02100 0.16070 -2.82150 158.92310 -2467.07920 0.02170 0.15770 -2.29720 138.61160 -2222.43950 0.02220 0.16330 -2.98010 172.62830 -2778.48540 0.02280 0.16710 -3.62170 205.32520 -3301.35590 0.02340 0.15740 -1.71360 98.96630 -1528.86970 0.02390 0.16670 -2.85120 152.22730 -2303.07610 0.02440 0.16310 -1.87990 91.89850 -1252.19260 0.02490 0.13980 0.92140 -32.88940 553.27690 0.02540 0.13770 1.34570 -55.13430 913.23050 0.02580 0.13160 2.28890 -104.32650 1723.82620 0.02630 0.13720 1.66900 -76.00320 1290.58330 0.02670 0.13290 1.87800 -75.58930 1213.00550 0.02710 0.12640 2.52610 -99.70420 1520.00270 0.02750 0.11900 3.59210 -151.30880 2311.67420 "
    s = s + "0.02800 0.10760 5.09480 -216.72020 3210.66040 0.02840 0.10560 5.50470 -239.24880 3580.38150 0.02870 0.10660 5.47350 -239.05360 3599.52070 0.02910 0.10830 4.98900 -204.30030 2935.94420 0.02950 0.10590 5.56780 -233.46590 3368.46900 0.02980 0.10510 5.71900 -240.86840 3479.30310 0.03020 0.11250 4.81640 -203.32260 2962.04060 0.03050 0.12250 3.26550 -128.86550 1851.47470 0.03090 0.11760 3.77040 -142.58520 1933.09240 0.03120 0.12240 3.38740 -135.63610 1960.96410 0.03160 0.11220 4.67510 -195.94150 2863.83340 0.03190 0.11340 4.46090 -180.94970 2580.71740 0.03230 0.11870 3.95770 -164.10740 2403.99910 0.03260 0.11390 4.40720 -182.10650 2649.24410 0.03300 0.11740 4.07780 -170.22870 2514.26420 0.03330 0.12120 3.71930 -157.87130 2369.09500 0.03360 0.12130 3.51640 -139.75030 1995.21010 0.03400 0.12570 2.89320 -108.94170 1519.08210 0.03430 0.12340 3.40880 -139.08300 2023.21550 0.03460 0.11920 3.92490 -164.05940 2428.09630 0.03500 0.12160 3.61570 -151.54930 2283.63660 0.03530 0.12950 2.71190 -115.21720 1780.90160 0.03560 0.12710 2.82310 -115.86390 1765.57400 0.03590 0.13210 2.22550 -88.49300 1347.27780 0.03620 0.13950 1.43860 -55.84620 894.15700 0.03650 0.14570 0.63400 -16.97100 294.92320 0.03680 0.15050 -0.11810 19.75020 -240.66640 0.03720 0.16020 -1.37510 78.36750 -1119.08070 0.03750 0.15820 -0.92330 49.71470 -607.11480 0.03780 0.15990 -1.12300 59.61280 -753.17990 "
    s = s + "0.03810 0.16700 -1.90110 87.73060 -1061.04040 0.03840 0.16580 -1.99140 98.56100 -1276.37880 0.03880 0.16720 -2.15560 102.91820 -1315.89680 0.03910 0.16870 -2.21910 100.70440 -1205.27800 0.03940 0.16290 -1.31220 58.02260 -585.53710 0.03970 0.15190 -0.01100 4.71340 126.08860 0.04010 0.15010 0.36780 -14.71910 416.94010 0.04040 0.15230 0.33860 -20.96600 592.60650 0.04070 0.14400 1.22280 -53.23950 982.46580 0.04110 0.14130 1.49510 -59.89620 1008.56920 0.04140 0.14660 0.64010 -20.21980 439.03620 0.04170 0.14400 0.64720 -8.94940 129.64570 0.04210 0.13940 1.10860 -28.36280 398.62800 0.04240 0.14190 0.61670 0.70000 -119.38180 0.04270 0.14240 0.38470 14.65260 -353.28710 0.04310 0.13410 1.19420 -17.82650 102.39050 0.04340 0.14330 -0.04020 42.02810 -818.09390 0.04370 0.13840 0.34940 30.22770 -688.68970 0.04410 0.14290 -0.61760 87.49530 -1673.83560 0.04440 0.14620 -0.91090 99.75080 -1861.60650 0.04470 0.15660 -2.10490 152.38370 -2633.51860 0.04500 0.15700 -2.29070 167.27370 -2918.12310 0.04540 0.15600 -2.03200 153.36000 -2715.50810 0.04570 0.15530 -1.98460 154.64830 -2786.02990 0.04600 0.16250 -2.78980 189.92620 -3313.37230 0.04640 0.16110 -2.71760 188.80330 -3310.41350 0.04670 0.16370 -3.27860 220.18410 -3810.52370 0.04710 0.15770 -2.67220 199.88440 -3597.77450 0.04740 0.16030 -3.02620 214.24480 -3792.31580 0.04780 0.15330 -2.30030 186.32130 -3427.33020 "
    s = s + "0.04810 0.15650 -2.72850 206.62400 -3727.43570 0.04850 0.15450 -2.81160 218.69270 -3975.85920 0.04880 0.15440 -2.60320 203.86000 -3704.29440 0.04920 0.16630 -4.21990 278.81190 -4790.60990 0.04950 0.17210 -4.89370 302.01820 -5017.60050 0.04990 0.17120 -4.75820 294.95570 -4898.86530 0.05020 0.17880 -5.89390 352.96460 -5812.25380 0.05060 0.18580 -6.82280 394.61750 -6402.96850 0.05090 0.18030 -5.96500 352.87390 -5780.50670 0.05130 0.17960 -6.09290 360.21240 -5864.91630 0.05170 0.17690 -5.86440 353.84970 -5843.40820 0.05210 0.17770 -5.81390 345.20420 -5649.81220 0.05240 0.18480 -6.46020 368.69830 -5938.46180 0.05280 0.18400 -6.18760 354.17070 -5713.47260 0.05320 0.17400 -4.99260 299.13140 -4876.12830 0.05360 0.16930 -4.17190 254.55680 -4152.32730 0.05400 0.16450 -3.68940 237.10040 -3957.08680 0.05440 0.16200 -3.26100 210.32100 -3445.90850 0.05480 0.16850 -3.86600 231.48290 -3696.44800 0.05510 0.17130 -3.89400 222.31860 -3456.03490 0.05560 0.15580 -1.78050 121.89120 -1931.43600 0.05600 0.15580 -1.46790 98.79250 -1516.99500 0.05640 0.16720 -3.16490 181.01980 -2734.17590 0.05680 0.17190 -3.81410 208.92790 -3111.41630 0.05720 0.17870 -4.90630 268.14070 -4091.71740 0.05760 0.17980 -5.04760 275.51130 -4219.06150 0.05800 0.17810 -4.81300 260.40050 -3917.25600 0.05850 0.17080 -4.03660 231.30840 -3561.17910 0.05890 0.16710 -3.62780 209.69020 -3175.00460 0.05930 0.16290 -3.37690 210.23540 -3336.29240 "
    s = s + "0.05980 0.15630 -2.75880 190.21020 -3137.99640 0.06020 0.15550 -3.08420 219.60820 -3731.62930 0.06070 0.15530 -3.03260 215.95730 -3643.90720 0.06110 0.15680 -2.79860 192.96210 -3165.66590 0.06160 0.15860 -2.92370 197.98980 -3251.04940 0.06200 0.16120 -2.70330 170.54530 -2669.06530 0.06240 0.17630 -4.34570 240.78810 -3684.25120 0.06290 0.18550 -5.65980 304.66370 -4673.57930 0.06340 0.18410 -5.60200 305.22590 -4726.69260 0.06390 0.17220 -4.44340 259.54890 -4119.67200 0.06440 0.17610 -4.71050 268.91670 -4253.56580 0.06490 0.17270 -4.21670 248.47150 -4017.46930 0.06540 0.16690 -3.64820 224.48750 -3660.02080 0.06590 0.16650 -3.74380 236.18770 -3938.41770 0.06640 0.16570 -3.58060 225.95280 -3749.27980 0.06690 0.17270 -4.43020 262.91680 -4260.96880 0.06740 0.17320 -4.54510 267.59350 -4299.27590 0.06800 0.15920 -2.52490 167.71740 -2766.16510 0.06860 0.14070 -0.03650 46.15620 -859.42540 0.06910 0.14620 -0.58210 64.41890 -1064.62920 0.06960 0.15040 -0.57210 50.57010 -761.47470 0.07020 0.14810 0.20320 1.64860 77.10100 0.07070 0.15970 -1.10060 55.47760 -676.93630 0.07120 0.18300 -3.97580 189.30660 -2716.70950 0.07180 0.19100 -4.67960 213.55760 -3045.88610 0.07240 0.19280 -4.62310 199.86100 -2704.60490 0.07300 0.19020 -5.20060 252.01020 -3712.69180 0.07360 0.17910 -4.14460 216.72550 -3350.17080 0.07420 0.19310 -5.73690 273.87580 -3980.13360 0.07480 0.20950 -7.26150 320.68860 -4411.11010 "
    s = s + "0.07550 0.20330 -6.29100 269.88140 -3594.49680 0.07610 0.21180 -7.30290 310.76670 -4129.60720 0.07680 0.21690 -7.88400 330.38980 -4349.72180 0.07750 0.20640 -6.69690 274.03660 -3474.10300 0.07820 0.19690 -5.22590 200.14120 -2325.69250 0.07890 0.19330 -5.02500 194.07260 -2197.83500 0.07960 0.18500 -3.89230 142.27240 -1479.62710 0.08040 0.18120 -4.14670 172.32050 -2081.53420 0.08110 0.18530 -4.79350 203.37300 -2556.81440 0.08180 0.19250 -5.70150 238.95720 -3026.68480 0.08260 0.18740 -5.21320 214.98670 -2630.71380 0.08340 0.18150 -4.03740 149.77580 -1598.22700 0.08420 0.18030 -3.06120 70.59100 5.42810 0.08510 0.16770 -2.00620 38.55410 308.05470 0.08600 0.14760 0.38180 -73.78540 2004.49450 0.08680 0.15730 -0.86940 -26.45910 1384.48100 0.08770 0.14650 0.14200 -59.90250 1656.36650 0.08860 0.13610 1.67640 -127.83710 2601.31480 0.08960 0.13030 1.92250 -127.63710 2476.17390 0.09050 0.14430 0.13900 -60.54490 1721.24490 0.09150 0.10910 4.98670 -292.98540 5194.85460 0.09260 0.09860 5.31650 -289.53220 5070.61000 0.09360 0.09480 5.23140 -272.98470 4739.47360 0.09470 0.10460 4.49400 -263.91640 4867.28890 0.09580 0.08720 6.05650 -325.76480 5701.17700 0.09690 0.08310 5.94170 -308.42180 5329.11260 0.09810 0.06280 8.10450 -394.08050 6395.97860 0.09930 0.07430 5.95170 -287.56160 4789.96600 0.10060 0.04020 10.05180 -465.54480 7254.60000 0.10180 0.07640 4.83410 -233.92890 3978.05210 "
    s = s + "0.10320 0.06890 5.62610 -275.38710 4626.16760 0.10450 0.05450 6.80940 -316.88960 5118.79200 0.10590 0.05530 6.62300 -295.02890 4522.46120 0.10740 0.06110 5.59540 -247.11390 3876.69160 0.10890 0.03080 9.47850 -423.10720 6390.48780 0.11060 -0.01840 13.51440 -548.82670 7735.32780 0.11220 -0.02910 13.82780 -533.41130 7212.31170 0.11390 -0.02160 14.05290 -605.15630 8910.65550 0.11570 -0.04180 16.61940 -728.78040 10840.71800 0.11760 -0.06290 17.77330 -735.94450 10389.71270 0.11970 -0.07950 20.03510 -882.86670 13137.29810 0.12180 -0.09720 21.33490 -947.46150 14297.60060 0.12390 -0.04850 16.06850 -741.56330 11514.10450 0.12630 -0.09000 19.87370 -914.87810 14354.98530 0.12890 -0.11590 22.60170 -1038.96010 16060.01980 0.13160 -0.13200 25.08050 -1188.00120 18671.52670 0.13450 -0.15460 26.99800 -1293.81520 20575.69710 0.13760 -0.15950 27.18590 -1342.82800 21973.06840 0.14120 -0.30410 43.27060 -2054.47100 32522.49250 0.14460 -0.21710 32.27070 -1584.63200 25856.48860 0.14890 -0.33830 46.13470 -2221.38870 35289.94530 0.15340 -0.35950 46.35770 -2219.04070 35317.56250 0.15810 -0.26820 37.23660 -1972.96940 33494.91870 0.16350 -0.17590 26.67290 -1609.74320 29609.72250 0.17010 -0.14100 15.74100 -1020.26410 20268.43580 0.17880 -0.57530 62.66650 -2966.99890 46440.82420 0.18790 -0.30120 25.12130 -1365.42690 23817.49300 0.20070 -0.58250 54.93230 -2697.44260 42611.63250 0.21840 -0.47240 35.49230 -1969.09970 32764.32490 0.22310 -0.48370 30.03590 -1566.17900 24942.97130 "
    s = s + "0.22880 -0.73100 56.06930 -2668.88130 40251.42850 0.23430 -0.70620 58.68310 -2957.85060 44875.37970 0.24030 -0.24430 -12.79460 472.11270 -6538.73100 0.24950 -0.71370 37.91580 -1682.26720 23342.20090 0.26060 -1.04450 60.29900 -2432.63380 32805.65020 0.27290 -1.00080 66.23470 -3273.45160 51418.93030 0.29190 -1.18260 58.58550 -2574.83190 37258.44570 0.32660 -1.86360 76.82100 -2953.35940 43246.55110 0.36150 -3.51390 275.37560 -12846.95600 198057.37610 0.40130 -2.43980 67.43810 -3671.51190 71771.45620 0.43790 -4.03530 178.03200 -7184.49680 106194.72130 "
    return(rowshape(strtoreal(tokens(s)), 221))
}

end