create_regions: Create Regional Series

View source: R/create_regions.R

create_regionsR Documentation

Create Regional Series

Description

Combines multiple country-specific time series to regional series.

Usage

create_regions(country_data, weight_data, region_weights, regions, period)

Arguments

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 country_data.

regions

a named list of character vectors containing specifications for countries in country_data, which should be combined to a region. The name of the respective list element will become the name of the region.

period

either a single integer or a numeric vector specifiying the periods in region_weights, which should be used to construct weights.

Details

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.

Value

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.

Examples

# 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 


franzmohr/bgvars documentation built on Sept. 2, 2023, 12:45 p.m.