Title: | Shrinkage Estimation Methods for Vector Autoregressive Models |
---|---|
Description: | Vector autoregressive (VAR) model is a fundamental and effective approach for multivariate time series analysis. Shrinkage estimation methods can be applied to high-dimensional VAR models with dimensionality greater than the number of observations, contrary to the standard ordinary least squares method. This package is an integrative package delivering nonparametric, parametric, and semiparametric methods in a unified and consistent manner, such as the multivariate ridge regression in Golub, Heath, and Wahba (1979) <doi:10.2307/1268518>, a James-Stein type nonparametric shrinkage method in Opgen-Rhein and Strimmer (2007) <doi:10.1186/1471-2105-8-S2-S3>, and Bayesian estimation methods using noninformative and informative priors in Lee, Choi, and S.-H. Kim (2016) <doi:10.1016/j.csda.2016.03.007> and Ni and Sun (2005) <doi:10.1198/073500104000000622>. |
Authors: | Namgil Lee [aut, cre] |
Maintainer: | Namgil Lee <[email protected]> |
License: | GPL-3 |
Version: | 0.3.1.9000 |
Built: | 2025-02-16 05:02:59 UTC |
Source: | https://github.com/namgillee/varshrink |
Returns the estimated coefficient matrices of the lagged endogenous variables of a VAR(p) model. This is a modification of vars::Acoef() for the class "varshrinkest".
Acoef_sh(x)
Acoef_sh(x)
x |
An object of class "varshrinkeset", generated by VARshrink(). |
Consider VAR(p) model:
The function returns the K-by-K matrices A_1, ..., A_p as a list object.
A list object with K-by-K VAR coefficient matrices A_1, A_2, ..., A_p
data(Canada, package = "vars") y <- diff(Canada) estim <- VARshrink(y, p = 2, type = "const", method = "ridge") Acoef_sh(estim)
data(Canada, package = "vars") y <- diff(Canada) estim <- VARshrink(y, p = 2, type = "const", method = "ridge") Acoef_sh(estim)
Performs univariate and multivariate ARCH-LM tests for a VAR. This is a modification of vars::arch.test() for the class "varshrinkest".
arch.test_sh(x, lags.single = 16, lags.multi = 5, multivariate.only = TRUE)
arch.test_sh(x, lags.single = 16, lags.multi = 5, multivariate.only = TRUE)
x |
An object of class "varshrinkest" obtained by VARshrink() |
lags.single |
An integer of the lag order used for univariate ARCH statistics. |
lags.multi |
An integer of the lag order used for multivariate ARCH statistic. |
multivariate.only |
If TRUE, only the multivariate statistic is computed. |
data(Canada, package = "vars") y <- diff(Canada) estim <- VARshrink(y, p = 2, type = "const", method = "ridge") arch.test_sh(estim)
data(Canada, package = "vars") y <- diff(Canada) estim <- VARshrink(y, p = 2, type = "const", method = "ridge") arch.test_sh(estim)
Returns the estimated coefficients of a VAR(p) model as a matrix. This is a modification of vars::Bcoef() for the class "varshrinkest".
Bcoef_sh(x)
Bcoef_sh(x)
x |
An object of class "varshrinkest" generated by VARshrink(). |
Consider VAR(p) model:
The function returns the concatenated matrix (A_1, ..., A_p, C) as a matrix object.
A matrix holding the estimated coefficients of a VAR.
data(Canada, package = "vars") y <- diff(Canada) estim <- VARshrink(y, p = 2, type = "const", method = "ridge") Bcoef_sh(estim)
data(Canada, package = "vars") y <- diff(Canada) estim <- VARshrink(y, p = 2, type = "const", method = "ridge") Bcoef_sh(estim)
This is a modification of vars::BQ() for the class "varshrinkest".
BQ_sh(x)
BQ_sh(x)
x |
An object of class "varshrinkest" obtained by VARshrink(). |
data(Canada, package = "vars") y <- diff(Canada) estim <- VARshrink(y, p = 2, type = "const", method = "ridge") BQ_sh(estim)
data(Canada, package = "vars") y <- diff(Canada) estim <- VARshrink(y, p = 2, type = "const", method = "ridge") BQ_sh(estim)
Compute sum of squared errors of coefficients of lagged endogenous variables (Acoef) of two VAR models.
calcSSE_Acoef(Acoef1, Acoef2)
calcSSE_Acoef(Acoef1, Acoef2)
Acoef1 , Acoef2
|
Each one is a list object with K-by-K coefficient matrices of lagged endogenous variables. See help(Acoef_sh), or, help(Acoef). |
Consider VAR(p) model:
The SSE of two VAR(p) models is expressed as
SSE value.
data(Canada, package = "vars") y <- diff(Canada) estim1 <- VARshrink(y, p = 2, type = "const", method = "fbayes") Acoef1 <- Acoef_sh(estim1) estim2 <- VARshrink(y, p = 2, type = "const", method = "ridge") Acoef2 <- Acoef_sh(estim2) calcSSE_Acoef(Acoef1, Acoef2)
data(Canada, package = "vars") y <- diff(Canada) estim1 <- VARshrink(y, p = 2, type = "const", method = "fbayes") Acoef1 <- Acoef_sh(estim1) estim2 <- VARshrink(y, p = 2, type = "const", method = "ridge") Acoef2 <- Acoef_sh(estim2) calcSSE_Acoef(Acoef1, Acoef2)
A modification of vars::causality() for the class "varshrinkest".
causality_sh(x, cause = NULL, vcov. = NULL, boot = FALSE, boot.runs = 100)
causality_sh(x, cause = NULL, vcov. = NULL, boot = FALSE, boot.runs = 100)
x |
An object of class "varshrinkest" obtained by VARshrink(). |
cause , vcov. , boot , boot.runs
|
Other arguments for causality analysis; see help(causality) for details. |
data(Canada, package = "vars") y <- diff(Canada) estim <- VARshrink(y, p = 2, type = "const", method = "ridge") causality_sh(estim, cause = "e")
data(Canada, package = "vars") y <- diff(Canada) estim <- VARshrink(y, p = 2, type = "const", method = "ridge") causality_sh(estim, cause = "e")
Convert a matrix of VAR coefficients estimated by a shrinkage method into a list of "shrinklm" object, where the class "shrinklm" inherits the class "lm".
convPsi2varresult(Psi, Y, X, lambda0, type = c("const", "trend", "both", "none"), ybar = NULL, xbar = NULL, Q_values = NULL, callstr = "")
convPsi2varresult(Psi, Y, X, lambda0, type = c("const", "trend", "both", "none"), ybar = NULL, xbar = NULL, Q_values = NULL, callstr = "")
Psi |
An M-by-K matrix of VAR coefficients |
Y |
An N-by-K data matrix of dependent variables |
X |
An N-by-M data matrix of regressors |
lambda0 |
A rescaled shrinkage intensity parameter, based on which the effective number of parameters is computed by
|
type |
Type of deterministic variables in the VAR estimation problem. Either of "const", "trend", "both", or "none". |
ybar , xbar
|
NULL if Y and X are not centered. Mean vectors if Y and X had been centered. If Y and X had been centered (ybar and xbar are not NULL) and type is "const" or "both", then the coefficients for the constant term is computed and concatenated to the coefficients. |
Q_values |
Nonnegative weight vector of length N. Default is NULL. Take weights on rows (samples) of Y and X by sqrt(Q). |
callstr |
The call to VARshrink(). |
Consider VAR(p) model:
It can be written in the matrix form:
where Psi is a concatenated M-by-K matrix, Psi = (A_1, ..., A_p, C)^T. It can be written in the multiple linear regression form of a VAR(p) model:
where y_j, psi_j, and e_j are the j-th column vectors of Y, Psi, and E, respectively. This function converts Psi into a list of "shrinklm" objects, where each "shrinklm" object contains the length-M vector psi_j as coefficients.
Considering that each coefficient vector psi_j is estimated by a shrinkage method, the effective number of parameters, k_eff, is computed as:
Then, the degree of freedom of residuals is computed as:
where N is the number of rows of data matrices Y and X.
A list object with objects of class c("shrinklm", "lm"). Each "shrinklm" object has components: coefficients, residuals, fitted.values, rank, df.residual, lambda0, call, terms, svd
Randomly create sparse lower-triangular matrices for VAR coefficients of lagged endogenous variables, and set a constant vector.
createVARCoefs_ltriangular(p = 1, K = 5, diag_val = 1/p, num_nonzero = 0, const_vector = NULL, range_min = 0.2, range_max = 1/p)
createVARCoefs_ltriangular(p = 1, K = 5, diag_val = 1/p, num_nonzero = 0, const_vector = NULL, range_min = 0.2, range_max = 1/p)
p |
lag order |
K |
Number of time series variables. |
diag_val |
diagonal values of A1,...,Ap |
num_nonzero |
Number of nonzero entries on the lower-triangular parts of A1, ..., Ap |
const_vector |
constant vector c of the VAR model |
range_min , range_max
|
Each nonzero off-diagonal entry of coefficient matrices is drawn uniformly from the interval [-range_max, -range_min] U [range_min, range_max] |
Consider VAR(p) model:
with the constant deterministic variable (d_t = 1). The function creates the coefficient matrices A_1, ..., A_p and constant vector c.
Diagonal elements of each K-by-K matrix A_k are all equal to diag_val, and off-diagonal elements are all zero except for a few randomly selected nonzero elements. Nonzero off-diagonal elements are selected from lower-triangular parts of A_i and the values are drawn from a uniform distribution over [-range_max, -range_min] U [range_min, range_max].
A list object with components $A and $c. $A is a list of K-by-K matrices A_1, ..., A_p, and $c is a constant vector of length K.
p <- 1; K <- 20; const_vector <- c(rep(0.2, 5), rep(0.7, 15)) createVARCoefs_ltriangular(p = p, K = K, diag_val = 0.6, num_nonzero = K, const_vector = const_vector, range_max = 1)
p <- 1; K <- 20; const_vector <- c(rep(0.2, 5), rep(0.7, 15)) createVARCoefs_ltriangular(p = p, K = K, diag_val = 0.6, num_nonzero = K, const_vector = const_vector, range_max = 1)
Computes the forecast error variance decomposition of a VAR(p) for n.ahead steps. This is a modification of vars::fevd() for the class "varshrinkest".
## S3 method for class 'varshrinkest' fevd(x, n.ahead = 10, ...)
## S3 method for class 'varshrinkest' fevd(x, n.ahead = 10, ...)
x |
Object of class 'varshrinkest';
generated by |
n.ahead |
Integer specifying the steps. |
... |
Currently not used. |
Computes the impulse response coefficients of a VAR(p) (or transformed VECM to VAR(p)) for n.ahead steps. This is a modification of vars::irf() for the class "varshrinkest".
## S3 method for class 'varshrinkest' irf(x, impulse = NULL, response = NULL, n.ahead = 10, ortho = TRUE, cumulative = FALSE, boot = TRUE, ci = 0.95, runs = 100, seed = NULL, ...)
## S3 method for class 'varshrinkest' irf(x, impulse = NULL, response = NULL, n.ahead = 10, ortho = TRUE, cumulative = FALSE, boot = TRUE, ci = 0.95, runs = 100, seed = NULL, ...)
x |
Object of class 'varshrinkest';
generated by |
impulse |
A character vector of the impulses, default is all variables. |
response |
A character vector of the responses, default is all variables. |
n.ahead |
Integer specifying the steps. |
ortho |
Logical, if TRUE (the default) the orthogonalised impulse response coefficients are computed (only for objects of class 'varshrinkest'). |
cumulative |
Logical, if TRUE the cumulated impulse response coefficients are computed. The default value is false. |
boot |
Logical, if TRUE (the default) bootstrapped error bands for the imuplse response coefficients are computed. |
ci |
Numeric, the confidence interval for the bootstrapped errors bands. |
runs |
An integer, specifying the runs for the bootstrap. |
seed |
An integer, specifying the seed for the rng of the bootstrap. |
... |
Currently not used. |
Estimate regression coefficients and scale matrix for noise by using Gibbs MCMC algorithm. The function assumes 1) multivariate t-distribution for noise as a sampling distribution, and 2) noninformative priors for regression coefficients and scale matrix for noise.
lm_full_Bayes_SR(Y, X, dof = Inf, burnincycle = 1000, mcmccycle = 2000)
lm_full_Bayes_SR(Y, X, dof = Inf, burnincycle = 1000, mcmccycle = 2000)
Y |
An N x K matrix of dependent variables. |
X |
An N x M matrix of regressors. |
dof |
Degree of freedom for multivariate t-distribution. If dof = Inf (default), then multivariate normal distribution is applied and weight vector q is not estimated. If dof = NULL or dof <= 0, then dof and q are estimated automatically. If dof is a positive number, q is estimated. |
burnincycle , mcmccycle
|
Number of burnin cycles is the number of initially generated sample values to drop. Number of MCMC cycles is the number of generated sample values to compute estimates. |
Consider the multivariate regression:
Psi is a M-by-K matrix of regression coefficients and Sigma is a K-by-K scale matrix for multivariate t-distribution for noise.
Sampling distribution for noise e is multivariate t-distribution with degree of freedom dof and scale matrix Sigma: e ~ mvt(0, dof, Sigma). The priors are noninformative priors: 1) the shrinkage prior for regression coefficients Psi, and 2) the reference prior for scale matrix Sigma.
The function implements Gibbs MCMC algorithm for estimating regression coefficients Psi and scale matrix Sigma.
A list object with estimated parameters: Psi, Sigma, dof, delta (delta is the reciprocal of lambda), and lambda. Additional components are se.param (standard error of the parameters) and LINEXVARmodel (estimates under LINEX loss).
S. Ni and D. Sun (2005). Bayesian estimates for vector autoregressive models. Journal of Business & Economic Statistics 23(1), 105-117.
Estimate regression coefficients by using ridge regression.
lm_multiv_ridge(Y, X, lambda = 0, do_scale = FALSE)
lm_multiv_ridge(Y, X, lambda = 0, do_scale = FALSE)
Y |
An N x K matrix of dependent variables. |
X |
An N x M matrix of regressors. |
lambda |
Numeric vector of lambda values |
do_scale |
If true, X is centered and scaled, and Y is centered. |
Consider the multivariate regression:
Psi is a M-by-K matrix of regression coefficients. The ridge regression estimate for the coefficients is
A list object with the components: 1) Psi - A list of estimated Psi matrices, 2) lambda - A vector of lambda values, 3) GCV - A vector of GCV values
G. H. Golub, M. Heath, G. Wahba (1979). Generalized cross-validation as a method for choosing a good ridge parameter. Technometrics 21(2), 215-223. doi: 10.2307/1268518
Estimate regression coefficients and scale matrix for noise by using a parameterized cross validation (PCV). The function assumes 1) multivariate t-distribution for noise as a sampling distribution, and 2) informative priors for regression coefficients and scale matrix for noise.
lm_semi_Bayes_PCV(Y, X, dof = Inf, lambda = NULL, lambda_var = NULL, prior_type = c("NCJ", "CJ"), num_folds = 5, m0 = ncol(Y))
lm_semi_Bayes_PCV(Y, X, dof = Inf, lambda = NULL, lambda_var = NULL, prior_type = c("NCJ", "CJ"), num_folds = 5, m0 = ncol(Y))
Y |
An N x K matrix of dependent variables. |
X |
An N x M matrix of regressors. |
dof |
Degree of freedom for multivariate t-distribution. If dof = Inf (default), then multivariate normal distribution is applied and weight vector q is not estimated. If dof = NULL or a numeric vector, then dof is selected by K-fold CV automatically and q is estimated. |
lambda |
If NULL or a vector of length >=2, it is selected by PCV. |
lambda_var |
If NULL, it is selected by a Stein-type shrinkage method. |
prior_type |
"NCJ" for non-conjugate prior and "CJ" for conjugate prior for scale matrix Sigma. |
num_folds |
Number of folds for PCV. |
m0 |
A hyperparameter for inverse Wishart distribution for Sigma |
Consider the multivariate regression:
Psi is a M-by-K matrix of regression coefficients and Sigma is a K-by-K scale matrix for multivariate t-distribution for noise.
Sampling distribution for noise e is the multivariate t-distribution with degree of freedom dof and scale matrix Sigma: e ~ mvt(0, dof, Sigma). The priors are informative priors: 1) a shrinkage prior for regression coefficients Psi, and 2) inverse Wishart prior for scale matrix Sigma, which can be either non-conjugate ("NCJ") or conjugate ("CJ") to the shrinkage prior for coefficients Psi.
The function implements parameterized cross validation (PCV) for selecting a shrinkage parameter lambda for estimating regression coefficients (0 < lambda <= 1). In addition, the function uses a Stein-type shrinkage method for selecting a shrinkage parameter lambda_var for estimating variances of time series variables.
N. Lee, H. Choi, and S.-H. Kim (2016). Bayes shrinkage estimation for high-dimensional VAR models with scale mixture of normal distributions for noise. Computational Statistics & Data Analysis 101, 250-276. doi: 10.1016/j.csda.2016.03.007
Estimate regression coefficients and scale matrix for noise by using semiparametric Bayesian shrinkage estimator, whose shrinkage parameters are selected by K-fold cross validation (KCV).
lm_ShVAR_KCV(Y, X, dof = Inf, lambda = NULL, lambda_var = NULL, prior_type = c("NCJ", "CJ"), num_folds = 5, m0 = ncol(Y))
lm_ShVAR_KCV(Y, X, dof = Inf, lambda = NULL, lambda_var = NULL, prior_type = c("NCJ", "CJ"), num_folds = 5, m0 = ncol(Y))
Y |
An N x K matrix of dependent variables. |
X |
An N x M matrix of regressors. |
dof |
Degree of freedom for multivariate t-distribution. If dof = Inf (default), then multivariate normal distribution is applied and weight vector q is not estimated. If dof = NULL or a numeric vector, then dof is selected by K-fold CV automatically and q is estimated. |
lambda |
If NULL or a vector of length >=2, it is selected by KCV. |
lambda_var |
If NULL or a vector of length >=2, it is selected by KCV. |
prior_type |
"NCJ" for non-conjugate prior and "CJ" for conjugate prior for scale matrix Sigma. |
num_folds |
Number of folds for KCV. |
m0 |
A hyperparameter for inverse Wishart distribution for Sigma |
The shrinkage parameters, lambda and lambda_var, for the semiparametric Bayesian shrinkage estimator are selected by KCV. See help(lm_semi_Bayes_PCV) for details about semiparametric Bayesian estimator.
N. Lee, H. Choi, and S.-H. Kim (2016). Bayes shrinkage estimation for high-dimensional VAR models with scale mixture of normal distributions for noise. Computational Statistics & Data Analysis 101, 250-276. doi: 10.1016/j.csda.2016.03.007
Returns the log-likelihood of a VAR model estimated by VARshrink(). It extends vars::logLik.varest() to incorporate 1) multivariate t-distribution for residuals, 2) scale matrix Sigma provided by shrinkage methods, and 3) effective number of parameters provided by shrinkage methods.
## S3 method for class 'varshrinkest' logLik(object, ...)
## S3 method for class 'varshrinkest' logLik(object, ...)
object |
An object of class "varshrinkest" |
... |
Currently not used. |
Acknowledgement: This code was contributed by Sung-Hoon Han & Dong-Han Lee @ Kangwon National University (2018.11.29.)
data(Canada, package = "vars") y <- diff(Canada) estim <- VARshrink(y, p = 2, type = "const", method = "ridge") logLik(estim)
data(Canada, package = "vars") y <- diff(Canada) estim <- VARshrink(y, p = 2, type = "const", method = "ridge") logLik(estim)
This function computes univariate and multivariate Jarque-Bera tests and multivariate skewness and kurtosis tests for the residuals of a VAR(p) or of a VECM in levels. This is a modification of vars::normality.test() for the class "varshrinkest".
normality.test_sh(x, multivariate.only = TRUE)
normality.test_sh(x, multivariate.only = TRUE)
x |
An object of class "varshrinkest" obtained by VARshrink(). |
multivariate.only |
If TRUE, only the multivariate statistics is computed. |
data(Canada, package = "vars") y <- diff(Canada) estim <- VARshrink(y, p = 2, type = "const", method = "ridge") normality.test_sh(estim)
data(Canada, package = "vars") y <- diff(Canada) estim <- VARshrink(y, p = 2, type = "const", method = "ridge") normality.test_sh(estim)
Returns the estimated coefficient matrices of the moving average representation of a stable VAR(p), of an SVAR as an array or a converted VECM to VAR. This is a modification of vars::Phi() for the class "varshrinkest".
## S3 method for class 'varshrinkest' Phi(x, nstep = 10, ...)
## S3 method for class 'varshrinkest' Phi(x, nstep = 10, ...)
x |
An object of class 'varshrinkest',
generated by |
nstep |
An integer specifying the number of moving error coefficient matrices to be calculated. |
... |
Currently not used. |
Forecating a VAR object of class 'varshrinkest' with confidence bands. This is a modification of vars::predict.varest() for the class "varshrinkest".
## S3 method for class 'varshrinkest' predict(object, ..., n.ahead = 10, ci = 0.95, dumvar = NULL)
## S3 method for class 'varshrinkest' predict(object, ..., n.ahead = 10, ci = 0.95, dumvar = NULL)
object |
An object of class 'varshrinkest';
generated by |
... |
currently not used. |
n.ahead |
An integer specifying the number of forecast steps. |
ci |
The forecast confidence interval |
dumvar |
Matrix for objects of class ‘vec2var’ or ‘varest’, if the dumvar argument in ca.jo() has been used or if the exogen argument in VARshrink() has been used, respectively. The matrix should have the same column dimension as in the call to ca.jo() or to VARshrink() and row dimension equal to n.ahead. |
Print method for an object of class "varshrinkest"
## S3 method for class 'varshrinkest' print(x, digits = max(3, getOption("digits") - 3), ...)
## S3 method for class 'varshrinkest' print(x, digits = max(3, getOption("digits") - 3), ...)
x |
An object of class "varshrinkest" |
digits , ...
|
Other arguments for print() method |
data(Canada, package = "vars") y <- diff(Canada) estim <- VARshrink(y, p = 2, type = "const", method = "ridge") print(estim)
data(Canada, package = "vars") y <- diff(Canada) estim <- VARshrink(y, p = 2, type = "const", method = "ridge") print(estim)
Print method for an object obtained by summary.varshrinkest().
## S3 method for class 'varshsum' print(x, digits = max(3, getOption("digits") - 3), signif.stars = getOption("show.signif.stars"), ...)
## S3 method for class 'varshsum' print(x, digits = max(3, getOption("digits") - 3), signif.stars = getOption("show.signif.stars"), ...)
x |
An object of class "varshsum" |
digits , signif.stars , ...
|
Other arguments for print(), printCoefmat(), format() method |
This function extends print.varsum() for VAR models estimated by shrinkage methods. The output includes scale matrix Sigma and degree of freedom dof for multivariate t-distribution for residuals.
This is a modification of vars::restrict() for the class "varshrinkest". Warning: THIS CODE IS NOT COMPLETE: this function may raise an error because it ignores shrinkage estimation.
restrict_sh(x, ...)
restrict_sh(x, ...)
x |
An object of class "varshrinkest" |
... |
Other arguments to vars::restrict() |
data(Canada, package = "vars") y <- diff(Canada) estim <- VARshrink(y, p = 2, type = "const", method = "ridge") restrict_sh(estim)
data(Canada, package = "vars") y <- diff(Canada) estim <- VARshrink(y, p = 2, type = "const", method = "ridge") restrict_sh(estim)
This is a variant of vars::roots() for an object of class 'varshrinkest',
VAR parameters estimated by VARshrink()
.
roots_sh(x, modulus = TRUE)
roots_sh(x, modulus = TRUE)
x |
An object of class "varshrinkest" |
modulus |
TRUE for modulus of the roots. |
data(Canada, package = "vars") y <- diff(Canada) estim <- VARshrink(y, p = 2, type = "const", method = "ridge") roots_sh(estim)
data(Canada, package = "vars") y <- diff(Canada) estim <- VARshrink(y, p = 2, type = "const", method = "ridge") roots_sh(estim)
An extension of vars::serial.test() to the class "varshrinkest".
serial.test_sh(x, lags.pt = 16, lags.bg = 5, type = c("PT.asymptotic", "PT.adjusted", "BG", "ES"))
serial.test_sh(x, lags.pt = 16, lags.bg = 5, type = c("PT.asymptotic", "PT.adjusted", "BG", "ES"))
x |
An object of class "varshrinkest" obtained by VARshrink(). |
lags.pt , lags.bg , type
|
Other arguments for vars::serial.test(). see help(serial.test) for details. |
data(Canada, package = "vars") y <- diff(Canada) estim <- VARshrink(y, p = 2, type = "const", method = "ridge") serial.test_sh(estim)
data(Canada, package = "vars") y <- diff(Canada) estim <- VARshrink(y, p = 2, type = "const", method = "ridge") serial.test_sh(estim)
Compute the semiparametric Bayesian shrinkage estimator of Psi and Sigma for a given shrinkage parameter lambda. The function is a private function for lm_semi_Bayes_PCV() and lm_ShVAR_KCV().
shrinkVARcoef(Y, X, lambda, dof = Inf, prior_type = "NCJ", TolDRes = 1e-04, m0 = ncol(Y))
shrinkVARcoef(Y, X, lambda, dof = Inf, prior_type = "NCJ", TolDRes = 1e-04, m0 = ncol(Y))
Y |
An N x K matrix of dependent variables. |
X |
An N x M matrix of regressors. |
lambda |
A shrinkage intensity parameter value between 0~1. |
dof |
Degree of freedom for multivariate t-distribution. If NULL or Inf, then use multivariate normal distribution. |
prior_type |
"NCJ" for non-conjugate prior and "CJ" for conjugate prior for scale matrix Sigma. |
TolDRes |
Tolerance parameter for stopping criterion. |
m0 |
A hyperparameter for inverse Wishart distribution for Sigma |
N. Lee, H. Choi, and S.-H. Kim (2016). Bayes shrinkage estimation for high-dimensional VAR models with scale mixture of normal distributions for noise. Computational Statistics & Data Analysis 101, 250-276. doi: 10.1016/j.csda.2016.03.007
Generate a multivariate time series data set using the given VAR model.
simVARmodel(numT, model, burnin = 0)
simVARmodel(numT, model, burnin = 0)
numT |
Number of observed time points, T. |
model |
A list object with Coef, Sigma, dof; Coef is a list with A and c; A is a list object of K-by-K coefficient matrices and c is a length-K vector. Sigma is a K-by-K scale matrix and dof is a degree of freedom for multivariate t-distribution for noise. |
burnin |
Number of initial points which are not included in the final values. |
First, it creates (p+burnin+numT x K) data, then it remove the first (p+burnin) vectors. Finally, it returns (numT x K) data.
A numT-by-K matrix
myCoef <- list(A = list(matrix(c(0.5, 0, 0, 0.5), 2, 2)), c = c(0.2, 0.7)) myModel <- list(Coef = myCoef, Sigma = diag(0.1^2, 2), dof = Inf) simVARmodel(numT = 100, model = myModel, burnin = 10)
myCoef <- list(A = list(matrix(c(0.5, 0, 0, 0.5), 2, 2)), c = c(0.2, 0.7)) myModel <- list(Coef = myCoef, Sigma = diag(0.1^2, 2), dof = Inf) simVARmodel(numT = 100, model = myModel, burnin = 10)
A variant of vars::stability(). Warning: this function has not been tested for small sample sizes yet.
stability_sh(x, type = c("OLS-CUSUM", "Rec-CUSUM", "Rec-MOSUM", "OLS-MOSUM", "RE", "ME", "Score-CUSUM", "Score-MOSUM", "fluctuation"), h = 0.15, dynamic = FALSE, rescale = TRUE, ...)
stability_sh(x, type = c("OLS-CUSUM", "Rec-CUSUM", "Rec-MOSUM", "OLS-MOSUM", "RE", "ME", "Score-CUSUM", "Score-MOSUM", "fluctuation"), h = 0.15, dynamic = FALSE, rescale = TRUE, ...)
x |
An object of class "varshrinkest" |
type , h , dynamic , rescale , ...
|
Other arguments to strucchange::efp() |
data(Canada, package = "vars") y <- diff(Canada) estim <- VARshrink(y, p = 2, type = "const", method = "ridge") stability_sh(estim)
data(Canada, package = "vars") y <- diff(Canada) estim <- VARshrink(y, p = 2, type = "const", method = "ridge") stability_sh(estim)
Class "shrinklm" inherits the class "lm", and it extends the "lm" class to incorporate shrinkage estimates with effective number of parameter.
## S3 method for class 'shrinklm' summary(object, correlation = FALSE, symbolic.cor = FALSE, ...)
## S3 method for class 'shrinklm' summary(object, correlation = FALSE, symbolic.cor = FALSE, ...)
object |
An object of class "shrinklm" |
correlation |
If TRUE, the correlation matrix of the the estimated coefficients is returned and printed. |
symbolic.cor |
If TRUE, print the correlations in a symbolic form rather than as numbers |
... |
Currently not used. |
Extend summary.varest() to class 'varshrinest' to incorporate adapted methods for new classes: summary.shrinklm(), logLik.varshrinkest(), roots.varshrinkest().
## S3 method for class 'varshrinkest' summary(object, equations = NULL, ...)
## S3 method for class 'varshrinkest' summary(object, equations = NULL, ...)
object |
An object of class "varshrinkest", usually a result of call to "VARshrink()". |
equations |
Subset of names of endogenous time series variables to summarize. |
... |
Currently not used. |
Code is modified to avoid call to data matrices ($y, $datamat) and to use effective numbers of parameters of shrinkage estimates.
Output includes the scale matrix, Sigma, and degree-of-freedom, dof, for multivariate t-distribution for residuals.
data(Canada, package = "vars") y <- diff(Canada) estim <- VARshrink(y, p = 2, type = "const", method = "ridge") summary(estim)
data(Canada, package = "vars") y <- diff(Canada) estim <- VARshrink(y, p = 2, type = "const", method = "ridge") summary(estim)
Shrinkage estimation methods for high-dimensional VAR models. Consider VAR(p) model: y_t = A_1 y_t-1 + ... + A_p y_t-p + C d_t + e_t, where y_t is K-dimensional time series, d_t is deterministic regressors, e_t is a noise process, and A_1, ..., A_p, and C are coefficient matrices. Exogenous variables can be included additionally as regressors.
VARshrink(y, p = 1, type = c("const", "trend", "both", "none"), season = NULL, exogen = NULL, method = c("ridge", "ns", "fbayes", "sbayes", "kcv"), lambda = NULL, lambda_var = NULL, dof = Inf, ...)
VARshrink(y, p = 1, type = c("const", "trend", "both", "none"), season = NULL, exogen = NULL, method = c("ridge", "ns", "fbayes", "sbayes", "kcv"), lambda = NULL, lambda_var = NULL, dof = Inf, ...)
y |
A T-by-K matrix of endogenous variables |
p |
Integer for the lag order |
type |
Type of deterministic regressors to include. #' 1) "const" - the constant. 2) "trend" - the trend. 3) "both" - both the constant and the trend. 4) "none" - no deterministic regressors. ***Note: In the package version <= 0.3, method='ns' does not accept type="const" and type="both" to avoid constant term. |
season |
An integer value of frequency for inclusion of centered seasonal dummy variables. abs(season) >= 3. |
exogen |
A T-by-L matrix of exogenous variables. Default is NULL. |
method |
1) "ridge" - multivariate ridge regression. 2) "ns" - a Stein-type nonparametric shrinkage method. 3) "fbayes" - a full Bayesian shrinkage method using noninformative priors. 4) "sbayes" - a semiparametric Bayesian shrinkage method using parameterized cross validation. 5) "kcv" - a semiparametric Bayesian shrinkage method using K-fold cross validation |
lambda , lambda_var
|
Shrinkage parameter value(s). Use of this parameter is slightly different for each method: the same value does not imply the same shrinkage estimates. |
dof |
Degree of freedom of multivariate t-distribution for noise. Valid only for method = "fbayes" and method = "sbayes". dof=Inf means multivariate normal distribution. |
... |
Extra arguments to pass to a specific function of the estimation method. For example, burnincycle and mcmccycle are for "fbayes". |
Shrinkage estimation methods can estimate the coefficients even when the dimensionality K is larger than the number of observations.
An object of class "varshrinkest" with the components: varresult, datamat, y, type, p, K, obs, totobs, restrictions, method, lambda, call. The class "varshrinkest" inherits the class "varest" in the package vars.
data(Canada, package = "vars") y <- diff(Canada) VARshrink(y, p = 2, type = "const", method = "ridge")
data(Canada, package = "vars") y <- diff(Canada) VARshrink(y, p = 2, type = "const", method = "ridge")