sim_cf_dens {geocausal}R Documentation

Simulate counterfactual densities

Description

'sim_cf_dens()' takes a list of power densities and returns simulated counterfactual densities.

Usage

sim_cf_dens(
  expected_number,
  base_dens,
  power_sim_results,
  window,
  grayscale = FALSE,
  color = c("white", "#F8DAC5FF", "#F4825AFF", "#D2204CFF", "#771F59FF")
)

Arguments

expected_number

the expected number of observations

base_dens

the baseline density (im object)

power_sim_results

the results obtained by 'simulate_power_density()'

window

owin object

grayscale

logical. 'grayscale' specifies whether to convert plot to grayscale (by default, FALSE).

color

the color scale. By default, "white", "#F8DAC5FF", "#F4825AFF", "#D2204CFF", and "#771F59FF".

Value

list of counterfactual densities, a ggplot, and priorities

Examples

# Baseline density
baseline <- get_base_dens(option = "out",
                          out_data = airstrikes_base,
                          out_coordinates = c("longitude", "latitude"),
                          window = iraq_window,
                          ndim = 64)

# Density 1: Distance from Mosul
dist_from_mosul <- get_dist_focus(window = iraq_window,
                                  lon = c(43.158),
                                  lat = c(36.349),
                                  resolution = 0.5,
                                  mile = FALSE,
                                  preprocess = FALSE)

# Density 2: Distance from Baghdad
dist_from_baghd <- get_dist_focus(window = iraq_window,
                                  lon = c(44.366),
                                  lat = c(33.315),
                                  resolution = 0.5,
                                  mile = FALSE,
                                  preprocess = FALSE)

# Simulation of power density
sim_power_mosul <- sim_power_dens(target_dens = list(dist_from_baghd),
                                  dens_manip = dist_from_mosul,
                                  priorities = 1,
                                  priorities_manip = c(1, 2, 5, 10, 15, 50),
                                  window = iraq_window,
                                  grayscale = FALSE)

# Simulation of counterfactual density
sim_cf_dens(expected_number = 3,
            base_dens = baseline,
            power_sim_results = sim_power_mosul,
            window = iraq_window,
            grayscale = FALSE)

[Package geocausal version 0.3.0 Index]