0
votes

I try to plot the variogram in R. When I run the below code:

library(geoR)
Data = as.geodata(Data2, coords.col=1:2, data.col=3)
VG = variog(Data2,estimator.type="classical")
VG.fit =   variofit(VG, ini.cov.pars =c(0.095,1.4), cov.model="gaussian",  fix.nugget=FALSE, nugget=0.065)
plot(VG.fit)

I am getting an error:

Error in xy.coords(x, y, xlabel, ylabel, log) : 'x' is a list, but does not have components 'x' and 'y'

1
Please read the info about how to ask a good question and how to give a reproducible example. This will make it much easier for others to help you. - zx8754

1 Answers

0
votes

In this case, VG is of class variogram while VG.fit is of classes variomodel and variofit. There is a plot method for variogram, but not for variomodel or variofit. After reading some documentation, it seems that you should plot the variogram first:

plot(VG)
lines(VG.fit)

If you only want the fitted line, then add pch = "" to the plot function as an argument.