Package 'denhotspots'

Title: a package for calculate gi and hi local spatial statistics
Description: the denhotspots package calculate the gi and hi local spatial statistics for areal data.
Authors: Felipe Antonio Dzul Manzanilla
Maintainer: The package maintainer <[email protected]>
License: MIT + file LICENSE
Version: 0.1.0
Built: 2024-09-17 04:26:54 UTC
Source: https://github.com/fdzul/denhotspots

Help Index


bivariate_map

Description

generate a bivariate map

Usage

bivariate_map(w, x, y, dim, pal, style, size_axis, scale_leg, x_leg, y_leg)

Arguments

w

Is the sf object with the variables to map.

x

Is the variable x in the sf object to be mapped.

y

Is the variable x in the sf object to be mapped.

dim

The dimensions of the palette, either 2 for a two-by-two palette or 3 for a three-by-three palette

pal

A palette name; one of "Brown", "DkBlue", "DkCyan", "DkViolet", or "GrPink". As biscale::bi_legend.

style

A string identifying the style used to calculate breaks. Currently supported styles are "quantile", "equal", "fisher", and "jenks"

size_axis

Size of axis labels.

scale_leg

Scales the grob relative to the rectangle defined by x, y, width, height. A setting of scale = 1 indicates no scaling.

x_leg

The x location of the legend in the plot.

y_leg

The y location of the legend in the plot.

Value

a ggplot object.

Author(s)

Felipe Antonio Dzul Manzanilla [email protected]


cases_by_agem

Description

this function left joint sf AGEM and the cases by municipality.

Usage

cases_by_agem(path, disease)

Arguments

path

is the directory where the txt of dengue file exist.

disease

is a string for define the vector borne disease. The option are "Paludismo", "Dengue" & "covid.

Value

a sf object. The municipality with the dengue cases by year.

Examples

1+1

data_geocoden

Description

this function creates an address vector and replaces incorrect text.

Usage

data_geocoden(infile, data, sinave_new)

Arguments

infile

is the name of file create with subset_den.

data

is a string for define the addreses or data. if data TRUE, is return the dataset.

sinave_new

is logical value. If is TRUE the subset ir for 2016-2019 dengue dataset, else the subset ir for 2008-2015 dengue dataset.

Value

a vector.

Author(s)

Felipe Antonio Dzul Manzanilla [email protected]


geocoden

Description

this function geocodes the addresses of the sinave database using Geocoding API.

Usage

geocoden(infile, address)

Arguments

infile

is the name of the location that is being geocoded and is used to be saved in a file with extension rds.

address

is vector addresses.

Details

The function use the geocode of ggmap.

Value

a file with extension rds.

Note

The code for geocoding was taken from the personal page of Shane Lynn https://www.shanelynn.ie/massive-geocoding-with-r-and-google-maps/ and adapted to work with the sinave http://www.sinave.gob.mx/ database.

Author(s)

Felipe Antonio Dzul Manzanilla [email protected]

See Also

geocode


gihi

Description

Calculate gi and hi local spatial statistic

Usage

gihi(x, gi_hi, id, dis, time, alpha = NULL)

Arguments

x

it is an sf object with the number of events for each spatial unit

gi_hi

Define the local spatial statistic. It includes three options ("gi", "hi", "gi_hi", if "gi" calculates the spatial local statistic getis & ord, if it is "hi" calculates hi, and if it is "gi_hi" calculates both statistic

id

is or are the identifiers of each spatial unit

dis

it is the prefix of the variable name. Example den_2018 or denv_2018, dis is den and denv

time

is the unit of time or the time scale of the analyzed time series. example in years, times, months, weeks

alpha

is the value of alpha to determine the threshold of value of gi to discriminate hotspots from non-hotspots

Value

a sf object with the ids and the intensity and hotspots for hi, gi or each.

Author(s)

Felipe Antonio Dzul Manzanilla [email protected]

References

Getis A, Ord JK. 1992. The analysis of spatial association by the use of distance statistics.Geographical Analysis, 24(2):189-206. Ord JK, Getis A. 1995. Local spatial autocorrelation statistics: distributional issues and an application. Geographical Analysis, 27, 286–306. Ord JK, Getis A. 2012. Local spatial heteroscedasticity (LOSH), The Annals of Regional Science, 48 (2), 529–539. Bivand RS, Wong DWS. 2018. Comparing implementations of global and local indicators of spatial association. TEST, 27(3), 716–748.

See Also

LOSH.cs, localG


intensity_plot

Description

this function plot the event hotspots by polygon.

Usage

intensity_plot(
  x,
  pal,
  option = NULL,
  name = NULL,
  pal_name,
  breaks,
  dir_pal = NULL,
  x_leg,
  y_leg
)

Arguments

x

is the hotspots dataset.

pal

is the palette.

option

is the palette option.

name

is the palette name. the option and name are very similar, some package use name (ej. rcartocolor::carto_pal) and other option (ex. viridis:viridis)

pal_name

is a logical value, if pal_name TRUE is for packages that use name, else the packages that use option.

breaks

is a numeric value. Is the increment of the sequence.

dir_pal

is the direction of the palette, 1 forward, -1 reverse.

x_leg

is the x coordinates of legend.

y_leg

is the x coordinates of legend.

Value

a ggplot

Examples

1+1

knox test

Description

This function implement space-time analysis with the knox test

Usage

knox(x, crs, dt, ds, sym, sp_link, planar_coord)

Arguments

x

is the dataset with the coordinates and onset of symptoms

crs

is the coordinate reference system.

dt

is the temporal windows.

ds

is the spatial windows.

sym

is the MonteCarlo replications number.

sp_link

is the logical value. If sp_link is true the space-time link is built with sp, else with sf.

planar_coord

is the logical value.if planar_coord is false, the dataset is projected to a planar system.

Details

This function implements the space-time analysis with the knox test. x is a dataframe with three variables: x (longitude), y (latitude) and onset (onset of symptoms) The coordinates should be projected to a planar system. The function rknox test use the (knox)[https://github.com/thanhleviet/knox] package of (github)[https://github.com/].

Value

a list with three elements: knox, st_link, space-time link. - *knox* is a list with three elements:

knox

Knox statistic, which is the number of pairs of points found in a given space-time distance.

p_value

p-value calculated from MonteCarlo simulation.

RR

Relative Risk - calculated by observed value (Knox statistics) divided by mean of simulated values.

- *st_link* is a origen-destination dataset of class dataframe. This dataset has four variables:

Xo

is the longitude of the point of origin.

Yo

are the latitud of the point of origin.

Xd

are the longitude of the destination point.

Yd

are the latitud of the destination point.

- *space-time link* is a sf object (LINESTRING) with crs 4326.

Author(s)

Felipe Antonio Dzul Manzanilla [email protected]

References

Knox, E. (1964). The detection of space-time interactions. Journal of the Royal Statistical Society. Series C (13(1), 25-30. Tango, T. (2010). Statistical methods for disease clustering. Springer.

See Also

knox_mc, st_link, knox


map_risk

Description

The map_risk function generates the map of the operational scenarios or epidemiological scenarios based on the hotspots of dengue transmission and the hotspots of the abundance of dengue vector eggs.

Usage

map_risk(risk, staticmap)

Arguments

risk

is the spatial risk dataset.

staticmap

is a logical value, if true the map is static else the map is interactive.

Value

a ggplot o mapview object

Note

To generate the map with this function, you must first run the risk_ageb function.

Author(s)

Felipe Antonio Dzul Manzanilla [email protected]

Examples

1+1

point_to_polygon

Description

this function counts how many events for spatial unit

Usage

point_to_polygons(x, y, ids, time, coords, crs, dis)

Arguments

x

is the point pattern data with the coordinate.

y

is the sf areal data.

ids

is the unique o uniques identifiers of each spatial unit.

time

is the temporal resolution of datasets.

coords

is the coordinates of geocoded dataset.

crs

is the coordinate reference system.

dis

is the name of vector-borne diseases.

Value

a sf object.

Author(s)

Felipe Antonio Dzul Manzanilla [email protected]


power_law_plot

Description

this plot generate the all Power Law for hotspots and spatial units.

Usage

power_law_plot(x)

Arguments

x

is the dataset.

Value

a ggplot.

Author(s)

Felipe Antonio Dzul Manzanilla [email protected]

Examples

1+1

Power Laws data.

Description

A dataset containing the Power Laws dataset.

Usage

power_laws

Format

A dataframe object with 606 rows and 3 variables:

y

are the percentiles of the y variable

x

are the percentiles of the x variable

power_law

are the power distributions

...

Source

https://www.tandfonline.com/doi/abs/10.1080/00207390802213609


Read the dengue dataset for geocoding

Description

Read the dengue dataset for geocoding

Usage

read_den_dataset(x, des_edo_res, des_mpo_res)

Arguments

x

is the path of dengue dataset.

des_edo_res

is a string for define the state in uppercase.

des_mpo_res

is a string for define the municipality in uppercase

Value

a data.table

Examples

1+1

read_dengue_dataset

Description

Read the dengue dataset of [SINAVE](https://www.sinave.gob.mx/)

Usage

read_dengue_dataset(
  path,
  spatial_resolution,
  status_caso,
  des_edo_res = NULL,
  des_mpo_res = NULL
)

Arguments

path

is the path of dengue dataset.

spatial_resolution

is the spatial resolution or the administrative level. The values are country, state and municipality.

des_edo_res

is a string for define the state in uppercase.

des_mpo_res

is a string for define the municipality in uppercase.

estatus_caso

1 probable, 2 confirmado, & 3 descartado.

Value

a data.table object.

Author(s)

Felipe Antonio Dzul Manzanilla [email protected]


risk_ageb

Description

risk ageb identifies epidemiological scenarios based on historical epidemiological and entomological information.

Usage

risk_ageb(betas, hotspots, intensity_perc, locality, cve_edo)

Arguments

betas

It is the dataset of the regression coefficients of the geostatistical model with INLA-SPDE. The betas are calculated with the deneggs package.

hotspots

It is the database of the results of the hotspots analysis with the local statistician Getis&Ord. Hotspots are calculated with the denhotspots package.

intensity_perc

It is the percentage of intensity of egg hotspots.

locality

is the locality name.

cve_edo

is the id of state.

Value

a sf object.

Author(s)

Felipe Antonio Dzul Manzanilla [email protected]

See Also

eggs_hotspots, spde_pred_map, eggs_hotspots_week & @seealso inla


risk_h3

Description

risk h3 identifies epidemiological scenarios based on historical epidemiological and entomological information.

Usage

risk_h3(betas, hotspots, intensity_perc, locality, cve_edo)

Arguments

betas

It is the dataset of the regression coefficients of the geostatistical model with INLA-SPDE. The betas are calculated with the deneggs package.

hotspots

It is the database of the results of the hotspots analysis with the local statistician Getis&Ord. Hotspots are calculated with the denhotspots package.

intensity_perc

It is the percentage of intensity of egg hotspots.

locality

is the locality name.

cve_edo

is the id of state.

Value

a sf object.

Author(s)

Felipe Antonio Dzul Manzanilla [email protected]

See Also

eggs_hotspots, spde_pred_map, eggs_hotspots_week & @seealso inla


satscanR

Description

This function performs space-time analysis with SaTScan.

Usage

satscanR(
  cas_file,
  geo_file,
  start_date,
  end_date,
  spatial_window,
  temporal_window,
  ssbatchfilename = "SaTScanBatch",
  path_satscan
)

Arguments

cas_file

is the case file (cas for short).

geo_file

is the geographic or coordinates file (geo for short).

start_date

is the earliest date to be included in the study period. Is calculated with min(x_cas$date).

end_date

is the latest date to be included in the study period. Is calculated with max(x_cas$date).

spatial_window

is the spatial window. The spatial resolution is in km.

temporal_window

is the temporal window. The time resolution is in days.

ssbatchfilename

is the name of the file containing the SaTScan executable.

path_satscan

is the path of directory of SatScan installation.

Details

the stascanR implements ths space-time analysis with [rsatscan](https://cran.r-project.org/web/packages/rsatscan/vignettes/rsatscan.html) package. The rsatscan package only does anything useful if you have installed [SaTScan](https://www.satscan.org/)

Value

a list with eight object (main, col, rr, gis, llr, sci, shapeclust, prm)

Author(s)

Felipe Antonio Dzul Manzanilla [email protected].

See Also

ss.options, satscan


save_geocoden

Description

This function generates the RData file where it contains the geocoded data and the sinave database.

Usage

save_geocoden(x, y, directory, loc)

Arguments

x

is the geocoded data.

y

is the dataset o sinave.

directory

is the folder where the RData file is to be saved

loc

is the name of geocoded name locality

Value

a RData

Author(s)

Felipe Antonio Dzul Manzanilla [email protected]


sf_joint_cov this function apply the dplyr::left_join between sf and covid data of México

Description

sf_joint_cov this function apply the dplyr::left_join between sf and covid data of México

Usage

sf_joint_cov(path_dat, path_sf)

Arguments

path_dat

is the directory of the covid data.

path_sf

is the directory of the municipality shapefile of Mexico.

Details

The function use the left_join of dplyr.

Value

a sf object with a dengue cases accumulated by municipality.

Note

the dataset of SARS-COV2 of Mexico is downloaded homepage of DGE https://www.gob.mx/salud/documentos/datos-abiertos-152127?idiom=es and adapted to work with the sinave http://www.sinave.gob.mx/ database.

Author(s)

Felipe Antonio Dzul Manzanilla [email protected]


Spatial Log Gaussian Cox Process

Description

The spatial_lgcp has the objective of performing the spatial analysis with the log gaussian cox process model in order to predict the intensity of cases in urban and metropolitan endemic dengue locations in Mexico.

Usage

spatial_lgcp(
  dataset,
  locality,
  cve_edo,
  longitude,
  latitude,
  k,
  plot,
  resolution,
  aproximation,
  integration,
  approach,
  cell_size = NULL,
  name
)

Arguments

dataset

is the dengue geocoded dataset.

locality

is the locality target.

cve_edo

is the text id of the state..

longitude

is the name of the column of the longitude in the geocoded dataset.

latitude

is the name of the column of the latitude in the geocoded dataset.

k

is the parameter for define the triagulization of delauney in the inner and the outer area in the argument max.edge in the INLA:inla.mesh.2d.

plot

is a logical value for the plot the mesh.

resolution

is a value for set the resolution of the locality raster. resolution 0.1 = 11.132 km, 0.009 = 1.00 km, 0.005 = 500 m, 0.0027 = 300 m, & 0.001 = 100 m.

aproximation

aproximation is the aproximation of the joint posterior of the marginals and hyperparameter. The options are "adaptative", "gaussian", "simplified.laplace" & "laplace".

integration

integration is the integration strategy. The options are "auto","grid", "eb" & "ccd".

approach

is algorithm for spatial Log Gaussian Cox Process. The option are "lattice", "inlabru" & "simpson" according to Illian 2012, Bachl et al 2018 & Simpson et al 2016,respectively.

cell_size

is the sample number per location (area of locality/n)

name

is the name of the palette.

Value

a list with several object.


staticmap_intensity

Description

This function generate the intensity map of hotspots.

Usage

staticmap_intensity(
  x,
  pal,
  option = NULL,
  name = NULL,
  pal_name,
  breaks,
  dir_pal = NULL,
  x_leg,
  y_leg,
  ageb
)

Arguments

x

is the hotspots dataset.

pal

is the palette.

option

is the palette option.

name

is the palette name. the option and name are very similar, some package use name (ej. rcartocolor::carto_pal) and other option (ex. viridis:viridis)

pal_name

is a logical value, if pal_name TRUE is for packages that use name, else the packages that use option.

breaks

is a numeric value. Is the increment of the sequence.

dir_pal

is the direction of the palette, 1 forward, -1 reverse.

x_leg

is the x coordinates of legend.

y_leg

is the x coordinates of legend.

ageb

is a logical value, if ageb is TRUE plot the intensity map of ageb, else plot the intensity map by other spatial unit.

Value

a ggplot map.

Author(s)

Felipe Antonio Dzul Manzanilla [email protected].

Examples

1+1

staticmap_knoxs

Description

This function generate the space-time link map.

Usage

staticmap_knoxs(
  locality,
  cve_geo,
  path_data,
  path_knoxs,
  pal,
  option = NULL,
  name = NULL,
  pal_name,
  breaks,
  dir_pal = NULL,
  x_leg,
  y_leg
)

Arguments

locality

is the locality target.

cve_geo

is the id of state.

path_data

is the directory of geocoded dengue cases dataset.

path_knoxs

is the output of the space-time analysis (Knoxs method) with ClusterSeer.

pal

is the palette.

option

is the palette option.

name

is the palette name. the option and name are very similar, some package use name (ej. rcartocolor::carto_pal) and other option (ex. viridis:viridis).

pal_name

is a logical value, if pal_name TRUE is for packages that use name, else the packages that use option.

breaks

is a numeric value. Is the increment of the sequence.

dir_pal

is the direction of the palette, 1 forward, -1 reverse.

x_leg

is the x coordinates of legend.

y_leg

is the x coordinates of legend.

Details

The staticmap_knox implement the space-time link map with Knoxs method in [ClusterSeer](https://www.biomedware.com/software/clusterseer/).

Value

a ggplot map.

Author(s)

Felipe Antonio Dzul Manzanilla [email protected].

Examples

1+1

staticmap_satscan

Description

This function generate the map of the output for [SaTScan](https://www.satscan.org/) or [rsatscan](https://cran.r-project.org/web/packages/rsatscan/vignettes/rsatscan.html).

Usage

staticmap_satscan(
  x,
  rsatscan = NULL,
  satscan,
  locality,
  cve_edo,
  path_shapeclust = NULL,
  path_gis = NULL
)

Arguments

x

is the dengue cases of the target locality.

rsatscan

is the output of the space-time analysis with [rsatscan](https://cran.r-project.org/web/packages/rsatscan/vignettes/rsatscan.html) package.

satscan

is a logical value for indicating if TRUE for output of [SaTScan](https://www.satscan.org/).

locality

is the target locality.

cve_edo

is the id of state.

path_shapeclust

is the directory of the output of the space-time analysis with [SaTScan](https://www.satscan.org/). is the col.shp file.

path_gis

is the directory of the output of the space-time analysis with [SaTScan](https://www.satscan.org/).is the gis.shp file.

Value

a ggplot map.

Author(s)

Felipe Antonio Dzul Manzanilla [email protected].


subset_den

Description

is a function for subset de dengue dataset

Usage

subset_den(x = NULL, path = NULL, edo, mun, loc, sinave_new, age_group, name)

Arguments

x

is the 2008-2015 dengue dataset. Is NULL for 2016-2019 dengue dataset.

path

is the path of the 2016-2019 dengue dataset. Is NULL for 2008-2015 dengue dataset.

edo

is a string for define the state in uppercase.

mun

is a string for define the municipality in uppercase.

loc

is a string for define the locality in uppercase.

sinave_new

is logical value. If is TRUE the subset ir for 2016-2019 dengue dataset, else the subset ir for 2008-2015 dengue dataset.

age_group

is a logical value. If is TRUE the subset for age group (<= 12 & >= 65), else all age group.

name

is the name the csv output

Value

a object names x and a csv file in working dircetory.

Author(s)

Felipe Antonio Dzul Manzanilla [email protected]


transmission_chain_map

Description

the function generate the space-time links map with mapview package.

Usage

transmission_chains_map(geocoded_dataset, cve_edo, locality, dengue_cases)

Arguments

geocoded_dataset

is the dengue geocoded dataset.

cve_edo

is the id of state.

locality

is the target locality

dengue_cases

is string for define the positive of suspected dengue cases

Value

a mapview

Author(s)

Felipe Antonio Dzul Manzanilla [email protected]

Examples

1+1