Computes the transition matrix required in the estimation of the GVAR model
Source:R/Transition_Matrix.R
Transition_Matrix.Rd
Computes the transition matrix required in the estimation of the GVAR model
Arguments
- t_First
Sample starting date (in the format: yyyy).
- t_Last
Sample ending date (in the format: yyyy).
- Economies
A character vector containing the names of the economies included in the system.
- type
A character string indicating the method for computing interdependence. Possible options include:
Time-varying
: Computes time-varying interdependence and returns the weight matrices for each year based on available data (may extrapolate the sample period).Sample Mean
: Returns a single weight matrix containing the average weights over the entire sample period, suitable for time-invariant interdependence.A specific year (e.g., "1998", "2005"): Used to compute time-invariant interdependence for the specified year.
- DataConnectedness
Data used to compute the transition matrix.
Details
If there is missing data for any country of the system for that particularly year, then the transition matrix will include only NAs.
Examples
t_First <- "2006"
t_Last <- "2019"
Economies <- c("China", "Brazil", "Mexico", "Uruguay")
type <- "Sample Mean"
GetExcelData <- FALSE
if (GetExcelData) {
if (!requireNamespace("readxl", quietly = TRUE)) {
stop(
"Please install package \"readxl\" to use this feature.",
call. = FALSE
)
DataPath <- system.file("extdata", "TradeData.xlsx", package = "MultiATSM")
tab_names_Trade <- readxl::excel_sheets(DataPath)
list_all_Trade <- suppressMessages(lapply(tab_names_Trade, function(x)
readxl::read_excel(path = DataPath, sheet = x)))
names(list_all_Trade) <- tab_names_Trade
L <- length(list_all_Trade)
for (i in 1:L) {
Countries <- list_all_Trade[[i]][[1]]
list_all_Trade[[i]] <- as.data.frame(list_all_Trade[[i]][,-1])
rownames(list_all_Trade[[i]]) <- Countries
}
DataConnectedness <- list_all_Trade
}
} else {
data(CM_Trade)
DataConnectedness <- TradeFlows
}
W_mat <- Transition_Matrix(t_First, t_Last, Economies, type, DataConnectedness)