Author: Luis Hernando Vanegas

# Introduction to the mtarm Package

#### Luis Hernando Vanegas

#### Sergio Alejandro Calderón

#### Luz Marina Rondón

# 1 Multivariate Threshold Autoregressive (TAR) models

The `mtarm` package provides a computational tool designed for Bayesian estimation, inference, and forecasting in multivariate Threshold Autoregressive (TAR) models. These models provide a versatile approach for modeling nonlinear multivariate time series and include multivariate Self-Exciting Threshold Autoregressive (SETAR) and Vector Autoregressive (VAR) models as particular cases (Vanegas, Calderón V, and Rondón 2025). The package accommodates a broad class of innovation distributions beyond the Gaussian assumption, such as Student-\(t\), slash, symmetric hyperbolic, Laplace, contaminated normal, skew-normal, and skew-\(t\) distributions, thereby enabling robust modeling of heavy tails, asymmetry, and other non-Gaussian characteristics.

## 1.1 Installation

### 1.1.1 Install from GitHub

    remotes::install_github("lhvanegasp/mtarm")

### 1.1.2 Install from CRAN

    install.packages("mtarm")

## 1.2 Application: Temperature, precipitation, and two river flows in Iceland

### 1.2.1 Dataset

The data are available in the object `iceland.rf` and were obtained from (Tong 1990), who provided a detailed description of the geographical and meteorological characteristics of the rivers and analyzed each series individually. Subsequently, (Tsay 1998) conducted a bivariate analysis of the same dataset. The focus is on the bivariate time series \(\{(Y_{1,t},Y_{2,t})^{\top}\}_{t\geq 1}\), where \(Y_{1,t}\) and \(Y_{2,t}\) denote the daily river flow (in cubic meters per second, \({m}^3/{s}\)) of the Jökulsá Eystri and Vatnsdalsá rivers, respectively. The sample covers the period from 1972 to 1974, comprising 1095 observations. The exogenous variables include daily precipitation \(X_t\), measured in millimeters (\({mm}\)), and temperature \(Z_t\), measured in degrees Celsius (\(^\circ\mathrm{C}\)), both recorded at the meteorological station in Hveravellir. Precipitation corresponds to the accumulated rainfall from 9:00 A.M. of the previous day to 9:00 A.M. of the current day.

    library(mtarm)
    data(iceland.rf)
    str(iceland.rf)
    #> 'data.frame':    1096 obs. of  5 variables:
    #>  $ Vatnsdalsa   : num  16.1 19.2 14.5 11 13.6 12.5 10.5 10.1 9.68 9.02 ...
    #>  $ Jokulsa      : num  30.2 29 28.4 27.8 27.8 27.8 27.8 27.8 27.8 27.3 ...
    #>  $ Precipitation: num  8.1 4.4 7 0 0 0 1.9 1.2 0 0.1 ...
    #>  $ Temperature  : num  0.9 1.6 0.1 0.6 2 0.8 1.4 1.3 2.2 0.1 ...
    #>  $ Date         : Date, format: "1972-01-01" "1972-01-02" ...

    summary(iceland.rf[,-5])
    #>    Vatnsdalsa        Jokulsa       Precipitation     Temperature
    #>  Min.   : 3.670   Min.   : 22.00   Min.   : 0.000   Min.   :-22.4000
    #>  1st Qu.: 6.100   1st Qu.: 26.70   1st Qu.: 0.000   1st Qu.: -4.2000
    #>  Median : 7.500   Median : 31.40   Median : 0.300   Median :  0.3000
    #>  Mean   : 8.938   Mean   : 41.15   Mean   : 2.519   Mean   : -0.4407
    #>  3rd Qu.: 9.240   3rd Qu.: 50.90   3rd Qu.: 2.500   3rd Qu.:  3.9000
    #>  Max.   :54.000   Max.   :143.00   Max.   :79.300   Max.   : 13.9000

    plot(ts(as.matrix(iceland.rf[,-5])), main="Iceland")

### 1.2.2 Model specification

Following (Tsay 1998), the series are modeled using a \(\mathrm{TAR}(2; p=(15,15), q=(4,4), d=(2,2))\) specification given by

\[ Y_t= \sum_{j=1}^{2} I\!\left(Z_{t-h}\in(c_{j-1},c_j]\right) \left(\! \phi_0^{^{(j)}} +\sum_{i=1}^{15}\boldsymbol{\phi}_i^{^{(j)}}Y_{t-i} +\sum_{i=1}^{4}\boldsymbol{\beta}_i^{^{(j)}}X_{t-i} +\sum_{i=1}^{2}\delta_i^{^{(j)}}Z_{t-i} +\epsilon_t^{^{(j)}} \!\right) \]

where \(\epsilon_t^{^{(j)}}\) is the error term. The last 55 observations (from November 7 to December 31, 1974), corresponding to \(5\%\) of the sample, are excluded from the estimation stage and reserved for out-of-sample forecast evaluation. The following code requests the estimation for the \(\mathrm{TAR}(2; p=(15,15), q=(4,4), d=(2,2))\) specification under Gaussian, Student-\(t\), and Laplace error distributions.

### 1.2.3 Parameter estimation

    set.seed(09102)
    fits <- mtar_grid(~ Jokulsa + Vatnsdalsa | Temperature | Precipitation,
                      data=iceland.rf, subset={Date<="1974-11-06"},
                      row.names=Date, nregim.min=2, nregim.max=2, p.min=15,
                      p.max=15, q.min=4, q.max=4, d.min=2, d.max=2,
                      n.burnin=500, n.sim=400, n.thin=2, ssvs=TRUE,
                      dist=c("Gaussian","Student-t","Laplace"),
                      plan_strategy="multisession")

    fits
    #>
    #>
    #> Sample size          : 1026 time points (1972-01-16 to 1974-11-06)
    #>
    #> Output Series        : Jokulsa    |    Vatnsdalsa
    #>
    #> Threshold Series (TS): Temperature
    #>
    #> Exogenous Series (ES): Precipitation
    #>
    #> Error Distribution   : Gaussian, Laplace, Student-t
    #>
    #> Number of regimes    : 2
    #>
    #> Deterministics       : Intercept
    #>
    #> Autoregressive order : 15
    #>
    #> Maximum lag for ES   : 4
    #>
    #> Maximum lag for TS   : 2

### 1.2.4 Model comparison using forecast accuracy measures

#### 1.2.4.1 Adjusted within-sample

The following code requests Deviance Information Criterion (DIC) (Spiegelhalter et al. 2002, 2014) and Watanabe-Akaike Information Criterion (WAIC) (Watanabe 2010) values.

    DIC(fits)
    #>                          DIC
    #> Gaussian.2.15.4.2  10073.665
    #> Laplace.2.15.4.2    7088.548
    #> Student-t.2.15.4.2  7570.670

    WAIC(fits)
    #>                         WAIC
    #> Gaussian.2.15.4.2  10267.211
    #> Laplace.2.15.4.2    8172.876
    #> Student-t.2.15.4.2  7624.427

#### 1.2.4.2 Out-of-sample with standard \(h\)-step-ahead forecasting

In addition, the following code provides the median of the log-score (Good 1952), the Energy Score (ES) (Gneiting et al. 2008)—a multivariate extension of the Continuous Ranked Probability Score (CRPS)(Matheson and Winkler 1976; Grimit et al. 2006)—and the Absolute Percentage Error (APE), all computed from the observed and forecasted values for the last 55 observations.

    newdata <- subset(iceland.rf, Date>"1974-11-06")
    set.seed(09102)

    oos <- out_of_sample(fits, newdata=newdata, n.ahead=nrow(newdata), FUN=median)
    oos[,c(1,2,5,6)]
    #>                    Log.Score Energy.Score Jokulsa.APE Vatnsdalsa.APE
    #> Gaussian.2.15.4.2   3.756526     2.768467    5.791811       34.22062
    #> Laplace.2.15.4.2    3.486000     2.027685    4.032976       19.60633
    #> Student-t.2.15.4.2  3.508241     2.396514    3.783218       20.11439

#### 1.2.4.3 Out-of-sample with rolling-origin forecasting and fixed parameters

    set.seed(09102)
    oos2 <- out_of_sample(fits, newdata=newdata, n.ahead=nrow(newdata),
                          rolling=5, FUN=median)

    for(i in 1:length(oos2)){
       cat("\n",i,"-step-ahead\n")
       print(oos2[[i]][,c(1,2,5,6)])
    }
    #>
    #>  1 -step-ahead
    #>                    Log.Score Energy.Score Jokulsa.APE Vatnsdalsa.APE
    #> Gaussian.2.15.4.2  2.5752867    1.2867011    1.577961       7.751834
    #> Laplace.2.15.4.2   1.5069745    0.8707850    1.021102       4.374278
    #> Student-t.2.15.4.2 0.9977087    0.7287759    1.093024       5.228132
    #>
    #>  2 -step-ahead
    #>                    Log.Score Energy.Score Jokulsa.APE Vatnsdalsa.APE
    #> Gaussian.2.15.4.2   3.017372     1.658087    2.436912      12.468417
    #> Laplace.2.15.4.2    2.336255     1.267278    1.614512       5.781262
    #> Student-t.2.15.4.2  1.914611     1.166369    1.633090       5.845511
    #>
    #>  3 -step-ahead
    #>                    Log.Score Energy.Score Jokulsa.APE Vatnsdalsa.APE
    #> Gaussian.2.15.4.2   3.182215     1.837573    2.754749      15.365773
    #> Laplace.2.15.4.2    2.625043     1.486705    1.995235       7.677927
    #> Student-t.2.15.4.2  2.236478     1.399870    1.984019       7.513583
    #>
    #>  4 -step-ahead
    #>                    Log.Score Energy.Score Jokulsa.APE Vatnsdalsa.APE
    #> Gaussian.2.15.4.2   3.321731     1.967156    3.001013      17.236090
    #> Laplace.2.15.4.2    2.870681     1.603429    2.299671       8.466708
    #> Student-t.2.15.4.2  2.565933     1.621374    2.591758       7.240398
    #>
    #>  5 -step-ahead
    #>                    Log.Score Energy.Score Jokulsa.APE Vatnsdalsa.APE
    #> Gaussian.2.15.4.2   3.382073     2.068730    3.284366      19.211759
    #> Laplace.2.15.4.2    2.967714     1.692586    2.243715       9.666655
    #> Student-t.2.15.4.2  2.777403     1.773609    2.757114       9.341327

### 1.2.5 Summary of the best model

    summary(fits[["Laplace.2.15.4.2"]])
    #>
    #>
    #> Sample size          : 1026 time points (1972-01-16 to 1974-11-06)
    #>
    #> Output Series (OS)   : Jokulsa    |    Vatnsdalsa
    #>
    #> Threshold Series (TS): Temperature with a estimated delay equal to 0
    #>
    #> Exogenous Series (ES): Precipitation
    #>
    #> Error Distribution   : Laplace
    #>
    #> Number of regimes    : 2
    #>
    #> Deterministics       : Intercept
    #>
    #> Autoregressive orders: 15 in each regime
    #>
    #> Maximum lags for ES  : 4 in each regime
    #>
    #> Maximum lags for TS  : 2 in each regime
    #>
    #>
    #> Thresholds (Mean, HDI.Lower, HDI.Upper)
    #>
    #> Regime 1 (-Inf,0.24] (-Inf,0.101] (-Inf,0.35403]
    #> Regime 2  (0.24,Inf)  (0.101,Inf)  (0.35403,Inf)
    #>
    #>
    #> Regime1:
    #>      OS.lag(1) OS.lag(2) OS.lag(3) OS.lag(4) OS.lag(5) OS.lag(6) OS.lag(7)
    #> SSVS         1         1      0.11      0.29         0         0         0
    #>      OS.lag(8) OS.lag(9) OS.lag(10) OS.lag(11) OS.lag(12) OS.lag(13) OS.lag(14)
    #> SSVS         0      0.44       0.15       0.16          0          0          0
    #>      OS.lag(15) ES.lag(1) ES.lag(2) ES.lag(3) ES.lag(4) TS.lag(1) TS.lag(2)
    #> SSVS       0.24         0         0         0         0         0      0.01
    #>
    #> Autoregressive coefficients
    #>                        Mean  2(1-PD)  HDI.Lower HDI.Upper             Mean
    #> (Intercept)         4.71928     1e-05   3.59591   5.96216    |     1.46940
    #> Jokulsa.lag( 1)     0.77745     1e-05   0.65459   0.87914    |    -0.08784
    #> Vatnsdalsa.lag( 1)  0.33704     1e-05   0.21744   0.45593    |     1.03659
    #> Jokulsa.lag( 2)    -0.01746     6e-01  -0.07278   0.04219    |     0.04701
    #> Vatnsdalsa.lag( 2) -0.27120     1e-05  -0.39015  -0.12786    |    -0.20697
    #>                     2(1-PD)  HDI.Lower HDI.Upper
    #> (Intercept)            1e-05   0.99726   1.95633
    #> Jokulsa.lag( 1)        1e-05  -0.13183  -0.04396
    #> Vatnsdalsa.lag( 1)     1e-05   0.93730   1.11482
    #> Jokulsa.lag( 2)        1e-05   0.01860   0.07639
    #> Vatnsdalsa.lag( 2)     1e-05  -0.28657  -0.13284
    #>
    #> Scale parameter (Mean, HDI.Lower, HDI.Upper)
    #>            Jokulsa Vatnsdalsa      Jokulsa Vatnsdalsa      Jokulsa Vatnsdalsa
    #> Jokulsa    0.24937    0.04570    . 0.19658    0.02911    . 0.29087    0.06407
    #> Vatnsdalsa 0.04570    0.08887    . 0.02911    0.06767    . 0.06407    0.10777
    #>
    #>
    #> Regime2:
    #>      OS.lag(1) OS.lag(2) OS.lag(3) OS.lag(4) OS.lag(5) OS.lag(6) OS.lag(7)
    #> SSVS         1         1         0         0         0         0         0
    #>      OS.lag(8) OS.lag(9) OS.lag(10) OS.lag(11) OS.lag(12) OS.lag(13) OS.lag(14)
    #> SSVS         0         0          0          0          0          0          0
    #>      OS.lag(15) ES.lag(1) ES.lag(2) ES.lag(3) ES.lag(4) TS.lag(1) TS.lag(2)
    #> SSVS          0      0.01         0         0         0         1         1
    #>
    #> Autoregressive coefficients
    #>                        Mean  2(1-PD)  HDI.Lower HDI.Upper             Mean
    #> (Intercept)         1.30758     1e-02   0.34610   2.28749    |     0.45310
    #> Jokulsa.lag( 1)     1.08490     1e-05   1.01553   1.15346    |    -0.00644
    #> Vatnsdalsa.lag( 1)  0.61082     1e-05   0.28481   0.93183    |     1.29627
    #> Jokulsa.lag( 2)    -0.22325     1e-05  -0.28360  -0.17030    |     0.00160
    #> Vatnsdalsa.lag( 2) -0.26323     1e-01  -0.50575   0.07505    |    -0.32087
    #> Temperature.lag(1)  1.18878     1e-05   0.99705   1.38429    |     0.04785
    #> Temperature.lag(2) -0.72583     1e-05  -0.90614  -0.50919    |    -0.05406
    #>                     2(1-PD)  HDI.Lower HDI.Upper
    #> (Intercept)          0.00001   0.24315   0.72736
    #> Jokulsa.lag( 1)      0.34000  -0.01748   0.00474
    #> Vatnsdalsa.lag( 1)   0.00001   1.16829   1.40942
    #> Jokulsa.lag( 2)      0.74500  -0.00759   0.01096
    #> Vatnsdalsa.lag( 2)   0.00001  -0.41281  -0.20274
    #> Temperature.lag(1)   0.01000   0.01232   0.08129
    #> Temperature.lag(2)   0.01500  -0.09224  -0.02052
    #>
    #> Scale parameter (Mean, HDI.Lower, HDI.Upper)
    #>            Jokulsa Vatnsdalsa      Jokulsa Vatnsdalsa      Jokulsa Vatnsdalsa
    #> Jokulsa    5.81841    0.27859    . 4.92348    0.15094    . 6.82294    0.41989
    #> Vatnsdalsa 0.27859    0.28275    . 0.15094    0.24123    . 0.41989    0.33833
    #>

### 1.2.6 Residuals

    res <- residuals(fits[["Laplace.2.15.4.2"]])

    par(mfrow=c(1,2))
    qqnorm(res[["full"]], pch=20, col="blue", main="")
    abline(0, 1, lty=3)
    hist(res[["full"]], freq=FALSE, xlab="Quantile-type residual",
         ylab="Density", main="")
    curve(dnorm(x), col="blue", add=TRUE)

    par(mfrow=c(1,2))
    acf(res[["full"]], col="blue", main="")
    pacf(res[["full"]], col="blue", main="")

### 1.2.7 Forecasting

    pred <- predict(fits[["Laplace.2.15.4.2"]], newdata=newdata,
                    n.ahead=nrow(newdata), row.names=Date, credible=0.8)

    head(pred$summary)
    #>            Jokulsa.Mean Jokulsa.Lower Jokulsa.Upper Vatnsdalsa.Mean
    #> 1974-11-07     22.24887      14.80440      29.71098        7.065749
    #> 1974-11-08     23.26888      17.07110      29.95938        7.468197
    #> 1974-11-09     24.56545      19.57061      29.75290        7.602840
    #> 1974-11-10     25.07271      20.53018      29.32400        7.452584
    #> 1974-11-11     25.20357      21.53071      29.01823        7.231594
    #> 1974-11-12     25.32326      22.85621      29.72021        7.061325
    #>            Vatnsdalsa.Lower Vatnsdalsa.Upper
    #> 1974-11-07         5.570865         8.656971
    #> 1974-11-08         5.363028         9.101836
    #> 1974-11-09         5.299086         9.449402
    #> 1974-11-10         4.942358         9.212046
    #> 1974-11-11         4.797265         9.265275
    #> 1974-11-12         5.144482         9.462583
    tail(pred$summary)
    #>            Jokulsa.Mean Jokulsa.Lower Jokulsa.Upper Vatnsdalsa.Mean
    #> 1974-12-26     25.79234      22.67541      29.20841        6.107449
    #> 1974-12-27     25.90488      22.38146      29.01598        6.098012
    #> 1974-12-28     25.94826      22.61811      28.87847        6.095481
    #> 1974-12-29     25.95476      22.75529      28.69989        6.015718
    #> 1974-12-30     25.91199      22.33841      28.47903        5.914708
    #> 1974-12-31     25.75638      23.24709      29.06307        5.910189
    #>            Vatnsdalsa.Lower Vatnsdalsa.Upper
    #> 1974-12-26         3.901664         8.291431
    #> 1974-12-27         3.992384         8.462892
    #> 1974-12-28         3.676926         8.205371
    #> 1974-12-29         3.960235         8.159962
    #> 1974-12-30         4.202140         8.192281
    #> 1974-12-31         3.702814         7.604186

### 1.2.8 Summary statistics

    fitmcmc <- coda::as.mcmc(fits[["Laplace.2.15.4.2"]])
    summary(fitmcmc)
    #>
    #>
    #>  Iterations = 501:1299
    #>
    #>  Thinning interval = 2
    #>
    #>  Sample size per chain = 400
    #>
    #> Thresholds:
    #>             Mean       Sd Sd(Mean)    2.5%    25%     50%     75%   97.5%
    #> Threshold.1 0.24 0.069355  0.02148 0.10709 0.2063 0.24164 0.28712 0.37538
    #>
    #>
    #> Regime 1
    #>
    #>
    #> Autoregressive coefficients:
    #>                                    Mean       Sd  Sd(Mean)      2.5%       25%
    #> Jokulsa:(Intercept)            4.719282 0.639500 0.1795684  3.700281  4.241557
    #> Vatnsdalsa:(Intercept)         1.469398 0.268241 0.0677283  1.000085  1.273678
    #> Jokulsa:Jokulsa.lag( 1)        0.777453 0.063010 0.0141672  0.633180  0.738324
    #> Vatnsdalsa:Jokulsa.lag( 1)    -0.087844 0.024333 0.0048510 -0.133022 -0.105813
    #> Jokulsa:Vatnsdalsa.lag( 1)     0.337044 0.062506 0.0051981  0.223531  0.294181
    #> Vatnsdalsa:Vatnsdalsa.lag( 1)  1.036586 0.044641 0.0048578  0.941195  1.006997
    #> Jokulsa:Jokulsa.lag( 2)       -0.017464 0.031735 0.0031497 -0.072485 -0.040201
    #> Vatnsdalsa:Jokulsa.lag( 2)     0.047013 0.016309 0.0017976  0.017332  0.036022
    #> Jokulsa:Vatnsdalsa.lag( 2)    -0.271201 0.069195 0.0165978 -0.400936 -0.319687
    #> Vatnsdalsa:Vatnsdalsa.lag( 2) -0.206967 0.039197 0.0031167 -0.286568 -0.230777
    #>                                     50%        75%     97.5%
    #> Jokulsa:(Intercept)            4.596442  5.1348531  6.069274
    #> Vatnsdalsa:(Intercept)         1.447402  1.6705781  1.968240
    #> Jokulsa:Jokulsa.lag( 1)        0.790344  0.8264448  0.871635
    #> Vatnsdalsa:Jokulsa.lag( 1)    -0.086233 -0.0694346 -0.044908
    #> Jokulsa:Vatnsdalsa.lag( 1)     0.335304  0.3811853  0.469796
    #> Vatnsdalsa:Vatnsdalsa.lag( 1)  1.038449  1.0665587  1.119978
    #> Jokulsa:Jokulsa.lag( 2)       -0.018531  0.0036256  0.042678
    #> Vatnsdalsa:Jokulsa.lag( 2)     0.046598  0.0596761  0.076146
    #> Jokulsa:Vatnsdalsa.lag( 2)    -0.273804 -0.2249351 -0.136540
    #> Vatnsdalsa:Vatnsdalsa.lag( 2) -0.207859 -0.1808252 -0.132843
    #>
    #>
    #> Scale parameter:
    #>                           Mean        Sd  Sd(Mean)     2.5%      25%      50%
    #> Jokulsa.Jokulsa       0.249370 0.0251663 0.0023048 0.201676 0.233108 0.248983
    #> Jokulsa.Vatnsdalsa    0.045699 0.0088572 0.0016123 0.029299 0.039962 0.044792
    #> Vatnsdalsa.Vatnsdalsa 0.088868 0.0107010 0.0010622 0.069301 0.081832 0.088942
    #>                            75%   97.5%
    #> Jokulsa.Jokulsa       0.267048 0.30054
    #> Jokulsa.Vatnsdalsa    0.051385 0.06437
    #> Vatnsdalsa.Vatnsdalsa 0.095470 0.11105
    #>
    #>
    #> Regime 2
    #>
    #>
    #>
    #> Autoregressive coefficients:
    #>                                     Mean        Sd   Sd(Mean)       2.5%
    #> Jokulsa:(Intercept)            1.3075820 0.5018816 0.02693731  0.1764215
    #> Vatnsdalsa:(Intercept)         0.4530976 0.1245738 0.00992205  0.2431474
    #> Jokulsa:Jokulsa.lag( 1)        1.0849030 0.0383974 0.00345264  1.0180005
    #> Vatnsdalsa:Jokulsa.lag( 1)    -0.0064415 0.0061333 0.00040984 -0.0174777
    #> Jokulsa:Vatnsdalsa.lag( 1)     0.6108226 0.1660698 0.01063256  0.2729072
    #> Vatnsdalsa:Vatnsdalsa.lag( 1)  1.2962716 0.0650681 0.01599231  1.1512708
    #> Jokulsa:Jokulsa.lag( 2)       -0.2232455 0.0308198 0.00268918 -0.2835984
    #> Vatnsdalsa:Jokulsa.lag( 2)     0.0016049 0.0049368 0.00030936 -0.0075856
    #> Jokulsa:Vatnsdalsa.lag( 2)    -0.2632336 0.1457999 0.01109848 -0.5391868
    #> Vatnsdalsa:Vatnsdalsa.lag( 2) -0.3208660 0.0562924 0.01253762 -0.4105189
    #> Jokulsa:Temperature.lag(1)     1.1887787 0.1065221 0.00910691  0.9970505
    #> Vatnsdalsa:Temperature.lag(1)  0.0478535 0.0187300 0.00108803  0.0114049
    #> Jokulsa:Temperature.lag(2)    -0.7258338 0.1018480 0.00791009 -0.9209181
    #> Vatnsdalsa:Temperature.lag(2) -0.0540590 0.0189246 0.00137457 -0.0906691
    #>                                      25%        50%        75%      97.5%
    #> Jokulsa:(Intercept)            1.0088174  1.3369085  1.6442004  2.2046857
    #> Vatnsdalsa:(Intercept)         0.3679797  0.4475482  0.5186073  0.7273559
    #> Jokulsa:Jokulsa.lag( 1)        1.0569074  1.0851120  1.1128026  1.1604548
    #> Vatnsdalsa:Jokulsa.lag( 1)    -0.0106835 -0.0063279 -0.0020743  0.0047436
    #> Jokulsa:Vatnsdalsa.lag( 1)     0.5065260  0.6123568  0.7163413  0.9294226
    #> Vatnsdalsa:Vatnsdalsa.lag( 1)  1.2578740  1.3062128  1.3418977  1.3979920
    #> Jokulsa:Jokulsa.lag( 2)       -0.2432853 -0.2220171 -0.2002674 -0.1703035
    #> Vatnsdalsa:Jokulsa.lag( 2)    -0.0017068  0.0015996  0.0048872  0.0109577
    #> Jokulsa:Vatnsdalsa.lag( 2)    -0.3559644 -0.2729285 -0.1780783  0.0536621
    #> Vatnsdalsa:Vatnsdalsa.lag( 2) -0.3609004 -0.3282851 -0.2856788 -0.1994312
    #> Jokulsa:Temperature.lag(1)     1.1115798  1.1875205  1.2645726  1.3842905
    #> Vatnsdalsa:Temperature.lag(1)  0.0357031  0.0477983  0.0614416  0.0811665
    #> Jokulsa:Temperature.lag(2)    -0.8000215 -0.7236439 -0.6593145 -0.5206088
    #> Vatnsdalsa:Temperature.lag(2) -0.0660588 -0.0537316 -0.0418908 -0.0143790
    #>
    #>
    #> Scale parameter:
    #>                          Mean       Sd  Sd(Mean)    2.5%     25%     50%
    #> Jokulsa.Jokulsa       5.81841 0.501736 0.0341567 4.88681 5.47334 5.81445
    #> Jokulsa.Vatnsdalsa    0.27859 0.071145 0.0038619 0.15094 0.22734 0.27809
    #> Vatnsdalsa.Vatnsdalsa 0.28275 0.024618 0.0015403 0.23297 0.26596 0.28190
    #>                           75%   97.5%
    #> Jokulsa.Jokulsa       6.10752 6.80022
    #> Jokulsa.Vatnsdalsa    0.32812 0.41989
    #> Vatnsdalsa.Vatnsdalsa 0.29836 0.33451

### 1.2.9 Convergence diagnostics

#### 1.2.9.1 Geweke statistic

    geweke_diagTAR(fits[["Laplace.2.15.4.2"]])
    #>
    #> Fraction in 1st window = 0.1
    #>
    #> Fraction in 2nd window = 0.5
    #> Thresholds:
    #> Threshold.1
    #>      1.8944
    #>
    #>
    #> Regime 1
    #>
    #>
    #> Autoregressive coefficients:
    #>                    Jokulsa Vatnsdalsa
    #> (Intercept)        -2.9592   -1.82894
    #> Jokulsa.lag( 1)     1.8198    0.34278
    #> Vatnsdalsa.lag( 1)  3.6611    4.64634
    #> Jokulsa.lag( 2)     1.9775   -1.75061
    #> Vatnsdalsa.lag( 2) -2.1832    0.23539
    #>
    #>
    #> Scale parameter:
    #>            Jokulsa Vatnsdalsa
    #> Jokulsa     1.6637     1.0644
    #> Vatnsdalsa  1.0644     4.0612
    #>
    #>
    #> Regime 2
    #>
    #>
    #>
    #> Autoregressive coefficients:
    #>                      Jokulsa Vatnsdalsa
    #> (Intercept)         0.275425   -0.21867
    #> Jokulsa.lag( 1)     0.451632   -2.51149
    #> Vatnsdalsa.lag( 1)  2.914177    2.30717
    #> Jokulsa.lag( 2)    -0.660319    1.57149
    #> Vatnsdalsa.lag( 2) -3.671382   -2.13820
    #> Temperature.lag(1)  0.041469   -0.21647
    #> Temperature.lag(2)  0.316697    0.55146
    #>
    #>
    #> Scale parameter:
    #>            Jokulsa Vatnsdalsa
    #> Jokulsa    0.10636    0.39787
    #> Vatnsdalsa 0.39787   -1.51946

#### 1.2.9.2 Effective sample size

    effectiveSize_TAR(fits[["Laplace.2.15.4.2"]])
    #> Thresholds:
    #> Threshold.1
    #>      10.425
    #>
    #>
    #> Regime 1
    #>
    #>
    #> Autoregressive coefficients:
    #>                    Jokulsa Vatnsdalsa
    #> (Intercept)         12.683     15.686
    #> Jokulsa.lag( 1)     19.781     25.160
    #> Vatnsdalsa.lag( 1) 144.595     84.447
    #> Jokulsa.lag( 2)    101.521     82.312
    #> Vatnsdalsa.lag( 2)  17.380    158.163
    #>
    #>
    #> Scale parameter:
    #>            Jokulsa Vatnsdalsa
    #> Jokulsa    119.225     30.178
    #> Vatnsdalsa  30.178    101.499
    #>
    #>
    #> Regime 2
    #>
    #>
    #>
    #> Autoregressive coefficients:
    #>                    Jokulsa Vatnsdalsa
    #> (Intercept)         347.13    157.634
    #> Jokulsa.lag( 1)     123.68    223.959
    #> Vatnsdalsa.lag( 1)  243.95     16.554
    #> Jokulsa.lag( 2)     131.35    254.664
    #> Vatnsdalsa.lag( 2)  172.58     20.159
    #> Temperature.lag(1)  136.82    296.343
    #> Temperature.lag(2)  165.78    189.547
    #>
    #>
    #> Scale parameter:
    #>            Jokulsa Vatnsdalsa
    #> Jokulsa     215.77     339.39
    #> Vatnsdalsa  339.39     255.44

Gneiting, Tilmann, Laura I. Stanberry, Eric P. Grimit, Leonhard Held, and Nicholas A. Johnson. 2008. “Assessing Probabilistic Forecasts of Multivariate Quantities, with an Application to Ensemble Predictions of Surface Winds.” TEST 17 (2): 211–35. https://doi.org/10.1007/s11749-008-0114-x.
Good, I. J. 1952. “Rational Decisions.” Journal of the Royal Statistical Society: Series B (Methodological) 14 (1): 107–14.
Grimit, Eric P., Tilmann Gneiting, Veronica J. Berrocal, and Nicholas A. Johnson. 2006. “The Continuous Ranked Probability Score for Circular Variables and Its Application to Mesoscale Forecast Ensemble Verification.” Quarterly Journal of the Royal Meteorological Society 132 (621C): 2925–42. https://doi.org/10.1256/qj.05.235.
Matheson, James E., and Robert L. Winkler. 1976. “Scoring Rules for Continuous Probability Distributions.” Management Science 22 (10): 1087–96. https://doi.org/10.1287/mnsc.22.10.1087.
Spiegelhalter, D. J., N. G. Best, B. P. Carlin, and A. Van Der Linde. 2014. “The Deviance Information Criterion: 12 Years on.” Journal of the Royal Statistical Society Series B: (Statistical Methodology) 76 (3): 485–93.
Spiegelhalter, D. J., N. G Best, B. P. Carlin, and A. Van Der Linde. 2002. “Bayesian Measures of Model Complexity and Fit.” Journal of the Royal Statistical Society: Series B (Statistical Methodology) 64 (4): 583–639.
Tong, Howell. 1990. Non‑linear Time Series: A Dynamical System Approach. Oxford Statistical Science Series. Oxford, UK: Oxford University Press.
Tsay, Ruey S. 1998. “Testing and Modeling Multivariate Threshold Models.” Journal of the American Statistical Association 93 (443): 1188–1202. https://doi.org/10.1080/01621459.1998.10473779.
Vanegas, L. H., S. A. Calderón V, and L. M. Rondón. 2025. “Bayesian Estimation of a Multivariate TAR Model When the Noise Process Distribution Belongs to the Class of Gaussian Variance Mixtures.” International Journal of Forecasting. https://doi.org/https://doi.org/10.1016/j.ijforecast.2025.08.001.
Watanabe, S. 2010. “Asymptotic Equivalence of Bayes Cross Validation and Widely Applicable Information Criterion in Singular Learning Theory.” The Journal of Machine Learning Research 11: 3571–94.