Learn R Programming

jollofR (version 0.6.5)

sprinkle1: sprinkle1: Disaggregates population counts at high-resolution grid cells using the grid's total population. This can also be applied to one-level disaggregation

Description

This function disaggregates population estimates at grid cell levels using the population counts of each grid cell.

Usage

sprinkle1(df, rdf, class, rclass, output_dir, verbose = TRUE)

Value

A list of data frame objects of the output files including the disaggregated population proportions and population totals along with the corresponding measures of uncertainties (lower and upper bounds of 95-percent credible intervals) for each demographic characteristic. In addition, a file containing the model performance/model fit evaluation metrics is also produced.

Arguments

df

A data frame object containing sample data (often partially observed) on different demographic groups population. It contains the admin's total populatioin count to be disaggregated as well as other key variables as defined within the 'toydata'.

rdf

A gridded data frame object containing key information on the grid cells. Variables include the admin_id which must be identical to the one in the admin level data. It contains GPS coordinates. i.e, longitude (lon) and Latitude (lat) of the grid cell's centroids.

class

These are the categories of the variables of interest. For example, for educational level, it could be 'no education', ' primary education', 'secondary education', 'tertiary education'.

rclass

This is a user-defined names of the files to be saved in the output folder.

output_dir

This is the directory with the name of the output folder where the disaggregated population proportions and population totals are automatically saved.

verbose

Logical. If TRUE, prints progress messages. Default is TRUE.

Examples

Run this code
# \donttest{
if (requireNamespace("INLA", quietly = TRUE)) {
 # load relevant libraries
 library(raster)
 library(dplyr)
 library(terra)
 # load the toy data
 data(toydata)
 # run 'cheesepop' function for admin level disaggregation
 result <- cheesepop(df = toydata$admin,output_dir = tempdir())
 class <- names(toydata$admin %>% dplyr::select(starts_with("age_")))

 rclass <- paste0("TOY_population_v1_0_age",1:12)
 # run 'sprinkle1' function for grid cell disaggregation at one level
 result2 <- sprinkle1(df = result$full_data,
 rdf = toydata$grid, class, rclass, output_dir = tempdir())
 ras2<- rast(paste0(output_dir = tempdir(), "/pop_TOY_population_v1_0_age4.tif"))
 plot(ras2) # visulize raster
}
# }

Run the code above in your browser using DataLab