Skip to content
Prev 25716 / 29559 Next

How to fit a pure spatial variogram on a spatio-temporal empirical one

Dear Carlo,

the code below is a bit of a hack, but does what you are asking for. The 
classes "gstatVariogram" and "StVariogram" have slight different design 
and so do the functions fit.variogram and fit.StVariogram. Note that 
spVv is now a pooled variogram across all time steps of your dataset 
treating each time slice as an independent copy of the same pure spatial 
process (i.e. strong temporal autocorrelation might influence your 
estimation).

HTH,

  Ben


library(gstat)
data("vv")
plot(vv)

spaceOnly <- vv$timelag == 0

spVv <- cbind(vv[spaceOnly,],
               data.frame(dir.hor=rep(0, sum(spaceOnly)),
                          dir.ver=rep(0, sum(spaceOnly))))

# drop empty (NA) first row
spVv <- spVv[-1, ]

# manually re-class
class(spVv) <- c("gstatVariogram","data.frame")

plot(spVv)

fitSpVgm <- fit.variogram(spVv, vgm(30, "Exp", 150, 10))
plot(spVv, fitSpVgm)
On 29/05/2017 20:13, Carlo Cavalieri wrote: