Skip to contents

geographical convergent cross mapping

Usage

# S4 method for class 'sf'
gccm(
  data,
  cause,
  effect,
  libsizes,
  E = 3,
  tau = 1,
  k = E + 2,
  theta = 1,
  algorithm = "simplex",
  lib = NULL,
  pred = NULL,
  nb = NULL,
  threads = detectThreads(),
  parallel.level = "low",
  bidirectional = TRUE,
  trend.rm = TRUE,
  progressbar = TRUE
)

# S4 method for class 'SpatRaster'
gccm(
  data,
  cause,
  effect,
  libsizes,
  E = 3,
  tau = 1,
  k = E + 2,
  theta = 1,
  algorithm = "simplex",
  lib = NULL,
  pred = NULL,
  threads = detectThreads(),
  parallel.level = "low",
  bidirectional = TRUE,
  trend.rm = TRUE,
  progressbar = TRUE
)

Arguments

data

The observation data.

cause

Name of causal variable.

effect

Name of effect variable.

libsizes

A vector of library sizes to use.

E

(optional) Dimensions of the embedding.

tau

(optional) Step of spatial lags.

k

(optional) Number of nearest neighbors to use for prediction.

theta

(optional) Weighting parameter for distances, useful when algorithm is smap.

algorithm

(optional) Algorithm used for prediction.

lib

(optional) Libraries indices.

pred

(optional) Predictions indices.

nb

(optional) The neighbours list.

threads

(optional) Number of threads.

parallel.level

(optional) Level of parallelism, low or high.

bidirectional

(optional) whether to identify bidirectional causal associations.

trend.rm

(optional) Whether to remove the linear trend.

progressbar

(optional) whether to print the progress bar.

Value

A list

xmap

cross mapping prediction results

varname

names of causal and effect variable

bidirectional

whether to identify bidirectional causal associations

References

Gao, B., Yang, J., Chen, Z. et al. Causal inference from cross-sectional earth system data with geographical convergent cross mapping. Nat Commun 14, 5875 (2023).

Examples

columbus = sf::read_sf(system.file("case/columbus.gpkg", package="spEDM"))
# \donttest{
g = gccm(columbus,"hoval","crime",libsizes = seq(5,45,5),E = 6)
#> 
Computing: [========================================] 100% (done)                         
#> 
Computing: [========================================] 100% (done)                         
g
#>   libsizes hoval->crime crime->hoval
#> 1        5    0.1301861    0.2642894
#> 2       10    0.1762769    0.3961522
#> 3       15    0.2197481    0.4672470
#> 4       20    0.2324435    0.5144297
#> 5       25    0.2354728    0.5713321
#> 6       30    0.2360934    0.6048914
#> 7       35    0.2412944    0.6253026
#> 8       40    0.2383788    0.6364897
#> 9       45    0.2339483    0.6484721
plot(g, ylimits = c(0,0.85))

# }