# Variogram fit won't converge

I am having some difficulty fitting a variogram to the data provided at the end of this post. For context, this is baseball data where the x and z coordinates are for the location of the pitch and the response variable is a metric for batter performance. The first picture below shows the manual model where I used a sill of 0.15, a range of 1.5, and a nugget of 0.22. However, the variogram fit did not converge. I tried both exponential and spherical models and different cutoff values, as suggested here to no avail. Also, the variogram seems to indicate that observations that are further apart are more correlated than observations that are close together which doesn't seem sensible to me.

``````library(geoR)
library(sp)
library(gstat)

coordinates(df)=~px+pz
x<-seq(min(df\$px), max(df\$px),length.out = 100)
y<-seq(min(df\$pz), max(df\$pz),length.out = 100)
grd <- expand.grid(x = x, y = y)
coordinates(grd)=~x+y
vgm = variogram(XR~1, df)
plot(vgm,pch=10,col="black",ylab=expression("Semivariogram("*gamma*")"),xlab="Distance",main="Baseball Data")
SILL=0.15# y value where y levels off
RANGE=1.5 # x value where y levels off
NUGGET=0.22 # intercept with y
m <- vgm(SILL-NUGGET, "Exp",RANGE,NUGGET) # define manual model
m
plot(vgm, model=m, pch=19, col="black", main="Manual Model",
ylab=expression("Semivarogram ("*gamma*")"), xlab="Distance")

fm <- fit.variogram(vgm, m)
fm
plot(nickel.vgm, model=fm, pch=19, col="black", main="Fitted Model",
ylab=expression("Semivariogram ("*gamma*")"), xlab="Distance")
``````

Edit: To help visualize this data, I have included a scatter plot. As Leigh suggested, most of the home runs were concentrated in the strike zone which could be causing this phenomenon.

The data is as follows:

``````df <- read.table(textConnection(
'pz px XR
3.05    -0.12   -0.098
1.02    0.81    -0.098
2.61    0.04    0.5
2.16    -0.76   0.5
3.2 0.03    -0.09
1.78    0.49    -0.09
0.48    -0.17   -0.098
1.25    -0.37   0.72
2.04    -0.02   -0.09
2.61    0.58    -0.098
1.73    -0.75   -0.098
2.49    0.21    0.5
2.35    0.11    -0.09
2.07    0.79    0.5
1.86    -0.73   -0.09
0.82    0.23    0.5
1.72    0.28    0.5
2.47    -0.07   -0.09
1.72    -0.42   0.72
3.12    -0.39   -0.09
2.71    -0.08   0.72
2.63    0.39    -0.09
2.28    0.28    -0.09
3.18    0.25    -0.098
2.23    0.22    -0.09
2.4 -0.39   0.5
3.75    -0.25   0.37
2.25    0.52    0.5
1.79    0.14    0.72
2.95    0.61    0.5
2.25    0.58    0.5
1.6 -0.22   0.5
1.66    0.69    -0.09
1.27    -0.54   -0.09
3.22    -0.25   -0.09
3.59    0.92    -0.098
3.59    0.66    0.5
3.4 -0.53   -0.098
3.21    -0.67   -0.098
2.64    0.85    -0.098
2.68    0.36    -0.09
2.51    0.27    -0.09
3.25    -1.17   -0.09
1.24    -0.41   0.37
3.63    -0.05   -0.09
2.8 -0.29   -0.09
2.42    -0.17   1.44
2.73    -0.41   -0.09
2.52    -0.18   -0.09
2.7 0.44    0.72
3.56    -0.98   -0.09
2.41    0.16    -0.09
1.76    0.53    -0.09
1.54    -0.11   -0.098
2.8 0.11    -0.09
3.3 0.63    -0.098
1.64    0.05    -0.09
1.5 0.29    -0.09
0.12    1.03    -0.098
3.37    -0.43   0.72
2.56    0.3 0.37
3.1 -0.72   0.5
1.05    0.64    -0.098
2.27    0.14    0.5
2.16    -0.21   -0.09
1.75    0.25    0.5
2.51    -0.27   0.72
2.42    0.09    0.5
2.57    0.12    -0.098
1.67    0.25    0.72
2.5 -0.52   0.5
2.41    0.29    -0.09
2.05    -0.07   0.5
2.29    -0.15   -0.09
2.56    -0.33   -0.098
1.95    0.55    0.5
1.82    1.09    0.5
0.81    0.57    -0.098
3.43    -0.68   0.5
2.66    0.15    -0.09
2.47    0.75    -0.098
1.5 -0.19   0.72
1.53    -0.51   0.5
1.33    -0.18   -0.37
2.4 -0.5    -0.09
1.08    -0.13   0.5
2.63    -0.4    0.5
3.13    -0.76   0.5
2.83    -0.41   0.5
1.67    -0.12   0.5
2.82    -0.56   0.5
3.62    -0.29   -0.09
2.27    0.86    -0.09
-0.62   -0.29   -0.098
2.04    -0.23   1.44
0.29    0.42    -0.098
2.08    -0.29   -0.09
1.98    -0.78   0.5
3.14    0.72    0.5
2.14    -0.56   -0.098
2.82    -0.75   0.04
1.58    0.44    -0.09
2.84    0.37    -0.09
3.33    -0.31   -0.09
0.9 0.47    -0.098
1.83    -0.2    0.5
3.08    0.18    -0.09
0.7 0.26    -0.09
2.7 -0.76   -0.09
1.88    -0.09   -0.09
2.74    -0.53   -0.09
1.32    0.97    -0.098
3.95    0.55    -0.098
2.03    -0.2    0.5
2.87    -0.77   -0.098
2.46    -0.2    0.5
2.24    0.36    -0.09
2.63    0.04    -0.09
3.12    -0.94   1.44
2.94    0.21    -0.09
2.89    1.11    0.5
2.29    0.15    0.5
2.12    -0.15   0.5
2.17    0.61    -0.09
2.21    0.09    0.5
3.29    -0.73   0.5
2.78    0.34    1.44
3.28    -0.64   -0.09
2.55    0.06    0.5
3.55    -0.19   -0.09
2.59    -0.66   -0.37
3.56    -0.35   -0.098
1.75    -0.33   0.5
0.93    0.09    -0.09
1.92    0.53    -0.09
2.37    0.74    -0.09
2.08    -0.64   -0.09
2.1 -0.35   -0.09
1.91    0.54    0.5
3.13    -0.03   -0.09
1.42    -0.38   0.5
1.11    0.97    -0.098
2.1 0.18    -0.09
3.26    -0.73   -0.09
3.24    -1.04   -0.09
2.98    0.5 0.5
1.59    -0.44   -0.37
2.91    -0.23   1.44
1.82    0.2 -0.098
1.44    -1.59   -0.098
2.46    0.76    0.72
2.78    -0.31   1.44
2.61    1.24    -0.09
2.95    -0.84   0.5
3.73    0.48    -0.09
2.07    -1.01   -0.098
2.17    0.05    -0.09
1.55    -0.51   -0.098
3.07    -0.65   0.5
3.45    -0.14   0.72
1.23    0.44    -0.098
2.01    0.57    -0.09
2.7 -0.36   0.5
2.05    -0.29   1.44
3.03    0.19    0.5
3.04    -0.3    0.72
3.21    -0.48   0.5
2.75    0.72    0.72
3.32    -0.63   -0.09
2.67    -0.14   -0.098
2.47    0.8 -0.09
2.9 0.82    0.5
2.73    0.5 0.5
2.59    1.03    -0.09
1.62    1.43    -0.098
3.32    0.75    0.5
1.96    1.41    -0.098
3.88    -0.76   0.5
2.09    1.89    -0.098
2.39    1.3 -0.098
2.02    -0.36   -0.09
2.38    -0.72   -0.09
2.55    0.19    -0.09
1.67    0.53    -0.09
2.78    0.01    0.5
2.15    0.62    0.5
2.27    0.74    -0.098
1.42    0.28    -0.09
2.94    -1.02   -0.09
1.72    -0.29   -0.09
2.93    -0.42   -0.098
1.59    -0.03   0.72
3.38    0.08    -0.09
2.47    0.44    -0.37
2.69    0.26    0.72
1.9 0.38    0.5
2.82    -0.73   0.5
2.55    0.57    0.5
1.78    1.45    -0.098
1.77    -0.06   -0.098
2.54    -0.05   -0.09
2.24    -0.05   1.44
0.83    0.39    -0.37
2.76    0.28    -0.09
2.37    -0.75   0.5
1.2 0.02    0.5
3.65    -0.13   -0.098
1.94    0.01    0.5
2.22    -0.47   0.5
2.93    0.12    -0.09
3.3 0.44    -0.09
2.09    0.12    -0.09
2.07    -0.37   1.44
1.85    1.01    -0.098
1.52    1.57    -0.098
1.84    -0.21   0.5
1.84    0.7 0.5
2.29    -0.08   1.44
1.46    -0.17   1.04
1.61    0.31    0.5
2.58    0.32    0.5
2.11    0.13    0.5
1.97    -0.52   0.5
2.17    -0.51   1.44
3.55    -0.91   -0.098
2.16    -0.7    1.04
2.27    0.84    0.5
2.29    0.15    1.44
1.23    0.4 -0.098
2.59    -0.23   0.5
3.39    -0.58   -0.098
2.33    0.62    0.5
2.45    -0.53   0.72
1.44    -0.55   0.5
1.37    -0.33   -0.09
3.42    -0.26   -0.098
3.05    -1.08   -0.09
1.91    0.4 -0.09
1.99    -0.44   0.72
1.87    0.02    0.72
3.28    0.24    0.5
2.2 0.95    -0.098
2.17    -1.15   -0.098
2.37    0.31    0.72
1.65    0.38    -0.09
1.82    0.15    0.72
3.18    0.03    -0.098
1.41    0.06    -0.09
0.9 0.38    -0.098
0.81    0.27    0.5
3.84    0.76    -0.098
2.1 -0.81   -0.09
1.92    -0.7    -0.09
3.2 -1.17   0.5
2.1 0.41    0.5
2.9 -0.62   -0.09
2.02    -0.23   -0.37
1.96    -0.55   -0.09
1.92    0.56    -0.09
2.21    -0.05   -0.09
2.71    -0.62   -0.09
2.31    -0.48   -0.098
2.65    -0.05   0.5
1.38    1.66    -0.098
1.24    0.65    -0.09
3.07    -0.58   0.5
2.06    -0.5    0.5
2.46    -0.78   -0.09
2.27    -0.1    0.5
1.59    0.91    -0.09
2.38    1.28    -0.098
2.85    0.6 1.44
2.48    0   -0.09
2.33    0.01    0.72
3.31    0.5 -0.098
3.45    -0.8    -0.098
1.68    0.1 -0.09
2.28    -1  0.5
1.06    0.09    0.5
3.11    0.22    -0.09
3.08    -1.24   -0.09
2.22    -0.08   0.5
2.32    -0.13   0.5
2.46    -0.15   -0.09
2.56    0.56    0.5
2.35    0.03    1.44
1.62    0.03    -0.09
1.97    0.38    0.72
2.39    0   1.44
3.44    -0.39   0.5
2.11    0.42    -0.09
3.72    0.57    -0.09
1.37    0.55    0.5
2   1.74    -0.098
1.93    -0.39   -0.098
2.39    -0.53   0.5
2.2 0.32    -0.09
2.8 -0.12   -0.37
3.47    -0.36   0.5
2.09    -0.19   -0.37
2.23    -0.79   -0.098
1.63    0.29    0.72
2.34    0.29    1.44
2.36    -0.28   0.5
1.94    0.76    1.44
3.07    -0.22   -0.09
2.58    0.04    -0.09
2.8 -0.04   -0.09
3.65    -0.37   -0.09
2.16    -0.35   -0.09
1.88    -0.59   0.5
2.41    -0.34   -0.09
1.99    -0.57   -0.09
2.8 -0.96   -0.09
2.82    -0.64   0.5
2.57    0.17    1.44
2.43    0.4 0.5
1.25    -1.37   -0.098
1.72    0.13    -0.09
2.5 -0.44   0.5
2.59    0.38    0.72
1.81    0.11    0.5
0.86    0.57    -0.098
1.59    -0.09   0.5
2.44    -0.15   -0.09
2.43    -0.4    0.5
1.6 -0.54   -0.09
2.79    -0.05   0.72
2.1 -0.63   -0.098
2.33    -0.45   -0.09
2.52    0.41    0.37
3.04    -0.07   -0.37
1.45    1.22    -0.098
1.7 -0.01   -0.09
2.93    0.15    0.5
2.04    0.54    -0.09
2.28    -0.33   0.5
2.53    0.42    0.5
2.6 -0.25   1.44
1.12    -1.46   -0.098
1.55    -0.06   -0.09
3.08    0.5 0.5
2.63    0.2 -0.09
1.29    -0.08   0.5
2.46    -0.21   -0.09
1.51    -0.23   0.72
2.94    0.29    -0.09
2.18    0.27    0.5
1.84    0.45    1.44
0.91    1.12    -0.098
3.04    0.39    -0.098
2.51    -0.27   -0.098
3.24    0.89    1.44
2.97    0.22    0.5
1.9 -0.76   -0.09
1.29    0.12    0.5
1.58    0.68    -0.37
2.91    0.37    -0.09
3.42    -0.86   -0.09
2.44    0.01    -0.37
2.91    0.5 -0.09
1.44    1.53    -0.098
3.25    0.25    -0.098
2.42    -0.7    0.5
2.31    0.36    0.5
2.12    -0.13   -0.098
1.32    -0.26   -0.09
4.14    0.01    -0.098
2.53    -0.04   1.44
2.69    -0.65   -0.09
1.85    -0.84   0.5
3.11    -0.02   -0.09
2.35    0.4 0.72
1.82    0.59    0.5
1.54    -0.43   0.5
2.9 -0.52   -0.09
2.47    -0.46   0.5
2.4 -0.23   0.5
2.07    -0.32   1.44
2.19    -0.95   0.5
3.05    0.48    -0.09
3.55    -0.79   -0.098
1.82    0.52    -0.098
3.42    0.39    -0.098
3.41    -0.16   1.44
2.8 -0.18   -0.09
1.66    0.07    0.5
1.21    1.18    -0.098
2   0.51    0.5
1.82    -0.19   -0.09
1.85    0.45    -0.09
2.51    0.58    0.5
0.69    0.33    -0.098
2.62    0.23    -0.09
2.48    -1.11   0.5
1.71    -1.18   -0.37
2.4 0.69    -0.09
1.57    -1.26   0.5
2.43    -0.66   -0.098
2.84    -0.74   -0.098
2.36    -0.8    0.5
2.42    -0.36   -0.09
2.08    -0.37   -0.09
2.41    -0.53   -0.098
3.04    -0.19   -0.098
2.45    -0.77   0.5
1.7 -0.01   0.72
4.19    0.08    -0.098
1.37    0.1 -0.098
3.11    -1.14   0.5
1.93    -0.84   -0.09
1.43    -0.26   0.5
3.02    -0.52   0.5
2.59    -1.03   -0.09
1.89    -0.41   0.5
3.08    -0.68   0.5
2.34    0.65    0.5
3.3 -0.86   0.5
1.92    -0.3    -0.09
2.35    -0.8    -0.09
2.2 -0.69   0.72
1.57    -1.08   -0.09
1.65    -0.31   -0.09
2.86    -0.61   0.5
2.89    0.49    -0.09
3.12    -0.36   0.5
2.38    0.15    0.5
3.93    0.36    -0.098
2.16    -0.02   1.44
2.42    -0.17   -0.09
0.12    0.72    -0.098
2.68    -0.17   0.72
3.46    -0.73   -0.098
2.24    -0.48   1.44
2.22    -0.38   0.5
3.28    -0.25   -0.09
1.57    -0.69   -0.09
3.39    -0.68   -0.09
2.25    -0.01   0.5
2.27    -0.9    -0.098
2.01    -0.33   -0.37
2.6 -0.55   0.5
2.53    -0.68   -0.09
2.63    -0.05   0.72
2.36    -0.83   0.5
2.03    -0.5    0.72
3.33    -0.05   -0.09
2.04    0.21    -0.37
2.59    0.28    -0.09
3.38    0.28    -0.098
1.88    0.44    0.5
2.71    0.06    0.5
2.32    -1.12   -0.09
2.36    -0.17   0.5
2.45    -0.48   0.72'), header = TRUE)
``````

I'm not sure I fully understand your data, so this might be off the mark. While it is unusual for a variogram to continue to decrease at successively higher lags, it is not impossible.

Consider for example a situation where most of the highest batting averages are concentrated in one area, for example in or around the centre of the city. Lag distances up to the radius of the city will include these high points in at least some of the pairs. However, lag distances approaching the diameter of the city will only include points located near the city margins. If these tend to be predominantly low values then both the mean and the variance of all points making up the calculation at these highest lags will be lower than those for smaller lags. This could result in the pattern you have observed.

Remember also to look critically at the number of pairs underlying the calculation for each lag spacing. Ideally, each lag should involve greater than 10 pairs and some people say 20. If less, then the estimate for that particular may not be statistically robust. If the points are sparse around the margins of the city then perhaps the greatest lag distances contain insufficient points.

A spatial display showing your data in something like a bubble plot will give you a visual representation of the distribution of high and low data points. This might give you a hint as to what is the cause.

• You're certainly right about most of the positive outcomes being concentrated in one area. I have added a scatter plot to my post. By the way, I chose eXtrapolated Runs (XR) as a metric for batter performance, as it translates the result of each batted ball into a number representing the expected run value of that event. For example 1.44 is for home runs and -0.37 is for grounding into a double play.
– Remy
Commented Nov 23, 2019 at 4:19