Learn R Programming

regions (version 0.1.8)

impute_down: Imputing Data From Larger To Smaller Units

Description

Imputing Data From Larger To Smaller Units

Usage

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

Run this code
# NOT RUN {
{
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" )
}
# }

Run the code above in your browser using DataLab