| Title: | Bayesian Unit Root Test for AR(1) Model with Trend Approximated by Linear Spline Function |
|---|---|
| Description: | Performs Bayesian unit root testing for autoregressive time series models with non-linear trend components approximated by linear spline functions, as proposed by Kumar et al. (2020) <doi:10.19139/soic-2310-5070-786>. The package 'BayesSplineUR' computes posterior odds ratios, Bayes factors, and posterior probabilities for the unit root hypothesis against trend-stationary alternatives in models with linear spline trends or maintained polynomial trends as developed by Chaturvedi and Kumar (2005) <doi:10.1016/j.spl.2005.04.044>. Includes automatic knot selection using information criteria (AIC/BIC) and theoretical foundations for Bayesian unit root testing under structural breaks and maintained trends drawing from Schotman and van Dijk (1991) <doi:10.1016/0304-4076(91)90038-F>, Phillips and Perron (1988) <doi:10.1093/biomet/75.2.335>, Ouliaris et al. (1988) <doi:10.1007/978-94-009-2953-1_10>, and Perron (1989) <doi:10.2307/1913683>. |
| Authors: | Shikhar Tyagi [aut, cre] (ORCID: <https://orcid.org/0000-0003-1606-0844>), Arvind Pandey [aut], Bhupendra Singh [aut], Vrijesh Tripathi [aut] |
| Maintainer: | Shikhar Tyagi <[email protected]> |
| License: | GPL (>= 3) |
| Version: | 0.1.0 |
| Built: | 2026-10-06 10:19:11 UTC |
| Source: | https://github.com/cran/BayesSplineUR |
Monthly import data (in Billion US Dollars) for 14 selected ASEAN Regional Forum (ARF) countries covering the period April 2012 to August 2018 (77 monthly observations). Analyzed in Section 5 of Kumar et al. (2020) for empirical illustration of the Bayesian unit root test with linear spline trend.
arf_importsarf_imports
A data frame with 77 rows and 15 variables:
Date of observation (monthly, April 2012 to August 2018).
Monthly imports for Australia (Billion USD).
Monthly imports for Hong Kong (Billion USD).
Monthly imports for Japan (Billion USD).
Monthly imports for South Korea (Billion USD).
Monthly imports for New Zealand (Billion USD).
Monthly imports for Taiwan (Billion USD).
Monthly imports for China (Billion USD).
Monthly imports for India (Billion USD).
Monthly imports for Indonesia (Billion USD).
Monthly imports for Malaysia (Billion USD).
Monthly imports for Philippines (Billion USD).
Monthly imports for Singapore (Billion USD).
Monthly imports for Thailand (Billion USD).
Monthly imports for Viet Nam (Billion USD).
International Monetary Fund (IMF) and International Financial Statistics (IFS) data portal.
Kumar, J., Agiwal, V., Kumar, D., & Chaturvedi, A. (2020). Bayesian unit root test for AR(1) model with trend approximated by linear spline function. Statistics, Optimization & Information Computing, 8(2), 425–461. doi:10.19139/soic-2310-5070-786
data(arf_imports) india_imports <- arf_imports$India res <- bayes_ur_spline_test(india_imports, knots = c(14, 32, 52)) print(res)data(arf_imports) india_imports <- arf_imports$India res <- bayes_ur_spline_test(india_imports, knots = c(14, 32, 52)) print(res)
Computes the posterior odds ratio, Bayes factor, and posterior probability for testing the unit root hypothesis (H0: rho = 1) against the trend-stationary alternative (H1: rho in (a, 1)) in an autoregressive AR(1) model where the non-linear time trend is approximated by a linear spline function, as derived by Kumar et al. (2020).
bayes_ur_spline_test( y, knots = NULL, r = 1, a = 0, p0 = 0.5, vartheta = 1, Omega = NULL, psi0 = NULL, y0 = NULL, n_grid = 500 ) kumar_spline_test( y, knots = NULL, r = 1, a = 0, p0 = 0.5, vartheta = 1, Omega = NULL, psi0 = NULL, y0 = NULL, n_grid = 500 )bayes_ur_spline_test( y, knots = NULL, r = 1, a = 0, p0 = 0.5, vartheta = 1, Omega = NULL, psi0 = NULL, y0 = NULL, n_grid = 500 ) kumar_spline_test( y, knots = NULL, r = 1, a = 0, p0 = 0.5, vartheta = 1, Omega = NULL, psi0 = NULL, y0 = NULL, n_grid = 500 )
y |
A numeric vector or univariate time series. |
knots |
Optional numeric vector of knot locations (indices 1 < t1 < ... < tr < T). If NULL, knot locations are automatically selected using |
r |
Positive integer specifying the number of spline knots if |
a |
Lower bound of the prior interval (a, 1) for autoregressive parameter rho under H1 (default is 0). Must satisfy -1 < a < 1. |
p0 |
Prior probability of the unit root hypothesis H0 (default is 0.5). Must satisfy 0 < p0 < 1. |
vartheta |
Prior hyperparameter scaling parameter for trend precision (default is 1.0). Must be positive. |
Omega |
Optional prior precision matrix (r x r) for spline coefficients (default is identity matrix I_r). |
psi0 |
Optional prior mean vector (r x 1) for spline coefficients (default is column means of spline design matrix). |
y0 |
Optional initial observation value y_0 (default is y[1]). |
n_grid |
Integer specifying the number of evaluation grid points for rho (default is 500). |
An object of class "bayes_ur_test" and "htest" containing:
statistic |
The posterior odds ratio (B01) in favor of the unit root hypothesis H0. |
p.value |
The posterior probability P(H0|y) of the unit root hypothesis. |
bayes_factor |
The Bayes factor (BF01) in favor of H0 relative to H1. |
posterior_h0 |
Posterior probability of the unit root hypothesis H0. |
posterior_h1 |
Posterior probability of the stationary alternative hypothesis H1. |
rho_summary |
Vector of summary statistics for rho under H1 (mean, sd, median, 2.5%, 97.5% quantiles). |
rho_grid |
Vector of evaluation grid points for rho in (a, 1). |
rho_density |
Vector of normalized posterior density values for rho under H1. |
parameter |
Named vector of test settings (r, knots, a, p0). |
method |
Character string describing the test method. |
data.name |
Character string providing the data name. |
estimates |
Named vector of estimated parameter values. |
Kumar, J., Agiwal, V., Kumar, D., & Chaturvedi, A. (2020). Bayesian unit root test for AR(1) model with trend approximated by linear spline function. Statistics, Optimization & Information Computing, 8(2), 425–461. doi:10.19139/soic-2310-5070-786
Schotman, P., & van Dijk, H. K. (1991). A Bayesian analysis of the unit root in real exchange rates. Journal of Econometrics, 49(1-2), 195–238. doi:10.1016/0304-4076(91)90038-F
Phillips, P. C. B., & Perron, P. (1988). Testing for a unit root in time series regression. Biometrika, 75(2), 335–346. doi:10.1093/biomet/75.2.335
set.seed(123) # Simulated AR(1) time series with linear spline trend t_vec <- 1:60 y_sim <- 5 + 0.1 * t_vec + pmax(0, t_vec - 30) * 0.4 + rnorm(60) res <- bayes_ur_spline_test(y_sim, knots = c(30)) print(res) summary(res)set.seed(123) # Simulated AR(1) time series with linear spline trend t_vec <- 1:60 y_sim <- 5 + 0.1 * t_vec + pmax(0, t_vec - 30) * 0.4 + rnorm(60) res <- bayes_ur_spline_test(y_sim, knots = c(30)) print(res) summary(res)
Computes the posterior odds ratio, Bayes factor, and posterior probabilities for testing the unit root hypothesis (H0: rho = 1) in autoregressive time series models with non-linear linear spline trends (Kumar et al., 2020) or maintained polynomial trends (Chaturvedi & Kumar, 2005).
bayes_ur_test( y, trend_type = c("spline", "polynomial"), knots = NULL, r = 1, p = 1, k = 1, a = 0, p0 = 0.5, vartheta = 1, V = NULL, n_grid = 500, ... ) chaturvedi_test(y, p = 1, k = 1, a = 0, p0 = 0.5, V = NULL, n_grid = 500)bayes_ur_test( y, trend_type = c("spline", "polynomial"), knots = NULL, r = 1, p = 1, k = 1, a = 0, p0 = 0.5, vartheta = 1, V = NULL, n_grid = 500, ... ) chaturvedi_test(y, p = 1, k = 1, a = 0, p0 = 0.5, V = NULL, n_grid = 500)
y |
A numeric vector or univariate time series. |
trend_type |
Character string specifying the trend model: |
knots |
Optional numeric vector of knot locations for linear spline trend. If NULL and |
r |
Positive integer specifying the number of spline knots when |
p |
Degree of polynomial trend when |
k |
Lag augmentation order when |
a |
Lower bound of prior interval (a, 1) for rho under H1 (default is 0). Must satisfy -1 < a < 1. |
p0 |
Prior probability of unit root hypothesis H0 (default is 0.5). Must satisfy 0 < p0 < 1. |
vartheta |
Prior hyperparameter scaling parameter for trend precision (default is 1.0). |
V |
Optional prior precision matrix for polynomial trend coefficients or scaling factor. |
n_grid |
Number of evaluation grid points for rho (default is 500). |
... |
Additional arguments passed to |
An object of class "bayes_ur_test" and "htest".
Kumar, J., Agiwal, V., Kumar, D., & Chaturvedi, A. (2020). Bayesian unit root test for AR(1) model with trend approximated by linear spline function. Statistics, Optimization & Information Computing, 8(2), 425–461. doi:10.19139/soic-2310-5070-786
Chaturvedi, A., & Kumar, J. (2005). Bayesian unit root test for model with maintained trend. Statistics & Probability Letters, 74(1), 109–115. doi:10.1016/j.spl.2005.04.044
set.seed(123) y_sim <- cumsum(rnorm(50)) # Spline trend unit root test (Kumar et al., 2020) res_spline <- bayes_ur_test(y_sim, trend_type = "spline", r = 1) print(res_spline) # Polynomial trend unit root test (Chaturvedi & Kumar, 2005) res_poly <- bayes_ur_test(y_sim, trend_type = "polynomial", p = 1, k = 1) print(res_poly)set.seed(123) y_sim <- cumsum(rnorm(50)) # Spline trend unit root test (Kumar et al., 2020) res_spline <- bayes_ur_test(y_sim, trend_type = "spline", r = 1) print(res_spline) # Polynomial trend unit root test (Chaturvedi & Kumar, 2005) res_poly <- bayes_ur_test(y_sim, trend_type = "polynomial", p = 1, k = 1) print(res_poly)
A simulated univariate time series vector containing 100 observations exhibiting a random walk with drift, suitable for demonstrating unit root testing.
macro_datamacro_data
A numeric vector of length 100.
Simulated dataset generated for package documentation and examples.
data(macro_data) res <- bayes_ur_test(macro_data, trend_type = "spline", r = 1) print(res)data(macro_data) res <- bayes_ur_test(macro_data, trend_type = "spline", r = 1) print(res)
Plots the posterior density of the autoregressive parameter rho under H1 along with prior density and unit root probability point mass.
## S3 method for class 'bayes_ur_test' plot(x, ...)## S3 method for class 'bayes_ur_test' plot(x, ...)
x |
An object of class |
... |
Further graphical arguments. |
No return value, called for side effects (plotting).
Prints a concise summary of the Bayesian unit root test results.
## S3 method for class 'bayes_ur_test' print(x, ...)## S3 method for class 'bayes_ur_test' print(x, ...)
x |
An object of class |
... |
Further arguments passed to or from other methods. |
Invisibly returns the input object x.
Identifies the optimal number and locations of join points (knots) in a time series with a linear spline trend based on Akaike Information Criterion (AIC) or Bayesian Information Criterion (BIC), as described in Section 5 of Kumar et al. (2020).
select_knots(y, max_r = 3, criterion = c("AIC", "BIC"), min_gap = 5)select_knots(y, max_r = 3, criterion = c("AIC", "BIC"), min_gap = 5)
y |
A numeric vector or univariate time series. |
max_r |
Positive integer specifying the maximum number of knots to evaluate (default is 3). |
criterion |
Character string specifying the selection criterion: |
min_gap |
Positive integer specifying minimum observations between consecutive knots (default is 5). |
A list containing:
r |
Selected optimal number of knots. |
knots |
Vector of selected optimal knot locations (indices). |
aic |
Minimum AIC value achieved. |
bic |
Minimum BIC value achieved. |
model_summary |
Data frame summarizing evaluated models across different knot configurations. |
Kumar, J., Agiwal, V., Kumar, D., & Chaturvedi, A. (2020). Bayesian unit root test for AR(1) model with trend approximated by linear spline function. Statistics, Optimization & Information Computing, 8(2), 425–461. doi:10.19139/soic-2310-5070-786
set.seed(123) t_vec <- 1:60 y_sim <- 10 + 0.2 * t_vec + pmax(0, t_vec - 25) * 0.5 + rnorm(60) res_knots <- select_knots(y_sim, max_r = 2, criterion = "AIC") print(res_knots$knots)set.seed(123) t_vec <- 1:60 y_sim <- 10 + 0.2 * t_vec + pmax(0, t_vec - 25) * 0.5 + rnorm(60) res_knots <- select_knots(y_sim, max_r = 2, criterion = "AIC") print(res_knots$knots)
Provides detailed summary output for a Bayesian unit root test object.
## S3 method for class 'bayes_ur_test' summary(object, ...)## S3 method for class 'bayes_ur_test' summary(object, ...)
object |
An object of class |
... |
Further arguments passed to or from other methods. |
Invisibly returns the input object object.