View source: R/create_weights.R
create_weights | R Documentation |
Produces a matrix of fixed or an array of time varying country-specific weights for a GVAR model.
create_weights(weight_data, period, country_data = NULL)
weight_data |
a named list of named time-series objects or a named matrix containing data for the construction of weights. See 'Details'. |
period |
either an integer for time varying weights or a numeric
vector specifying the number of past periods in |
country_data |
a named list of time-series objects containing country
data. Only requried if |
The function assists in the creation of country-specific weight matrices.
If a numeric vector is provided as period
, the function calculates
country weights based on the sums over the specified periods. If an integer
is proved, the weights are constructed from rolling sums over the last
period
periods. If a country series begins earlier than its
corresponding weight series, the sums over the first period
observations of weight_data
are used until the periods match.
If weight_data
is a list, its elements should be time-series objects,
where colums should be named after the trading partner. The names of the list
elements should match the country names in country_data
. If a matrix is
provided, its rows should contain the name of the reference country and the
columns should be named after the trading partner. All cells should contain
zeros when the reference country and the trading partner are the same,
i.e. row and column names are equal.
A named matrix or an array containing country-specific weight matrices.
# Load data
data("gvar2019")
# Data objects
country_data <- gvar2019[["country_data"]]
weight_data <- gvar2019[["weight_data"]]
weight_data <- create_weights(weight_data = weight_data, period = 3,
country_data = country_data)
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.