Title: | Efficient Bayesian Inference for TVP-VAR-SV Models with Shrinkage |
---|---|
Description: | Efficient Markov chain Monte Carlo (MCMC) algorithms for fully Bayesian estimation of time-varying parameter vector autoregressive models with shrinkage priors. Details on the algorithms used are provided in Cadonna et al. (2020) <doi:10.3390/econometrics8020020> and Knaus et al. (2021) <doi:10.18637/jss.v100.i13>. |
Authors: | Peter Knaus [aut, cre] |
Maintainer: | Peter Knaus <[email protected]> |
License: | GPL (>= 2) |
Version: | 0.1.1 |
Built: | 2024-11-16 06:53:53 UTC |
Source: | CRAN |
density_plotter
plots empirical kernel density estimates of the posterior distribution for hyperparameters
of a time-varying parameter coefficient matrix in a TVP-VAR model. beta_mean
and theta_sr
will most
likely be of interest here.
density_plotter( x, lag = 1, mgp = c(1.5, 0.5, 0), ylim, xlim, ylabs, mains, h_borders = c(0.075, 0.05), w_borders = c(0.05, 0.05), ... )
density_plotter( x, lag = 1, mgp = c(1.5, 0.5, 0), ylim, xlim, ylabs, mains, h_borders = c(0.075, 0.05), w_borders = c(0.05, 0.05), ... )
x |
|
lag |
single integer value, indicating the lag of the time-varying VAR to be plotted. The default value is 1. |
mgp |
vector of length 3, determining the margin line (in |
ylim |
numeric vector of length 2, determining the y-axis limits of the plot.
If missing, the limits are determined by the |
xlim |
numeric vector of length 2, determining the x-axis limits of the plot. If missing, the limits are determined by the minimum and maximum values of the data. |
ylabs |
character vector of length m, determining the y-axis labels of the plot. If missing, the labels are taken from the column names of the data. |
mains |
character vector of length m, determining the main titles of the plot. If missing, the titles are taken from the column names of the data. |
h_borders |
numeric vector of length 2, determining the horizontal borders of the plot.
The first value is the space between the plot and the left border,
the second value is the space between the plot and the right border.
Both are fractions of the total width of the plot. The default value is |
w_borders |
numeric vector of length 2, determining the vertical borders of the plot.
The first value is the space between the plot and the top border,
the second value is the space between the plot and the bottom border.
Both are fractions of the total height of the plot. The default value is |
... |
further arguments to be passed to |
Called for its side effects and returns invisibly.
Peter Knaus [email protected]
Other plotting functions:
TV_heatmap()
,
plot.mcmc.tvp.var()
,
plot.mcmc.var()
,
plot.shrinkTVPVAR()
,
plot.shrinkTVPVAR_fit()
,
plot.shrinkTVPVAR_forc()
,
state_plotter()
set.seed(123) sim <- simTVPVAR(p = 2) data <- sim$data res <- shrinkTVPVAR(data, p = 2) plot(res$theta_sr) # Plot second lag plot(res$theta_sr, lag = 2)
set.seed(123) sim <- simTVPVAR(p = 2) data <- sim$data res <- shrinkTVPVAR(data, p = 2) plot(res$theta_sr) # Plot second lag plot(res$theta_sr, lag = 2)
Calculates the fitted values for an estimated TVP-VAR-SV model.
## S3 method for class 'shrinkTVPVAR' fitted(object, ...)
## S3 method for class 'shrinkTVPVAR' fitted(object, ...)
object |
A |
... |
Currently ignored. |
An object of class shrinkTVPVAR_fit
Peter Knaus [email protected]
Other prediction functions:
forecast_shrinkTVPVAR()
set.seed(123) sim <- simTVPVAR(p = 2) data <- sim$data res <- shrinkTVPVAR(data, p = 2) fitted <- fitted(res) # Visualize fitted values plot(fitted)
set.seed(123) sim <- simTVPVAR(p = 2) data <- sim$data res <- shrinkTVPVAR(data, p = 2) fitted <- fitted(res) # Visualize fitted values plot(fitted)
forecast_shrinkTVPVAR
draws from the posterior predictive distribution of a fitted TVP-VAR-SV model resulting from a call to
shrinkTVPVAR
.
forecast_shrinkTVPVAR(mod, n.ahead = 1)
forecast_shrinkTVPVAR(mod, n.ahead = 1)
mod |
an object of class |
n.ahead |
a single, positive integer indicating the forecasting horizon, i.e. how many time-points into the future
the posterior predictive distribution should be sampled from. Can not be larger than the number of rows in |
The value returned is a list object of class shrinkTVPVAR_forc
containing the samples from the
posterior predictive density.
Peter Knaus [email protected]
Other prediction functions:
fitted.shrinkTVPVAR()
set.seed(123) sim <- simTVPVAR(p = 2) data <- sim$data res <- shrinkTVPVAR(data, p = 2) forc <- forecast_shrinkTVPVAR(res, n.ahead = 4) # Visualize forecast plot(forc)
set.seed(123) sim <- simTVPVAR(p = 2) data <- sim$data res <- shrinkTVPVAR(data, p = 2) forc <- forecast_shrinkTVPVAR(res, n.ahead = 4) # Visualize forecast plot(forc)
gen_TVP_params
creates either a list or a list of lists of hyperparameters
in the correct format to be used as input for a TVP-VAR-SV model estimated by shrinkTVPVAR
.
gen_TVP_params(m = 2, for_each_eq = TRUE)
gen_TVP_params(m = 2, for_each_eq = TRUE)
m |
The number of equations in the VAR model. Ignored if |
for_each_eq |
Logical. If TRUE, a list of lists is returned, where each list contains the hyperparameters for one equation. If FALSE, a single list is returned. |
Either a list containing the hyperparameters for all equations or a list of lists containing the hyperparameters for each equation individually.
Peter Knaus [email protected]
# For a 5 equation model params <- gen_TVP_params(m = 5) # For a model where all equations share the same hyperparameters params <- gen_TVP_params(for_each_eq = FALSE)
# For a 5 equation model params <- gen_TVP_params(m = 5) # For a model where all equations share the same hyperparameters params <- gen_TVP_params(for_each_eq = FALSE)
mcmc.tvp.var
objectsPlotting method for mcmc.tvp.var
objects
## S3 method for class 'mcmc.tvp.var' plot(x, ...)
## S3 method for class 'mcmc.tvp.var' plot(x, ...)
x |
|
... |
further arguments to be passed to For further details see |
Called for its side effects and returns invisibly.
Peter Knaus [email protected]
Other plotting functions:
TV_heatmap()
,
density_plotter()
,
plot.mcmc.var()
,
plot.shrinkTVPVAR()
,
plot.shrinkTVPVAR_fit()
,
plot.shrinkTVPVAR_forc()
,
state_plotter()
set.seed(123) sim <- simTVPVAR(p = 2) data <- sim$data res <- shrinkTVPVAR(data, p = 2) plot(res$beta)
set.seed(123) sim <- simTVPVAR(p = 2) data <- sim$data res <- shrinkTVPVAR(data, p = 2) plot(res$beta)
mcmc.var
objectsPlotting method for mcmc.var
objects
## S3 method for class 'mcmc.var' plot(x, ...)
## S3 method for class 'mcmc.var' plot(x, ...)
x |
|
... |
further arguments to be passed to For further details see |
Called for its side effects and returns invisibly.
Peter Knaus [email protected]
Other plotting functions:
TV_heatmap()
,
density_plotter()
,
plot.mcmc.tvp.var()
,
plot.shrinkTVPVAR()
,
plot.shrinkTVPVAR_fit()
,
plot.shrinkTVPVAR_forc()
,
state_plotter()
set.seed(123) sim <- simTVPVAR(p = 2) data <- sim$data res <- shrinkTVPVAR(data, p = 2) plot(res$theta_sr)
set.seed(123) sim <- simTVPVAR(p = 2) data <- sim$data res <- shrinkTVPVAR(data, p = 2) plot(res$theta_sr)
shrinkTVPVAR
objectsPlotting method for shrinkTVPVAR
objects
## S3 method for class 'shrinkTVPVAR' plot(x, ...)
## S3 method for class 'shrinkTVPVAR' plot(x, ...)
x |
|
... |
further arguments to be passed to For further details see |
Called for its side effects and returns invisibly.
Peter Knaus [email protected]
Other plotting functions:
TV_heatmap()
,
density_plotter()
,
plot.mcmc.tvp.var()
,
plot.mcmc.var()
,
plot.shrinkTVPVAR_fit()
,
plot.shrinkTVPVAR_forc()
,
state_plotter()
set.seed(123) sim <- simTVPVAR(p = 2) data <- sim$data res <- shrinkTVPVAR(data, p = 2) plot(res)
set.seed(123) sim <- simTVPVAR(p = 2) data <- sim$data res <- shrinkTVPVAR(data, p = 2) plot(res)
plot.shrinkTVPVAR_fit
generates plots visualizing the posterior distribution of fitted values
of a model generated by a call to shrinkTVPVAR
.
## S3 method for class 'shrinkTVPVAR_fit' plot(x, nplot = 3, h_borders = c(0.05, 0.05), w_borders = c(0.02, 0.02), ...)
## S3 method for class 'shrinkTVPVAR_fit' plot(x, nplot = 3, h_borders = c(0.05, 0.05), w_borders = c(0.02, 0.02), ...)
x |
a |
nplot |
single integer value, determining the number of plots (i.e. number of equations to visualize at once) to be generated. The default value is 3. |
h_borders |
numeric vector of length 2, determining the horizontal borders of the plot.
The first value is the space between the plot and the left border,
the second value is the space between the plot and the right border.
Both are fractions of the total width of the plot. The default value is |
w_borders |
numeric vector of length 2, determining the vertical borders of the plot.
The first value is the space between the plot and the top border,
the second value is the space between the plot and the bottom border.
Both are fractions of the total height of the plot. The default value is |
... |
further arguments to be passed to |
Called for its side effects and returns invisibly.
Peter Knaus [email protected]
Other plotting functions:
TV_heatmap()
,
density_plotter()
,
plot.mcmc.tvp.var()
,
plot.mcmc.var()
,
plot.shrinkTVPVAR()
,
plot.shrinkTVPVAR_forc()
,
state_plotter()
set.seed(123) sim <- simTVPVAR(p = 2) data <- sim$data res <- shrinkTVPVAR(data, p = 2) fit <- fitted(res) plot(fit)
set.seed(123) sim <- simTVPVAR(p = 2) data <- sim$data res <- shrinkTVPVAR(data, p = 2) fit <- fitted(res) plot(fit)
plot.shrinkTVPVAR_forc
generates plots visualizing the posterior predictive density generated by forecast_shrinkTVPVAR
.
## S3 method for class 'shrinkTVPVAR_forc' plot(x, nplot = 3, h_borders = c(0.05, 0.05), w_borders = c(0.02, 0.02), ...)
## S3 method for class 'shrinkTVPVAR_forc' plot(x, nplot = 3, h_borders = c(0.05, 0.05), w_borders = c(0.02, 0.02), ...)
x |
a |
nplot |
single integer value, determining the number of plots (i.e. number of equations to visualize at once) to be generated. The default value is 3. |
h_borders |
numeric vector of length 2, determining the horizontal borders of the plot.
The first value is the space between the plot and the left border,
the second value is the space between the plot and the right border.
Both are fractions of the total width of the plot. The default value is |
w_borders |
numeric vector of length 2, determining the vertical borders of the plot.
The first value is the space between the plot and the top border,
the second value is the space between the plot and the bottom border.
Both are fractions of the total height of the plot. The default value is |
... |
further arguments to be passed to |
Called for its side effects and returns invisibly.
Peter Knaus [email protected]
Other plotting functions:
TV_heatmap()
,
density_plotter()
,
plot.mcmc.tvp.var()
,
plot.mcmc.var()
,
plot.shrinkTVPVAR()
,
plot.shrinkTVPVAR_fit()
,
state_plotter()
set.seed(123) sim <- simTVPVAR(p = 2) data <- sim$data res <- shrinkTVPVAR(data, p = 2) forc <- forecast_shrinkTVPVAR(res, n.ahead = 2) plot(forc)
set.seed(123) sim <- simTVPVAR(p = 2) data <- sim$data res <- shrinkTVPVAR(data, p = 2) forc <- forecast_shrinkTVPVAR(res, n.ahead = 2) plot(forc)
Nicer printing of shrinkTVPVAR objects
## S3 method for class 'shrinkTVPVAR' print(x, ...)
## S3 method for class 'shrinkTVPVAR' print(x, ...)
x |
a |
... |
Currently ignored. |
Called for its side effects and returns invisibly.
Peter Knaus [email protected]
shrinkTVPVAR
samples from the joint posterior distribution of the parameters of a TVP-VAR-SV
model with shrinkage as described in Cadonna et al. (2020) and returns the MCMC draws.
The model can be written as:
where .
shrinkTVPVAR( y, p = 1, mod_type = "double", const = TRUE, niter = 5000, nburn = round(niter/2), nthin = 1, display_progress = TRUE, TVP_params_beta = list(), TVP_params_sigma = list() )
shrinkTVPVAR( y, p = 1, mod_type = "double", const = TRUE, niter = 5000, nburn = round(niter/2), nthin = 1, display_progress = TRUE, TVP_params_beta = list(), TVP_params_sigma = list() )
y |
matrix or data frame containing the time series data. The rows correspond to the time points and the columns to the variables. |
p |
positive integer indicating the number of lags in the VAR model. The default value is 1. |
mod_type |
character string that reads either |
const |
logical value indicating whether a constant should be included in the model. The default value is |
niter |
positive integer, indicating the number of MCMC iterations
to perform, including the burn-in. Has to be larger than or equal to |
nburn |
non-negative integer, indicating the number of iterations discarded
as burn-in. Has to be smaller than or equal to |
nthin |
positive integer, indicating the degree of thinning to be performed. Every |
display_progress |
logical value indicating whether the progress bar and other informative output should be
displayed. The default value is |
TVP_params_beta |
optional named list containing hyperparameter values for the TVP prior of the beta_mean matrix.
Not all have to be supplied, with those missing being replaced by the default values. Any list elements that are misnamed will be ignored and a warning will be thrown.
Can either be a list of depth 1, which results in all equations having the same hyperparameters, or a list of lists of length
|
TVP_params_sigma |
optional named list containing hyperparameter values for the TVP prior of the Sigma matrix.
The structure is the same as for |
The elements of the VAR coefficients are assumed to follow component-wise
random walk.
For further details concerning the algorithms and the model please refer to the paper by Cadonna et al. (2020).
The value returned is a shrinkTVPVAR
object containing:
beta |
an object of class |
beta_mean |
an object of class |
theta_sr |
an object of class |
xi2 |
an object of class |
c_xi |
an object of class |
kappa2 |
an object of class |
kappa2_B |
an object of class |
a_xi |
an object of class |
tau2 |
an object of class |
c_tau |
an object of class |
lambda2 |
an object of class |
lambda2_B |
an object of class |
a_tau |
an object of class |
Sigma |
an object of class |
pred_objs |
a list containing objects required for prediction methods to work. |
beta_consts |
a list of |
data |
a list containing the input data, as well as the synthetic "covariates" used for estimation. |
Note that only the values pertaining to the VAR coefficients are returned. The values for the variance-covariance matrix are not returned.
To display the output, use plot
on various elements of the list, as well as the TV_heatmap
,
density_plotter
and state_plotter
function. Many functions that can be applied to coda::mcmc
objects
(e.g. coda::acfplot
) can be applied to all output elements that are coda
compatible.
Peter Knaus [email protected]
Cadonna, A., Frühwirth-Schnatter, S., & Knaus, P. (2020). "Triple the Gamma—A Unifying Shrinkage Prior for Variance and Variable Selection in Sparse State Space and TVP Models." Econometrics, 8(2), 20. <doi:10.3390/econometrics8020020>
Knaus, P., Bitto-Nemling, A., Cadonna, A., & Frühwirth-Schnatter, S. (2021) "Shrinkage in the Time-Varying Parameter Model Framework Using the R
Package shrinkTVP
."
Journal of Statistical Software 100(13), 1–32. <doi:10.18637/jss.v100.i13>
TV_heatmap
density_plotter
state_plotter
set.seed(123) sim <- simTVPVAR(p = 2) data <- sim$data res <- shrinkTVPVAR(data, p = 2) # Visualize the results plot(res) plot(res$theta_sr) # Change prior to triple gamma res2 <- shrinkTVPVAR(data, p = 2, mod_type = "triple") # Modify the hyperparameter setup # Estimate under hierarchical horseshoe prior hyperparam <- list(learn_a_xi = FALSE, learn_c_xi = FALSE, learn_a_tau = FALSE, learn_c_tau = FALSE, a_xi = 0.5, c_xi = 0.5, a_tau = 0.5, c_tau = 0.5) res3 <- shrinkTVPVAR(data, p = 2, mod_type = "triple", TVP_params_beta = hyperparam, TVP_params_sigma = hyperparam) # Can also specify different hyperparameters for each equation # gen_TVP_params() is a helper function and returns a # list of lists (if for_each_eq = TRUE) where each sub-list # contains the hyperparameters for the respective equation hyperparam2 <- gen_TVP_params(m = 3, for_each_eq = TRUE) hyperparam2[[1]]$learn_a_xi <- FALSE hyperparam2[[1]]$a_xi <- 0.5 res4 <- shrinkTVPVAR(data, p = 2, mod_type = "triple", TVP_params_beta = hyperparam2) # Now, a_xi is only fixed in first equation plot(res4$a_xi)
set.seed(123) sim <- simTVPVAR(p = 2) data <- sim$data res <- shrinkTVPVAR(data, p = 2) # Visualize the results plot(res) plot(res$theta_sr) # Change prior to triple gamma res2 <- shrinkTVPVAR(data, p = 2, mod_type = "triple") # Modify the hyperparameter setup # Estimate under hierarchical horseshoe prior hyperparam <- list(learn_a_xi = FALSE, learn_c_xi = FALSE, learn_a_tau = FALSE, learn_c_tau = FALSE, a_xi = 0.5, c_xi = 0.5, a_tau = 0.5, c_tau = 0.5) res3 <- shrinkTVPVAR(data, p = 2, mod_type = "triple", TVP_params_beta = hyperparam, TVP_params_sigma = hyperparam) # Can also specify different hyperparameters for each equation # gen_TVP_params() is a helper function and returns a # list of lists (if for_each_eq = TRUE) where each sub-list # contains the hyperparameters for the respective equation hyperparam2 <- gen_TVP_params(m = 3, for_each_eq = TRUE) hyperparam2[[1]]$learn_a_xi <- FALSE hyperparam2[[1]]$a_xi <- 0.5 res4 <- shrinkTVPVAR(data, p = 2, mod_type = "triple", TVP_params_beta = hyperparam2) # Now, a_xi is only fixed in first equation plot(res4$a_xi)
simTVPVAR
generates synthetic data from a TVP-VAR-SV model. The data is always generated as to be stationary.
This is done via a trial and error approach, where the VAR coefficients are drawn from the data generating process until
the VAR process is stationary. As such, very large models might take a long time to generate.
simTVPVAR( N = 200, p = 2, m = 3, prob_0_beta = 0.8, prob_0_theta = 0.8, simsig2_theta_sr = 0.2, simsig2_beta_mean = 0.2, intercept = TRUE, display_progress = TRUE )
simTVPVAR( N = 200, p = 2, m = 3, prob_0_beta = 0.8, prob_0_theta = 0.8, simsig2_theta_sr = 0.2, simsig2_beta_mean = 0.2, intercept = TRUE, display_progress = TRUE )
N |
integer > 2. Indicates the length of the time series to be generated. The default value is 200. |
p |
integer > 0. Indicates the number of lags in the VAR model. The default value is 2. |
m |
integer > 1. Indicates the number of equations in the VAR model. The default value is 3. |
prob_0_beta |
numeric. Indicates the probability of a zero element in the beta_mean matrix. Can be a single value or a vector of length p. The default value is 0.8. |
prob_0_theta |
numeric. Indicates the probability of a zero element in the theta matrix. Can be a single value or a vector of length p. The default value is 0.8. |
simsig2_theta_sr |
numeric. Indicates the standard deviation of the normal distribution from which the elements of the theta matrix are drawn. The default value is 0.2. |
simsig2_beta_mean |
numeric. Indicates the standard deviation of the normal distribution from which the elements of the beta_mean matrix are drawn. The default value is 0.2. |
intercept |
logical. Indicates whether an intercept should be included in the model. The default value is TRUE. |
display_progress |
logical. Indicates whether a progress bar should be displayed. The default value is TRUE. |
The value returned is a list object containing:
data:
data frame that holds the simulated data.
true_vals:
list object containing:
Phi:
array containing the true VAR coefficients.
Sigma:
array containing the true covariance matrices.
theta_sr:
array containing the true standard deviations of the theta matrix.
beta_mean:
array containing the true means of the beta matrix.
Peter Knaus [email protected]
# Generate a time series of length 300 res <- simTVPVAR(N = 300, m = 3, p = 3) # Estimate a model model <- shrinkTVPVAR(y = res$data, p = 3)
# Generate a time series of length 300 res <- simTVPVAR(N = 300, m = 3, p = 3) # Estimate a model model <- shrinkTVPVAR(y = res$data, p = 3)
plot.mcmc.tvp
plots empirical posterior quantiles for a time-varying parameter coefficient matrix in a TVP-VAR model.
state_plotter( x, lag = 1, mgp = c(1.5, 0.5, 0), ylim, ylabs, mains, h_borders = c(0.075, 0.05), w_borders = c(0.05, 0.05), ... )
state_plotter( x, lag = 1, mgp = c(1.5, 0.5, 0), ylim, ylabs, mains, h_borders = c(0.075, 0.05), w_borders = c(0.05, 0.05), ... )
x |
|
lag |
single integer value, indicating the lag of the time-varying VAR to be plotted. The default value is 1. |
mgp |
vector of length 3, determining the margin line (in |
ylim |
numeric vector of length 2, determining the y-axis limits of the plot. If missing, the limits are determined by the lowest and largest quantiles of the data. |
ylabs |
character vector of length m, determining the y-axis labels of the plot. If missing, the labels are taken from the column names of the data. |
mains |
character vector of length m, determining the main titles of the plot. If missing, the titles are taken from the column names of the data. |
h_borders |
numeric vector of length 2, determining the horizontal borders of the plot.
The first value is the space between the plot and the left border,
the second value is the space between the plot and the right border.
Both are fractions of the total width of the plot. The default value is |
w_borders |
numeric vector of length 2, determining the vertical borders of the plot.
The first value is the space between the plot and the top border,
the second value is the space between the plot and the bottom border.
Both are fractions of the total height of the plot. The default value is |
... |
further arguments to be passed to |
Called for its side effects and returns invisibly.
Peter Knaus [email protected]
Other plotting functions:
TV_heatmap()
,
density_plotter()
,
plot.mcmc.tvp.var()
,
plot.mcmc.var()
,
plot.shrinkTVPVAR()
,
plot.shrinkTVPVAR_fit()
,
plot.shrinkTVPVAR_forc()
set.seed(123) sim <- simTVPVAR(p = 2) data <- sim$data res <- shrinkTVPVAR(data, p = 2) plot(res$beta) # Plot second lag plot(res$beta, lag = 2)
set.seed(123) sim <- simTVPVAR(p = 2) data <- sim$data res <- shrinkTVPVAR(data, p = 2) plot(res$beta) # Plot second lag plot(res$beta, lag = 2)
TV_heatmap
plots a heatmap of posterior distribution for hyperparameters
of a time-varying parameter coefficient matrix in a TVP-VAR model. This is achieved
by plotting the median of the posterior of the absolute value for theta_sr
and the
median of the posterior for all others. The plot itself is generated by
lattice::levelplot
.
beta_mean
and theta_sr
will most likely be of interest here.
TV_heatmap(x, cuts = 15, cols, max_val, flipcols, ...)
TV_heatmap(x, cuts = 15, cols, max_val, flipcols, ...)
x |
|
cuts |
single integer value, determining the number of cuts for the color palette. The default value is 15. |
cols |
character string, determining the color palette to be used. The default value is "Purples" for |
max_val |
numeric value, determining the maximum value for the color palette. If missing, the maximum value is determined by the largest absolute value of the data. |
flipcols |
logical value, determining whether the color palette should be flipped. The default value is |
... |
further arguments to be passed to |
Called for its side effects and returns invisibly.
Peter Knaus [email protected]
Other plotting functions:
density_plotter()
,
plot.mcmc.tvp.var()
,
plot.mcmc.var()
,
plot.shrinkTVPVAR()
,
plot.shrinkTVPVAR_fit()
,
plot.shrinkTVPVAR_forc()
,
state_plotter()
set.seed(123) sim <- simTVPVAR(p = 2) data <- sim$data res <- shrinkTVPVAR(data, p = 2) TV_heatmap(res$theta_sr)
set.seed(123) sim <- simTVPVAR(p = 2) data <- sim$data res <- shrinkTVPVAR(data, p = 2) TV_heatmap(res$theta_sr)