Skip to contents

embedding spatial cross sectional data

Usage

# S4 method for class 'sf'
embedded(
  data,
  target,
  E = 3,
  tau = 1,
  style = 1,
  stack = FALSE,
  detrend = FALSE,
  nb = NULL
)

# S4 method for class 'SpatRaster'
embedded(
  data,
  target,
  E = 3,
  tau = 1,
  style = 1,
  stack = FALSE,
  detrend = FALSE,
  grid.coord = TRUE,
  embed.direction = 0
)

Arguments

data

observation data.

target

name of target variable.

E

(optional) embedding dimensions.

tau

(optional) step of spatial lags.

style

(optional) embedding style (0 includes current state, 1 excludes it).

stack

(optional) whether to stack embeddings.

detrend

(optional) whether to remove the linear trend.

nb

(optional) neighbours list.

grid.coord

(optional) whether to detrend using cell center coordinates (TRUE) or row/column numbers (FALSE).

embed.direction

(optional) direction selector for embeddings (0 returns all directions, 1-8 correspond to NW, N, NE, W, E, SW, S, SE).

Value

A matrix (when stack is FALSE) or list.

Examples

columbus = sf::read_sf(system.file("case/columbus.gpkg", package="spEDM"))
v = embedded(columbus,"crime")
v[1:5,]
#>          [,1]     [,2]     [,3]
#> [1,] 24.71427 41.55964 43.45135
#> [2,] 26.24684 44.57868 40.73529
#> [3,] 29.41175 43.45135 37.55683
#> [4,] 34.64648 37.95647 38.69064
#> [5,] 40.46533 34.43484 42.28334

cu = terra::rast(system.file("case/cu.tif", package="spEDM"))
r = embedded(cu,"cu")
r[1:5,]
#>          [,1]     [,2]     [,3]
#> [1,] 14.13616 13.86900 13.60871
#> [2,] 14.09866 13.59174 13.77765
#> [3,] 13.57425 13.91658 14.02535
#> [4,] 13.61885 13.81650 14.26563
#> [5,] 13.82547 13.76455 14.03200