# Generate a random adjacency matrix for 5 spatial regions with a probability of 0.2
W <- rAdj(n = 5, p = 0.2)
# Generate a spatial random field from the CAR model using the adjacency matrix
# with parameters variance = 0.1, and rho = 0.5
spatial_random_field <- spatCAR(W = W, sig = 0.1, rho = 0.5)
print(spatial_random_field)
Run the code above in your browser using DataLab