calculate_posterior: Calculate the estimated location of mobile devices

View source: R/calculate_posterior.R

calculate_posteriorR Documentation

Calculate the estimated location of mobile devices

Description

Calculate the estimated location of mobile devices, i.e. the location posterior probabilities. This is the final step of the mobloc process (see vignette("mobloc")).

Usage

calculate_posterior(prior, llh, raster)

Arguments

prior

prior object, the result of create_uniform_prior, create_prior, or create_network_prior

llh

a likelihood object, e.g. the result of create_voronoi_llh and create_strength_llh

raster

raster object that contains the raster tile index numbers (e.g. created with create_raster)

See Also

vignette("mobloc")

Examples

## Not run: 
# set parameters
ZL_param <- mobloc_param()

# load data
data("ZL_cellplan", "ZL_muni", "ZL_elevation", "ZL_landuse")

# create environment layer (needed to calculate path loss exponent (ple))
ZL_envir <- combine_raster_layers(ZL_landuse, weights = c(1, 1, 1, 0, 0))

# validate cellplan
ZL_cellplan <- validate_cellplan(ZL_cellplan, param = ZL_param, region = ZL_muni,
                                 envir = ZL_envir, elevation = ZL_elevation)

# create raster
ZL_bbox <- sf::st_bbox(c(xmin = 4012000, ymin = 3077000, xmax = 4048000, ymax = 3117000),
                       crs = sf::st_crs(3035))
ZL_raster <- create_raster(ZL_bbox)

# compute the signal strength model
ZL_strength <- compute_sig_strength(cp = ZL_cellplan, raster = ZL_raster,
                                    elevation = ZL_elevation, param = ZL_param)

# create likelihoods
ZL_strength_llh <- create_strength_llh(ZL_strength, param = ZL_param)
ZL_voronoi_llh <- create_voronoi_llh(ZL_cellplan, ZL_raster)

# create priors
ZL_uniform_prior <- create_uniform_prior(ZL_raster)
ZL_network_prior <- create_network_prior(ZL_strength, ZL_raster)
ZL_landuse_prior <- create_prior(ZL_landuse, weights = c(1, 1, .1, 0, .5))
ZL_comp_prior <- create_prior(ZL_network_prior, ZL_landuse_prior, weights = c(.25, .75))

# calculate the mobile phone locations, i.e. the location posterior.
ZL_post <- calculate_posterior(prior = ZL_comp_prior, llh = ZL_strength_llh, raster = ZL_raster)

# update posterior with timing advance (TA).
ZL_post_TA <- update_posterior_TA(ZL_post, ZL_raster, ZL_cellplan, ZL_param, ZL_elevation)


## End(Not run)

MobilePhoneESSnetBigData/mobloc documentation built on Feb. 18, 2024, 3:41 a.m.