# Error in calculating covariance matrix and fitting variogram model

When constructing variogram model, usually the spatial points are given, and we build a variogram model and conduct parameter estimation. But here in my question the points are not given while parameters for the variogram model is given, the spatial process is defined to be conforming to normal distribution with mean=0, but its sigma matrix is undefined and I have to calculate it using output values of variogram model. I calculated the gamma matrix using code:

``````h.Matrix<-as.matrix(dist(h.Matrix))
gamma.Matrix<-1-1/{exp(3*h.Matrix)}
``````

But I need the value of C(0)(i.e.the value of sill) to caculate C(h) from C(h)=C(0)-γ(h). In this case, I suppose the value of sill is not defined?
And I have an error when fitting the variogram model as follows:

``````sp<-data.frame(x,y,z)
coordinates(sp)<-~x+y
v<-variogram(z~1,sp)
plot(v)
fit.wls <- fit.variogram(v, vgm(c("Lin", "Exp", "Sph", "Gau")))

Error in fit.variogram(object, x, fit.sills = fit.sills, fit.ranges = fit.ranges,  :
fit.method 7 will not work with zero distance semivariances; use another fit.method value
``````

I tried to change the fit.method but another error occured:

``````In fit.variogram(object, x, fit.sills = fit.sills, fit.ranges = fit.ranges,  :
No convergence after 200 iterations: try different initial values?
``````

I cannot figure out what's wrong in the codes and would like to seek for your help...

• While spatial stats is well within the domain of GIS, I would suggest cross-posting this question to stats.stackexchange.com as well. I feel like the R crowd is more active there. – Trevor J. Smith Sep 24 '18 at 1:10