rgstat

What are the rules for calculating point pairs using the variogram function of the gstat package?


In R, what are the rules for calculating point pairs using the variogram function of the gstat package? When calculating the semivariogram, 30 points are randomly generated for calculation, and the sum of the point pairs is different each time. Here's the code:

library(gstat)
n <- 40  
X <- runif(n, 0, 100)
Y <- runif(n, 0, 100)
ref_exponential <- exp(runif(n, 0, 1))
data_exponential <- data.frame(X, Y, ref = ref_exponential)
coordinates(data_exponential) <- ~X + Y
variogram_model_exponential <- variogram(ref ~ 1, data_exponential)
print(sum(variogram_model_exponential$np))

I tried to calculate by reading the data given in the txt file. When there are 30 points, there are a total of 435 point pairs, which conforms to the rules of random sampling (30*29/2=435). When 40 points are calculated, there are a total of 528 point pairs (40*39/2=780), which does not comply with the rules of random sampling.

At the same time, I referred to the documentation of gstat variogram, which explains np as the number of point pairs for this estimate. I would like to know its calculation rules.

Thanks in advance!


Solution

  • np is the number of pairs with a distance in the according distance interval; use width and cutoff to manipulate these intervals.