I have generated a 3D unconditional normal scores simulation using gstat
package and would now like to check the variogram reproduction. How do a specify the calculation of the variogram on the grid?
#-- Create the grid
grd<-expand.grid(1:100,1:100,1:50)
names(grd)<-c("x","y","z")
#-- Define the variogram model
MyNug<-0.02
MySill<-0.98
MyRng<-70
MyAnis1<-1.0
MyAnis2<-0.1
vmdl<-vgm(nugget=MyNug,
psill=MySill,
range= MyRng,
model="Sph",
anis=c(90,0,0,MyAnis1,MyAnis2))
#--- Prepare the simulation pars for an unconditional simulation
SimPar<-gstat(formula=p~1,
locations=~x+y+z,
dummy=T,
beta=0,
nmin=8,
nmax=16,
model=vmdl)
#--- Run simulations
MyNsim=1
Sim<- predict(SimPar, newdata=grd, nsim=MyNsim,debug=-1)
summary(Sim)
#--- Prepare the variograms of the the simulation
#--- Convert Sim to a spatial object
SimS<-Sim
coordinates(SimS)<-~x+y+z
SimGrd<-grd
coordinates(SimGrd)<-~x+y+z
VarSim<-variogram(sim1~1,SimS,alpha=0, beta=0,grid=SimGrd)
At this point I get an error as follows
Error in variogram.default(y, locations, X, trend.beta = beta, grid = grid, :
formal argument "grid" matched by multiple actual arguments
Any guidance or and example of variogram calculation using gridded data appreciated (note the simulation takes a while to run as there are 1 million nodes)