Gather data of several countries in a list. Particularly useful for GVAR-based setups (Compute "GVARFactors")
Source:R/DatabasePrep.R
DatabasePrep.Rd
Gather data of several countries in a list. Particularly useful for GVAR-based setups (Compute "GVARFactors")
Usage
DatabasePrep(
t_First,
t_Last,
Economies,
N,
FactorLabels,
ModelType,
Macro_FullData,
Yields_FullData,
Wgvar = NULL
)
Arguments
- t_First
Start date of the sample period in the format yyyy-mm-dd.
- t_Last
End date of the sample period in the format yyyy-mm-dd.
- Economies
A character vector containing the names of the economies included in the system.
- N
Integer. Number of country-specific spanned factors.
- FactorLabels
A list of character vectors with labels for all variables in the model.
- ModelType
A character vector indicating the model type to be estimated.
- Macro_FullData
List containing a full set of macroeconomic data.
- Yields_FullData
List containing a full set of bond yield data
- Wgvar
GVAR transition matrix of size C x C, applicable if a GVAR-type model is selected. Default is NULL.
Value
List containing the risk factor set. This list is particularly useful for the estimation of the GVAR-based models.
Examples
# Load data from excel
macro_data <- Load_Excel_Data(system.file("extdata", "MacroData.xlsx", package = "MultiATSM"))
yields_data <- Load_Excel_Data(system.file("extdata", "YieldsData.xlsx", package = "MultiATSM"))
trade_data <- Load_Excel_Data(system.file("extdata", "TradeData.xlsx", package = "MultiATSM"))
#> New names:
#> • `` -> `...1`
#> New names:
#> • `` -> `...1`
#> New names:
#> • `` -> `...1`
#> New names:
#> • `` -> `...1`
#> New names:
#> • `` -> `...1`
# Adjust trade data
trade_data <- lapply(trade_data, function(df) {
countries <- df[[1]]
df <- as.data.frame(df[-1])
rownames(df) <- countries
df
})
# Define features of interest
ModelType <- "GVAR multi"
Economies <- c("China", "Uruguay", "Russia")
GlobalVar <- c("GBC", "CPI_OECD")
DomVar <- c("Eco_Act", "Inflation")
N <- 3
t0 <- "2006-09-01"
tF <- "2019-01-01"
# Compute some inputs
FactorLabels <- LabFac(N, DomVar, GlobalVar, Economies, ModelType)
Wgvar <- Transition_Matrix(t_First = "2006", t_Last= "2019", Economies,
type = "Sample Mean", trade_data)
# Compute GVARFactors
GVARFactors <- DatabasePrep(t0, tF, Economies, N, FactorLabels, ModelType, macro_data,
yields_data, Wgvar)