1

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'

www
  • 38,575
  • 12
  • 48
  • 84
  • Please read the info about [how to ask a good question](http://stackoverflow.com/help/how-to-ask) and how to give a [reproducible example](http://stackoverflow.com/questions/5963269). This will make it much easier for others to help you. – zx8754 Jun 27 '16 at 09:05

1 Answers1

1

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.

slamballais
  • 3,161
  • 3
  • 18
  • 29