riskEst {localEM} | R Documentation |
The riskEst
function computes the estimations of the relative risk with high raster resolution.
riskEst(cases, lemObjects, bw, fact = 1, ncores = 1, iterations = list(tol = 1e-05, maxIter = 1000, gpu = FALSE), path = getwd(), filename = "lemRisk.grd", verbose = FALSE)
cases |
Spatial polygons, data frame or vector of case data |
lemObjects |
List of arrays for the smoothing matrix, and raster stacks for the partition and smoothed offsets |
bw |
Vector of bandwidths specifying which smoothing matrix in |
fact |
Aggregation factor prior to 'final step' smoothing (set to zero to skip final step) |
ncores |
Number of cores/threads for parallel processing |
iterations |
List of convergence tolerance, number of iterations, and use of gpuR package for running local-EM recursions |
path |
Folder for storing rasters |
filename |
Filename (must have .grd extension) of the risk estimation |
verbose |
Verbose output |
After using the riskEst
function, the risk estimations are computed on a fine resolution based on the rasterization of the spatial polygons of population data.
The riskEst
function returns a raster brick of risk estimations for the input bandwidths.
## Not run: # case and population data data('kentuckyCounty') data('kentuckyTract') # parameters ncores = 2 cellsCoarse = 8 cellsFine = 100 bw = c(10, 15, 17.5, 20) * 1000 path = 'example' # rasters of case and population data lemRaster = rasterPartition(polyCoarse = kentuckyCounty, polyFine = kentuckyTract, cellsCoarse = cellsCoarse, cellsFine = cellsFine, bw = bw, ncores = ncores, path = path, idFile = 'lemId.grd', offsetFile = 'lemOffsets.grd', verbose = TRUE) # smoothing matrix lemSmoothMat = smoothingMatrix(rasterObjects = lemRaster, ncores = ncores, path = path, filename = 'lemSmoothMat.grd', verbose = TRUE) # risk estimation lemRisk = riskEst(cases = kentuckyCounty[,c('id','count')], lemObjects = lemSmoothMat, bw = bw, ncores = ncores, path = path, filename = 'lemRisk.grd', verbose = TRUE) # plot risk rCol = mapmisc::colourScale(lemRisk$riskEst, breaks = 5, style = 'quantile', dec = 2) par(mfrow = c(2,2), mar = c(0.5,0.5,3,0.5)) for(inBw in 1:length(bw)) { plot(lemRisk$riskEst[[inBw]], main = paste('Risk, bw=', bw[inBw], 'km', sep = ''), col = rCol$col, breaks = rCol$breaks, axes = FALSE, box = FALSE, legend = FALSE, add = FALSE) } mapmisc::legendBreaks('right', rCol) ## End(Not run)