map_plot: Visualizes regional disaggregrated estimates on a map

Description Usage Arguments Value See Also Examples

View source: R/map_plot.R

Description

Function map_plot creates spatial visualizations of the estimates obtained by small area estimation methods or direct estimation.

Usage

1
2
3
4
map_plot(object, indicator = "all", MSE = FALSE, CV = FALSE,
  map_obj = NULL, map_dom_id = NULL, map_tab = NULL,
  color = c("white", "red4"), scale_points = NULL,
  guide = "colourbar", return_data = FALSE)

Arguments

object

an object of type emdi, containing the estimates to be visualized.

indicator

optional character vector that selects which indicators shall be returned: (i) all calculated indicators ("all"); (ii) each indicator name, for ebp and direct objects: "Mean", "Quantile_10", "Quantile_25", "Median", "Quantile_75", "Quantile_90", "Head_Count", "Poverty_Gap", "Gini", "Quintile_Share" or the function name/s of "custom_indicator/s"; for fh objects, "FH" or "Direct"; (iii) groups of indicators (only for ebp and direct): "Quantiles", "Poverty" or "Inequality". Defaults to "all". Note, additional custom indicators can be defined as argument for the direct and ebp estimation (see also ebp and direct) and do not appear in groups of indicators even though these might belong to one of the groups.

MSE

optional logical. If TRUE, the MSE is also visualized.

CV

optional logical. If TRUE, the CV is also visualized.

map_obj

an SpatialPolygonsDataFrame object as defined by the sp package on which the data should be visualized.

map_dom_id

a character string containing the name of a variable in map_obj that indicates the domains.

map_tab

a data.frame object with two columns that match the domain variable from the census data set (first column) with the domain variable in the map_obj (second column). This should only be used if the IDs in both objects differ.

color

a vector of length 2 defining the lowest and highest color in the plots.

scale_points

a structure defining the lowest, the mid and the highest value of the colorscale. If a numeric vector of length two is given, this scale will be used for every plot. Alternatively a list defining colors for each plot separately may be given. Please see the details section and examples for this.

guide

character passed to scale_colour_gradient from ggplot2. Possible values are "none", "colourbar", and "legend".

return_data

if set to TRUE a fortified data frame including the map data as well as the chosen indicators is returned. Customized maps can easily be obtained from this data frame via the package ggplot2. Defaults to FALSE.

Value

Creates the plots demanded, and, if selected, a fortified data.frame containing the mapdata and chosen indicators.

See Also

ebp, emdiObject, readShapePoly

Examples

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
## Not run: 
data("eusilcA_pop")
data("eusilcA_smp")

# Generate emdi object with additional indicators; here via function ebp()
emdi_model <- ebp(fixed = eqIncome ~ gender + eqsize + cash +
                    self_empl + unempl_ben + age_ben + surv_ben + sick_ben + dis_ben + rent +
                    fam_allow + house_allow + cap_inv + tax_adj, pop_data = eusilcA_pop,
                  pop_domains = "district", smp_data = eusilcA_smp, smp_domains = "district",
                  threshold = 11064.82, transformation = "box.cox", L= 50, MSE = TRUE, B = 50)

# Load shape file
load_shapeaustria()

# Create map plot for mean indicator - point and MSE estimates but no CV
map_plot(object = emdi_model, MSE = TRUE, CV = FALSE,
         map_obj = shape_austria_dis, indicator = c("Mean"),
         map_dom_id = "PB")

# Create a suitable mapping table to use numerical identifiers of the shape
# file

# First find the right order
dom_ord <- match(shape_austria_dis@data$PB, emdi_model$ind$Domain)

# Create the mapping table based on the order obtained above
map_tab <- data.frame(pop_data_id = emdi_model$ind$Domain[dom_ord],
                      shape_id = shape_austria_dis@data$BKZ)

# Create map plot for mean indicator - point and CV estimates but no MSE
# using the numerical domain identifiers of the shape file

map_plot(object = emdi_model, MSE = FALSE, CV = TRUE,
         map_obj = shape_austria_dis, indicator = c("Mean"),
         map_dom_id = "BKZ", map_tab = map_tab)

        
## End(Not run)

akreutzmann/fayherriot documentation built on Aug. 19, 2019, 12:22 p.m.