spatialgraph {NeuralEstimators} | R Documentation |
spatialgraph
Description
Constructs a graph object for use in a graph neural network (GNN).
Usage
spatialgraph(S, Z, isotropic = TRUE, stationary = TRUE, ...)
Arguments
S |
Spatial locations, provided as:
|
Z |
Spatial data, provided as:
|
isotropic |
Logical. If |
stationary |
Logical. If |
... |
Additional keyword arguments from the Julia function |
Value
A GNNGraph
(JuliaProxy
object) or, if multiple data sets are provided, a vector of GNNGraph
objects which can be indexed in the usual manner using [[
or converted to an R list using a combination of indexing and lapply
.
Examples
## Not run:
library("NeuralEstimators")
# Number of replicates
m <- 5
# Spatial locations fixed for all replicates
n <- 100
S <- matrix(runif(n * 2), n, 2)
Z <- matrix(runif(n * m), n, m)
g <- spatialgraph(S, Z)
# Spatial locations varying between replicates
n <- sample(50:100, m, replace = TRUE)
S <- lapply(n, function(ni) matrix(runif(ni * 2), ni, 2))
Z <- lapply(n, function(ni) runif(ni))
g <- spatialgraph(S, Z)
# Multiple data sets: Spatial locations fixed for all replicates within a given data set
K <- 15 # number of data sets
n <- sample(50:100, K, replace = TRUE) # number of spatial locations can vary between data sets
S <- lapply(1:K, function(k) matrix(runif(n[k] * 2), n[k], 2))
Z <- lapply(1:K, function(k) matrix(runif(n[k] * m), n[k], m))
g <- spatialgraph(S, Z)
# Multiple data sets: Spatial locations varying between replicates within a given data set
S <- lapply(1:K, function(k) {
lapply(1:m, function(i) {
ni <- sample(50:100, 1) # randomly generate the number of locations for each replicate
matrix(runif(ni * 2), ni, 2) # generate the spatial locations
})
})
Z <- lapply(1:K, function(k) {
lapply(1:m, function(i) {
n <- nrow(S[[k]][[i]])
runif(n)
})
})
g <- spatialgraph(S, Z)
## End(Not run)