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-11-06 22:25:03 UTC |
Source: | https://github.com/fdzul/denhotspots |
generate a bivariate map
bivariate_map(w, x, y, dim, pal, style, size_axis, scale_leg, x_leg, y_leg)
bivariate_map(w, x, y, dim, pal, style, size_axis, scale_leg, x_leg, y_leg)
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. |
a ggplot object.
Felipe Antonio Dzul Manzanilla [email protected]
this function left joint sf AGEM and the cases by municipality.
cases_by_agem(path, disease)
cases_by_agem(path, disease)
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. |
a sf object. The municipality with the dengue cases by year.
1+1
1+1
this function creates an address vector and replaces incorrect text.
data_geocoden(infile, data, sinave_new)
data_geocoden(infile, data, sinave_new)
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. |
a vector.
Felipe Antonio Dzul Manzanilla [email protected]
this function geocodes the addresses of the sinave database using Geocoding API.
geocoden(infile, address)
geocoden(infile, address)
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. |
The function use the geocode of ggmap.
a file with extension rds.
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.
Felipe Antonio Dzul Manzanilla [email protected]
Calculate gi and hi local spatial statistic
gihi(x, gi_hi, id, dis, time, alpha = NULL)
gihi(x, gi_hi, id, dis, time, alpha = NULL)
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 |
a sf object with the ids and the intensity and hotspots for hi, gi or each.
Felipe Antonio Dzul Manzanilla [email protected]
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.
this function plot the event hotspots by polygon.
intensity_plot( x, pal, option = NULL, name = NULL, pal_name, breaks, dir_pal = NULL, x_leg, y_leg )
intensity_plot( x, pal, option = NULL, name = NULL, pal_name, breaks, dir_pal = NULL, x_leg, y_leg )
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. |
a ggplot
1+1
1+1
This function implement space-time analysis with the knox test
knox(x, crs, dt, ds, sym, sp_link, planar_coord)
knox(x, crs, dt, ds, sym, sp_link, planar_coord)
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. |
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/].
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.
Felipe Antonio Dzul Manzanilla [email protected]
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.
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.
map_risk(risk, staticmap)
map_risk(risk, staticmap)
risk |
is the spatial risk dataset. |
staticmap |
is a logical value, if true the map is static else the map is interactive. |
a ggplot o mapview object
To generate the map with this function, you must first run the risk_ageb function.
Felipe Antonio Dzul Manzanilla [email protected]
1+1
1+1
this function counts how many events for spatial unit
point_to_polygons(x, y, ids, time, coords, crs, dis)
point_to_polygons(x, y, ids, time, coords, crs, dis)
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. |
a sf object.
Felipe Antonio Dzul Manzanilla [email protected]
this plot generate the all Power Law for hotspots and spatial units.
power_law_plot(x)
power_law_plot(x)
x |
is the dataset. |
a ggplot.
Felipe Antonio Dzul Manzanilla [email protected]
1+1
1+1
A dataset containing the Power Laws dataset.
power_laws
power_laws
A dataframe object with 606 rows and 3 variables:
are the percentiles of the y variable
are the percentiles of the x variable
are the power distributions
...
https://www.tandfonline.com/doi/abs/10.1080/00207390802213609
Read the dengue dataset for geocoding
read_den_dataset(x, des_edo_res, des_mpo_res)
read_den_dataset(x, des_edo_res, des_mpo_res)
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 |
a data.table
1+1
1+1
Read the dengue dataset of [SINAVE](https://www.sinave.gob.mx/)
read_dengue_dataset( path, spatial_resolution, status_caso, des_edo_res = NULL, des_mpo_res = NULL )
read_dengue_dataset( path, spatial_resolution, status_caso, des_edo_res = NULL, des_mpo_res = NULL )
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. |
a data.table object.
Felipe Antonio Dzul Manzanilla [email protected]
risk ageb identifies epidemiological scenarios based on historical epidemiological and entomological information.
risk_ageb(betas, hotspots, intensity_perc, locality, cve_edo)
risk_ageb(betas, hotspots, intensity_perc, locality, cve_edo)
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. |
a sf object.
Felipe Antonio Dzul Manzanilla [email protected]
eggs_hotspots, spde_pred_map, eggs_hotspots_week & @seealso inla
risk h3 identifies epidemiological scenarios based on historical epidemiological and entomological information.
risk_h3(betas, hotspots, intensity_perc, locality, cve_edo)
risk_h3(betas, hotspots, intensity_perc, locality, cve_edo)
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. |
a sf object.
Felipe Antonio Dzul Manzanilla [email protected]
eggs_hotspots, spde_pred_map, eggs_hotspots_week & @seealso inla
This function performs space-time analysis with SaTScan.
satscanR( cas_file, geo_file, start_date, end_date, spatial_window, temporal_window, ssbatchfilename = "SaTScanBatch", path_satscan )
satscanR( cas_file, geo_file, start_date, end_date, spatial_window, temporal_window, ssbatchfilename = "SaTScanBatch", path_satscan )
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. |
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/)
a list with eight object (main, col, rr, gis, llr, sci, shapeclust, prm)
Felipe Antonio Dzul Manzanilla [email protected].
This function generates the RData file where it contains the geocoded data and the sinave database.
save_geocoden(x, y, directory, loc)
save_geocoden(x, y, directory, loc)
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 |
a RData
Felipe Antonio Dzul Manzanilla [email protected]
sf_joint_cov this function apply the dplyr::left_join between sf and covid data of México
sf_joint_cov(path_dat, path_sf)
sf_joint_cov(path_dat, path_sf)
path_dat |
is the directory of the covid data. |
path_sf |
is the directory of the municipality shapefile of Mexico. |
The function use the left_join of dplyr.
a sf object with a dengue cases accumulated by municipality.
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.
Felipe Antonio Dzul Manzanilla [email protected]
The purpose of this function is to visualize the transmission chains resulting from the knox test.
space_time_link_map(x, locality, cve_edo, maptype, facetmap = NULL)
space_time_link_map(x, locality, cve_edo, maptype, facetmap = NULL)
x |
is the result of knox test. |
locality |
is the locality target. |
cve_edo |
is the id of state. |
maptype |
is the map type, the values are staticmap & interactive_map. |
facetmap |
is a logical value for facet, if true the map is facet, else is not facet. |
a ggmap
Felipe Antonio Dzul Manzanilla [email protected]
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.
spatial_lgcp( dataset, locality, cve_edo, longitude, latitude, k, plot, resolution, aproximation, integration, approach, cell_size = NULL, name )
spatial_lgcp( dataset, locality, cve_edo, longitude, latitude, k, plot, resolution, aproximation, integration, approach, cell_size = NULL, name )
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. |
a list with several object.
This function generate the intensity map of hotspots.
staticmap_intensity( x, pal, option = NULL, name = NULL, pal_name, breaks, dir_pal = NULL, x_leg, y_leg, ageb )
staticmap_intensity( x, pal, option = NULL, name = NULL, pal_name, breaks, dir_pal = NULL, x_leg, y_leg, ageb )
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. |
a ggplot map.
Felipe Antonio Dzul Manzanilla [email protected].
1+1
1+1
This function generate the space-time link map.
staticmap_knoxs( locality, cve_geo, path_data, path_knoxs, pal, option = NULL, name = NULL, pal_name, breaks, dir_pal = NULL, x_leg, y_leg )
staticmap_knoxs( locality, cve_geo, path_data, path_knoxs, pal, option = NULL, name = NULL, pal_name, breaks, dir_pal = NULL, x_leg, y_leg )
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. |
The staticmap_knox implement the space-time link map with Knoxs method in [ClusterSeer](https://www.biomedware.com/software/clusterseer/).
a ggplot map.
Felipe Antonio Dzul Manzanilla [email protected].
1+1
1+1
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).
staticmap_satscan( x, rsatscan = NULL, satscan, locality, cve_edo, path_shapeclust = NULL, path_gis = NULL )
staticmap_satscan( x, rsatscan = NULL, satscan, locality, cve_edo, path_shapeclust = NULL, path_gis = NULL )
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. |
a ggplot map.
Felipe Antonio Dzul Manzanilla [email protected].
is a function for subset de dengue dataset
subset_den(x = NULL, path = NULL, edo, mun, loc, sinave_new, age_group, name)
subset_den(x = NULL, path = NULL, edo, mun, loc, sinave_new, age_group, name)
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 |
a object names x and a csv file in working dircetory.
Felipe Antonio Dzul Manzanilla [email protected]
the function generate the space-time links map with mapview package.
transmission_chains_map(geocoded_dataset, cve_edo, locality, dengue_cases)
transmission_chains_map(geocoded_dataset, cve_edo, locality, dengue_cases)
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 |
a mapview
Felipe Antonio Dzul Manzanilla [email protected]
1+1
1+1