From 30c5bf6b005ded897b0b44d226952d334bdcd1f5 Mon Sep 17 00:00:00 2001 From: Antonio Paez Date: Tue, 17 Dec 2024 18:51:09 +0100 Subject: [PATCH] Checking the build in Linux --- .Rbuildignore | 1 - .github/workflows/pkgdown.yaml | 3 +- .gitignore | 1 + DESCRIPTION | 3 +- R/m.surround.R | 14 +-- man/m.surround.Rd | 14 +-- obsolete/DESCRIPTION | 39 -------- obsolete/_spqdata-package.R | 92 ------------------- spqdep.Rproj | 1 + vignettes/.gitignore | 2 + vignettes/bibliospq.bib | 34 +++++++ .../{spq_userguide.Rmd => user-guide.Rmd} | 41 +++------ 12 files changed, 56 insertions(+), 189 deletions(-) delete mode 100644 obsolete/DESCRIPTION delete mode 100644 obsolete/_spqdata-package.R create mode 100644 vignettes/.gitignore rename vignettes/{spq_userguide.Rmd => user-guide.Rmd} (95%) diff --git a/.Rbuildignore b/.Rbuildignore index 8405697..106773e 100644 --- a/.Rbuildignore +++ b/.Rbuildignore @@ -6,5 +6,4 @@ ^\.github$ ^README\.Rmd$ ^LICENSE\.md$ -^obsolete$ ^data-raw$ diff --git a/.github/workflows/pkgdown.yaml b/.github/workflows/pkgdown.yaml index c9f0165..bfc9f4d 100644 --- a/.github/workflows/pkgdown.yaml +++ b/.github/workflows/pkgdown.yaml @@ -4,12 +4,11 @@ on: push: branches: [main, master] pull_request: - branches: [main, master] release: types: [published] workflow_dispatch: -name: pkgdown +name: pkgdown.yaml permissions: read-all diff --git a/.gitignore b/.gitignore index 234f028..0d7f03b 100644 --- a/.gitignore +++ b/.gitignore @@ -3,3 +3,4 @@ .RData .Ruserdata docs +inst/doc diff --git a/DESCRIPTION b/DESCRIPTION index 2595dee..66258ce 100644 --- a/DESCRIPTION +++ b/DESCRIPTION @@ -39,5 +39,6 @@ Imports: Depends: R (>= 2.10) Suggests: - knitr + knitr, + rmarkdown BugReports: https://github.com/f8l5h9/spqdep/issues diff --git a/R/m.surround.R b/R/m.surround.R index 7fb21ba..a5692c7 100644 --- a/R/m.surround.R +++ b/R/m.surround.R @@ -125,19 +125,7 @@ #' plot(msurr_points, type = 1) #' plot(msurr_points, type = 2) #' -#' # Example 4: Examples with multipolygons -#' fname <- system.file("shape/nc.shp", package="sf") -#' nc <- sf::st_read(fname) -#' plot(sf::st_geometry(nc)) -#' m <- 3 -#' r <- 1 -#' msurr_polygonsf <- m.surround(x = nc, m = m, r = r, -#' distance = "Great Circle", -#' control=list(dtmaxpc = 0.20)) -#' plot(msurr_polygonsf, type = 1) -#' plot(msurr_polygonsf, type = 2) -#' -#' # Example 5: With regular lattice +#' # Example 4: With regular lattice #' sfc = sf::st_sfc(sf::st_polygon(list(rbind(c(0,0), c(1,0), c(1,1), c(0,1), c(0,0))))) #' hexs <- sf::st_make_grid(sfc, cellsize = 0.1, square = FALSE) #' hexs.sf <- sf::st_sf(hexs) diff --git a/man/m.surround.Rd b/man/m.surround.Rd index 7c89a77..3995f94 100644 --- a/man/m.surround.Rd +++ b/man/m.surround.Rd @@ -126,19 +126,7 @@ msurr_points <- m.surround(x = provinces_spain, m = m, r = r, plot(msurr_points, type = 1) plot(msurr_points, type = 2) -# Example 4: Examples with multipolygons -fname <- system.file("shape/nc.shp", package="sf") -nc <- sf::st_read(fname) -plot(sf::st_geometry(nc)) -m <- 3 -r <- 1 -msurr_polygonsf <- m.surround(x = nc, m = m, r = r, - distance = "Great Circle", - control=list(dtmaxpc = 0.20)) -plot(msurr_polygonsf, type = 1) -plot(msurr_polygonsf, type = 2) - -# Example 5: With regular lattice +# Example 4: With regular lattice sfc = sf::st_sfc(sf::st_polygon(list(rbind(c(0,0), c(1,0), c(1,1), c(0,1), c(0,0))))) hexs <- sf::st_make_grid(sfc, cellsize = 0.1, square = FALSE) hexs.sf <- sf::st_sf(hexs) diff --git a/obsolete/DESCRIPTION b/obsolete/DESCRIPTION deleted file mode 100644 index 7e95fdf..0000000 --- a/obsolete/DESCRIPTION +++ /dev/null @@ -1,39 +0,0 @@ -Package: spqdep -Type: Package -Title: Testing for Spatial Independence of Qualitative Data in Cross Section -Version: 0.1.3.4 -Date: 2024-11-17 -Authors@R: - c(person("Fernando", "Lopez", email = "fernando.lopez@upct.es", - role = c("aut", "cre"), comment = c(ORCID = "0000-0002-5397-9748")), - person("Roman", "Minguez", email = "roman.minguez@uclm.es", - role = c("aut"), comment = c(ORCID = "0000-0002-0490-3181")), - person("Antonio", "Paez", email = "paezha@gmail.com", - role = c("aut"), comment = c(ORCID = "0000-0001-6912-9919")), - person("Manuel", "Ruiz", email = "manuel.ruiz@upct.es", - role = c("aut"), comment = c(ORCID = "0000-0001-9228-6410"))) -Maintainer: Fernando Lopez -Description: Testing for Spatial Dependence of Qualitative Data in Cross Section. The list of functions includes join-count tests, Q test, spatial scan test, similarity test and spatial runs test. The methodology of these models can be found in and . -LazyData: true -Encoding: UTF-8 -License: MIT + file LICENSE -Depends: - R (>= 3.5), methods (>= 3.5), stats (>= 3.5) -Imports: - broom (>= 0.7.2), dplyr (>= 1.0.2), - gtools (>= 3.8.2), magrittr (>= 1.5), - Matrix (>= 1.2-18), purrr (>= 0.3.4), rsample (>= 0.0.8), sp (>= 1.4-5), - spatialreg (>= 1.1-8), spdep (>= 1.1-3), sf (>= 0.9-3), tidyr (>= 1.1.2) -Suggests: - knitr, - rmarkdown, - bookdown, - ggplot2, - gridExtra, - igraph, - gt -VignetteBuilder: knitr -RoxygenNote: 7.3.2 -Language: en-US -URL: https://f8l5h9.github.io/spqdep/ -Config/testthat/edition: 3 diff --git a/obsolete/_spqdata-package.R b/obsolete/_spqdata-package.R deleted file mode 100644 index 05e4dfc..0000000 --- a/obsolete/_spqdata-package.R +++ /dev/null @@ -1,92 +0,0 @@ -#' @docType package -#' @name spqdep-package -#' @rdname spqdep-package -#' -#' @title Testing for Spatial Dependence of Qualitative Data in Cross Section. -#' -#' @description -#' \pkg{spqdep} offers the user a collection of functions to testing for spatial independence of categorical cross-section datasets. -#' -#' @details -#' Some functionalities that have been included in \pkg{spqdep} package are: -#' -#' @section 1. Test Q: -#' Testing for spatial dependence with the Q test based on the symbolic entropy. See references -#' @section 2. Test QMap: -#' Two statistics for the spatial analysis of qualitative data are obtained -#' that are based on the symbolic entropy of the maps. See references -#' @section 3. Spatial runs test: -#' Testing for spatial dependence with the global test based on runs. See references -#' @section 4. Local spatial runs test: -#' Obtain the local test based on runs. See references -#' @section 5. Scan test: -#' Testing for spatial dependence with the Scan test. See references -#' @section 6. Join-count tests: -#' Testing for spatial dependence with the classical Join-count test. See references -#' @section 7. Similarity test: -#' Testing for spatial dependence with the Similarity test. See references -#' -#' @section Datasets: (example provinces_spain, FastFood.sf) -#' \pkg{spqdep} includes two different datasets: provinces_spain and FastFood.sf. These -#' sets are used to illustrate the capabilities of different functions. -#' Briefly, their main characteristics are the following \cr -#' \itemize{ -#' \item The \emph{FastFood.sf} A sf object with points of the localization of Fastfood restaurants in Toronto. -#' \item The \emph{provinces_spain} An object of the class sf with the geometry of spanish provinces and several data sets. -#' } -#' -#' @references -#' \itemize{ -#' \item Ruiz M, López FA and A Páez (2011). -#' Comparison of Thematic Maps Using Symbolic Entropy. -#' \emph{International Journal of Geographical Information Science}, 26, 413-439. -#' \item Ruiz, M., López, F., and Páez, A. (2010). -#' Testing for spatial association of qualitative data using symbolic dynamics. -#' \emph{Journal of Geographical Systems}, 12(3), 281-309.0. -#' \item Kulldorff M, Nagarwalla N. (1995). -#' Spatial disease clusters: Detection and Inference. -#' \emph{Statistics in Medicine}. 14:799-810 -#' \item Jung I, Kulldorff M, Richard OJ (2010). -#' A spatial scan statistic for multinomial data. -#' \emph{Statistics in Medicine}. 29(18), 1910-1918 -#' \item Páez, A, López-Hernández, FA, Ortega-García, JA, & Ruiz, M. (2016). -#' Clustering and co-occurrence of cancer types: A comparison of techniques with an application to pediatric cancer in Murcia, Spain. -#' \emph{Spatial Analysis in Health Geography}, 69-90. -#' } -#' -#' @author -#' \tabular{ll}{ -#' Fernando López \tab \email{fernando.lopez@@upct.es} \cr -#' Román Mínguez \tab \email{roman.minguez@@uclm.es} \cr -#' Antonio Páez \tab \email{paezha@@gmail.com} \cr -#' Manuel Ruiz \tab \email{manuel.ruiz@@upct.es} \cr -#' } -#' -#' @importFrom dplyr group_by rename select -#' @importFrom gtools combinations permutations -#' @importFrom ggplot2 ggplot geom_bar geom_errorbar -#' @importFrom ggplot2 geom_point geom_sf -#' @importFrom ggplot2 scale_fill_manual labs xlab -#' @importFrom ggplot2 aes element_text element_blank -#' @importFrom ggplot2 theme theme_bw -#' @importFrom graphics pairs par symbols title -#' @importFrom gridExtra grid.arrange -#' @importFrom igraph graph.adjacency layout.norm -#' @importFrom magrittr %>% -#' @importFrom Matrix solve -#' @importFrom methods as -#' @importFrom rsample bootstraps analysis -#' @importFrom sf st_coordinates st_distance -#' @importFrom sf st_geometry st_as_sf st_centroid -#' @importFrom sf st_read -#' @importFrom sp SpatialPoints -#' @importFrom spatialreg get.ZeroPolicyOption -#' @importFrom spdep knearneigh knn2nb poly2nb -#' @importFrom spdep mat2listw nb2listw nb2mat -#' @importFrom spdep listw2mat -#' @importFrom spdep joincount.multi joincount.test -#' @importFrom spdep joincount.mc -#' @importFrom stats quantile pnorm rnorm qnorm pchisq -#' @importFrom stats get_all_vars na.action model.frame -#' @importFrom stats addmargins sd var -NULL diff --git a/spqdep.Rproj b/spqdep.Rproj index bb130b5..b6cd50f 100644 --- a/spqdep.Rproj +++ b/spqdep.Rproj @@ -1,4 +1,5 @@ Version: 1.0 +ProjectId: 56260ffc-b211-4479-a592-08103c3b5e3d RestoreWorkspace: Default SaveWorkspace: Default diff --git a/vignettes/.gitignore b/vignettes/.gitignore new file mode 100644 index 0000000..097b241 --- /dev/null +++ b/vignettes/.gitignore @@ -0,0 +1,2 @@ +*.html +*.R diff --git a/vignettes/bibliospq.bib b/vignettes/bibliospq.bib index 9cd0f59..6a2f626 100644 --- a/vignettes/bibliospq.bib +++ b/vignettes/bibliospq.bib @@ -119,3 +119,37 @@ @book{Kanaroglou2016 } @Comment{jabref-meta: databaseType:bibtex;} + + + +@article{farber_testing_2015, + title = {Testing for {Spatial} {Independence} {Using} {Similarity} {Relations}}, + volume = {47}, + issn = {0016-7363}, + doi = {10.1111/gean.12044}, + abstract = {In this article, we construct new, simple, and nonparametric tests for spatial independence using symbolic analysis. An important aspect is that the tests are free of a priori assumptions about the functional form of dependence, making them especially suitable in situations where the dependence is nonlinear. We define the concept of a similarity relation, which is used to keep track of similarity between neighboring observations. This similarity count is used to construct new statistical tests based on both random permutation simulations and derived asymptotic distributions. We include a Monte Carlo study to better illustrate the properties and the behavior of the new tests under several synthetically generated processes. Apart from being competitive compared with other nonparametric and parametric tests, results underline the outstanding power of the new tests for nonlinear-dependent spatial processes.}, + language = {English}, + number = {2}, + journal = {Geographical Analysis}, + author = {Farber, S. and Marin, M. R. and Paez, A.}, + month = apr, + year = {2015}, + keywords = {Geography, dependency tests, estimation bias, network autoregressive models, topology}, + pages = {97--120}, + file = {PDF:/home/antonio-paez/antonio-rogue/Zotero/storage/SRDR385M/Farber et al. - 2015 - Testing for Spatial Independence Using Similarity Relations.pdf:application/pdf}, +} + + +@article{paezSpatioTemporalAnalysisEnvironmental2021, + title = {A {Spatio}-{Temporal} {Analysis} of the {Environmental} {Correlates} of {COVID}-19 {Incidence} in {Spain}}, + volume = {53}, + issn = {0016-7363}, + doi = {10.1111/gean.12241}, + abstract = {The novel SARS-CoV2 has disrupted health systems and the economy, and public health interventions to slow its spread have been costly. How and when to ease restrictions to movement hinges in part on whether SARS-CoV2 will display seasonality due to variations in temperature, humidity, and hours of sunshine. Here, we address this question by means of a spatio-temporal analysis in Spain of the incidence of COVID-19, the disease caused by the virus. Use of spatial Seemingly Unrelated Regressions (SUR) allows us to model the incidence of reported cases of the disease per 100,000 population as an interregional contagion process, in addition to a function of temperature, humidity, and sunshine. In the analysis we also control for GDP per capita, percentage of older adults in the population, population density, and presence of mass transit systems. The results support the hypothesis that incidence of the disease is lower at higher temperatures and higher levels of humidity. Sunshine, in contrast, displays a positive association with incidence of the disease. Our control variables also yield interesting insights. Higher incidence is associated with higher GDP per capita and presence of mass transit systems in the province; in contrast, population density and percentage of older adults display negative associations with incidence of COVID-19.}, + number = {3}, + journal = {Geographical Analysis}, + author = {Paez, Antonio and Lopez, Fernando A. and Menezes, Tatiane and Cavalcanti, Renata and Pitta, Maira Galdino da Rocha}, + year = {2021}, + pages = {397--421}, + file = {gean.12241:/home/antonio-paez/antonio-rogue/Zotero/storage/827756QB/gean.12241.pdf:application/pdf}, +} diff --git a/vignettes/spq_userguide.Rmd b/vignettes/user-guide.Rmd similarity index 95% rename from vignettes/spq_userguide.Rmd rename to vignettes/user-guide.Rmd index 2547d1e..9ef6318 100644 --- a/vignettes/spq_userguide.Rmd +++ b/vignettes/user-guide.Rmd @@ -1,37 +1,26 @@ --- -title: "spqdep user guide" -subtitle: "The user guide


" +title: "User Guide" author: - Fernando A. López, Technical University of Cartagena (Spain) - Román Mínguez, University of Castilla-La Mancha (Spain) - Antonio Páez, McMaster University (Canada) - Manuel Ruiz, Technical University of Cartagena (Spain)


date: "`r Sys.Date()`
" -output: - bookdown::html_document2: - number_sections: yes - toc: yes - toc_depth: 2 - toc_float: - collapsed: no - smooth_scroll: no - toc_title: Article Outline - self_contained: TRUE - linkcolor: red link-citations: yes bibliography: ["bibliospq.bib"] -vignette: | - %\VignetteIndexEntry{spq_userguide} +output: rmarkdown::html_vignette +vignette: > + %\VignetteIndexEntry{user-guide} + %\VignetteEngine{knitr::rmarkdown} %\VignetteEncoding{UTF-8} - %\VignetteEngine{knitr::rmarkdown} -editor_options: - chunk_output_type: inline --- - +```{r, include = FALSE} +knitr::opts_chunk$set( + collapse = TRUE, + comment = "#>" +) +``` ```{r setup, include=FALSE} knitr::opts_chunk$set(echo = TRUE) @@ -54,7 +43,7 @@ Global and local statistics give information about the spatial structure of the Three data sets will be used as examples in this guide: -- **provinces_spain**: The division of Spain into provinces. It is a multypolygon geometry with isolated provinces (Canary and Balearic islands without neighbouring provinces). See by example Paez et al. 2021. +- **provinces_spain**: The division of Spain into provinces. It is a multypolygon geometry with isolated provinces (Canary and Balearic islands without neighbouring provinces). See for example @paezSpatioTemporalAnalysisEnvironmental2021. - **FastFood.sf**: A simple feature (sf) dataframe containing the locations of a selection of fast food restaurants in the city of Toronto, Canada (data are from 2008). The data set used as example in @ruiz2010. It is a geometry of points. @@ -503,7 +492,7 @@ data(FastFood.sf) # Similarity test -The Farber et al. (2014) paper develop the similarity test +@farber_testing_2015 develop the similarity test. The \code{similarity.test()} function calculates the similarity test for both asymptotic distribution and permutational resampling. @@ -537,7 +526,3 @@ summary(jc1) ``` # References - -Farber, S., Marin, M. R., & Páez, A. (2015). Testing for spatial independence using similarity relations. Geographical Analysis, 47(2), 97-120. - -Paez, A., Lopez, F. A., Menezes, T., Cavalcanti, R., & Pitta, M. G. D. R. (2021). A spatio‐temporal analysis of the environmental correlates of COVID‐19 incidence in Spain. Geographical analysis, 53(3), 397-421.