impute_down: Imputing Data From Larger To Smaller Units

Description Usage Arguments Value See Also Examples

View source: R/impute_down.R

Description

Imputing Data From Larger To Smaller Units

Usage

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
impute_down(
  upstream_data = NULL,
  downstream_data = NULL,
  country_var = "country_code",
  regional_code = "geo_code",
  values_var = "values",
  time_var = NULL,
  upstream_method_var = NULL,
  downstream_method_var = NULL
)

Arguments

upstream_data

An upstream data frame to project on containing smaller geographical units, for example, country-level data.

downstream_data

A downstream data frame containing the smaller level missing data observations. It must contain all the necessary structural information for imputation.

country_var

The geographical ID of the upstream data, defaults to "country_code".

regional_code

The geographical ID of the downstream data, defaults to "geo_code".

values_var

The variable that contains the upstream data to be imputed to the downstream data, defaults to "values".

time_var

The time component, if present, defaults to "year".

upstream_method_var

The name of the variable that contains the potentially applied imputation methods. Defaults to NULL.

downstream_method_var

The name of the variable that will contain the metadata of the potentially applied imputation methods. Defaults to NULL in which case a variable called 'method' will be created. If possible, avoid using upstream_data or downstream_data that contains a variable called 'method' for other purposes.

Value

The upstream data frame (containing data of a larger unit) and the downstream data (containing data of smaller sub-divisional units) are joined; whenever data is missing in the downstream sub-divisional column, it is imputed with the corresponding values from the upstream data frame. The 'method' metadata column explains if the actual downstream data or the imputed data can be found in the downstream value column.

See Also

Other impute functions: impute_down_nuts()

Examples

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
{
upstream <- data.frame ( country_code =  rep( "AU", 3),
                         year = c(2018:2020),
                         my_var  = c(10,12,11),
                         description = c("note1", NA_character_,
                         "note3")
                       )

downstream <- australia_states

impute_down ( upstream_data  = upstream,
              downstream_data = downstream,
              country_var = "country_code",
              regional_code = "geo_code",
              values_var = "my_var",
              time_var = "year" )
}

regions documentation built on June 21, 2021, 5:06 p.m.