if (FALSE) {
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)
}
Run the code above in your browser using DataLab