Learn R Programming

NeuralEstimators (version 0.1.3)

spatialgraph: spatialgraph

Description

Constructs a graph object for use in graph neural networks.

Usage

spatialgraph(S, Z, isotropic = TRUE, stationary = TRUE, ...)

Value

A GNNGraph (a JuliaProxy object) ready for use in a graph neural network.

Arguments

S

Spatial locations, provided as:

  • An n x d matrix when locations are fixed across replicates, where n is the number of spatial locations and d is the spatial dimension (typically d=2).

  • A list of n_i x d matrices when locations vary across replicates, where each matrix corresponds to the spatial locations of a single replicate.

Z

Spatial data, provided as:

  • An n x m matrix when locations are fixed, where m is the number of replicates.

  • A list of n_i vectors when locations vary across replicates, where each vector corresponds to the data for a single replicate.

isotropic

Logical. If TRUE, edge features store the spatial distance (magnitude) between nodes. If FALSE, the spatial displacement or spatial location is stored, depending on the value of stationary.

stationary

Logical. If TRUE, edge features store the spatial displacement (vector difference) between nodes, capturing both magnitude and direction. If FALSE, edge features include the full spatial locations of both nodes.

...

Additional keyword arguments from the Julia function adjacencymatrix() determine the neighborhood of each node, with the default being a randomly selected set of k=30 neighbors within a radius of r=0.15 units.

See Also

spatialgraphlist() for the vectorised version of this function.

Examples

Run this code
if (FALSE) {
library("NeuralEstimators")

# Number of replicates and spatial dimension
m <- 5
d <- 2

# Spatial locations fixed for all replicates
n <- 100
S <- matrix(runif(n * d), n, d)
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 * d), ni, d))
Z <- lapply(n, function(ni) runif(ni))
g <- spatialgraph(S, Z)
}

Run the code above in your browser using DataLab