# NOT RUN {
# Loading data - population and sample data
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,
custom_indicator = list( my_max = function(y, threshold){max(y)},
my_min = function(y, threshold){min(y)}), na.rm = TRUE, cpus = 1)
# Load shape file
load_shapeaustria()
# Create mapping table such that variables that indicate domains correspond
# in population data and shape file
mapping_table <- data.frame(unique(eusilcA_pop$district),
unique(shape_austria_dis$NAME_2))
# Example 1: 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 = "NAME_2",
map_tab = mapping_table)
# Example 2:
# Now we are creating plots for the Mean and the Median with both their precision
# measures, while forcing coloring ranges of both indicators to be the same
# First, define appropriate scales for each indicator and measure and save it
# in a nested list as seen below
my_scale_points <- list(Mean = list(ind = c(0, 75000),
MSE = c(45000, 15000000),
CV = c(0, 0.5)
),
Median = list(ind = c(0, 75000),
MSE = c(45000, 15000000),
CV = c(0, 0.5)
)
)
# When done so, this list may be used as an argument to map_plot
map_plot(object = emdi_model, MSE = TRUE, CV = TRUE,
map_obj = shape_austria_dis, indicator = c("Mean", "Median"),
map_dom_id = "NAME_2", map_tab = mapping_table,
scale_points = my_scale_points)
# Example 3:
# In the simple case, that all plots shall use the same color range,
# the procedure from example 2 may be abbreviated to:
map_plot(object = emdi_model, MSE = FALSE, CV = FALSE,
map_obj = shape_austria_dis, indicator = c("Mean", "Median"),
map_dom_id = "NAME_2", map_tab = mapping_table,
scale_points = c(0, 75000))
# }
Run the code above in your browser using DataLab