View source: R/create_regions.R
create_regions | R Documentation |
Combines multiple country-specific time series to regional series.
create_regions(country_data, weight_data, region_weights, regions, period)
country_data |
a named list of time-series objects containing country data. |
weight_data |
a named list of named time-series objects. See 'Details'. |
region_weights |
a multivariate time-series object containing data used
to weight the observations in |
regions |
a named list of character vectors containing specifications for countries
in |
period |
either a single integer or a numeric vector specifiying the periods in
|
If a numeric vector is provided for argument period
, the function weights
country-specific observations based on the sums over the specified periods.
If an integer is proved, the country-specific observations are weighted
according to rolling sums over the last period
periods. If country
data start earlier than the series in region_weights
, the sums over
the first period
observations of region_weights
are used
until the periods match.
The elements of weight_data
should be time-series objects,
where colums are named after the trading partners of the respective country
and the names of the elements should match the country names in
country_data
. For each country list element the time-series object should
contain zeros in the column of the respective country. For examle, the column
"US" in the "US"-element of the list should only contain zeros.
A list containing the following elements:
country_data |
a named list of updated time-series objects with country data. |
weight_data |
a named list of named time-series objects for the generation of country-specific weight matrices. |
# Load data
data("gvar2019")
# Create regions
temp <- create_regions(country_data = gvar2019$country_data,
weight_data = gvar2019$weight_data,
region_weights = gvar2019$region_weights,
regions = list(EA = c("AT", "BE", "DE", "ES", "FI", "FR", "IT", "NL")),
period = 3)
# New data sets
country_data <- temp$country_data
weight_data <- temp$weight_data
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.