Package 'sesp'

Title: Spatially Explicit Stratified Power
Description: Assesses spatial associations between variables through an equivalent geographical detector (q-statistic) within a regression framework and incorporates a spatially explicit stratified power model by integrating spatial dependence and spatial stratified heterogeneity, facilitating the modeling of complex spatial relationships.
Authors: Wenbo Lv [aut, cre, cph] , Yongze Song [aut] , Zehua Zhang [aut] , Shaoqing Dai [aut] , Jianwu Yan [aut] , Wufan Zhao [aut]
Maintainer: Wenbo Lv <[email protected]>
License: GPL-3
Version: 1.0-0
Built: 2024-11-24 07:26:32 UTC
Source: https://github.com/stscl/sesp

Help Index


Spatial fuzzy overlay between variables pairwise

Description

Spatial fuzzy overlay between variables pairwise

Usage

fuzzyoverlay2(formula, data, method = "and")

Arguments

formula

A formula.

data

A data.frame or tibble of discretized data.

method

(optional) Spatial overlay method. One of and, or, intersection. Default is and.

Value

A list

overlay

overlay results between pairs of variables

variable

pairwise interacting variable

Examples

sim = tibble::tibble(y = stats::runif(7,0,10),
                     x1 = c(1,rep(2,3),rep(3,3)),
                     x2 = c(rep(1,2),rep(2,2),rep(3,3)),
                     x3 = c(rep(1,3),rep(2,2),rep(3,2)))
fo1 = fuzzyoverlay2(y ~ .,data = sim, method = 'and')
fo1
fo2 = fuzzyoverlay2(y ~ .,data = sim, method = 'or')
fo2
fo3 = fuzzyoverlay2(y ~ .,data = sim, method = 'intersection')
fo3

Estimate GWR model coefficients

Description

Estimate GWR model coefficients

Usage

gwr_betas(
  formula,
  data,
  bw = "AIC",
  adaptive = TRUE,
  kernel = "gaussian",
  intercept = FALSE
)

Arguments

formula

A formula.

data

An sf object of observation data

bw

(optional) The bandwidth used in selecting models. The optimal bandwidth can be selected using one of two methods: AIC, and CV. Default will use AIC.

adaptive

(optional) Whether the bandwidth value is adaptive or not. Default is TRUE.

kernel

(optional) Kernel function. Default is gaussian.

intercept

(optional) Whether to include the intercept term in the coefficient ⁠tibble. Default is ⁠FALSE'.

Value

A tibble

Examples

depression = system.file('extdata/Depression.csv',package = 'gdverse') |>
  readr::read_csv() |>
  sf::st_as_sf(coords = c('X','Y'), crs = 4326)
gwr_betas(Depression_prevelence ~ ., data = depression)
gwr_betas(Depression_prevelence ~ ., data = depression, intercept = TRUE)

Spatially Explicit Stratified Power (SESP) Model

Description

Spatially Explicit Stratified Power (SESP) Model

Usage

sesp(
  formula,
  data,
  listw = NULL,
  discvar = "all",
  discnum = 3:8,
  model = "ols",
  durbin = FALSE,
  overlay = "and",
  alpha = 0.5,
  intercept = FALSE,
  bw = "AIC",
  adaptive = TRUE,
  kernel = "gaussian",
  increase_rate = 0.05,
  cores = 1,
  ...
)

Arguments

formula

A formula for enhanced stratified power model.

data

An sf object of observation data. Please note that the column names of the independent variables should not be all or none.

listw

(optional) A listw object. See spdep::mat2listw() and spdep::nb2listw() for details.

discvar

(optional) Name of continuous variable columns that need to be discretized. Noted that when formula has discvar, data must have these columns. Default is all, which means all independent variables are used as discvar. When discvar is set to none, all independent variables do not need to be discretized.

discnum

(optional) Number of discretization. Default all will use 3:8.

model

(optional) The type of linear model used, default is ols. The model value must be any of ols, gwr, lag or error.

durbin

(optional) Whether to consider spatial durbin terms, default is false.

overlay

(optional) Spatial overlay method. One of and, or, intersection. Default is and.

alpha

(optional) Controlling the strength of spatial soft constraints, the larger the alpha, the stronger the spatial soft constraint. Default is 0.5.

intercept

(optional) Whether to include the intercept term in the gwr coefficient tibble. Default is FALSE.

bw

(optional) The bandwidth used in selecting models. The optimal bandwidth can be selected using one of two methods: AIC, and CV. Default is AIC.

adaptive

(optional) Whether the bandwidth value is adaptive or not. Default is TRUE.

kernel

(optional) Kernel function. Default is gaussian.

increase_rate

(optional) The critical increase rate of the number of discretization. Default is ⁠5%⁠.

cores

(optional) Positive integer (default is 1). When cores are greater than 1, use multi-core parallel computing.

...

(optional) Other arguments passed to sdsfun::hclustgeo_disc().

Value

A list.

factor

global factor detection result

interaction

global interactive detection results

optdisc

independent variable optimal spatial discretization

allfactor

factor detection results corresponding to different numbers of discreteization

model

regression model used to estimate equivalent q values

Note

Note that when the number of continuous independent variables is small (three or fewer), the built-in spatial explicit discretization in sesp may overestimate the variable q value (when there are fewer input independent variables, GWR tends to overestimate the contribution of each variable). In such cases, it is recommended to discretize these variables beforehand and then input them into sesp for computation.

Examples

NTDs = sf::st_as_sf(gdverse::NTDs, coords = c('X','Y'))
g = sesp(incidence ~ ., data = NTDs, discvar = 'none',
         model = 'ols', overlay = 'intersection', cores = 1)
g