[R-sig-Geo] NA in ST-variogram

Saman Monfared samanmonfared1 at gmail.com
Thu Mar 28 13:03:08 CET 2013


Dear All,
I have some problem in ST modeling using gstat.
 my program is :

library(gstat)
data<-read.table("cancer.txt",header=TRUE)
value<-runif(105)
sp = cbind(data$x,data$y)
row.names(sp) = paste("point", 1:nrow(sp), sep="")
sp = SpatialPoints(sp)
time = as.POSIXct("2003-01-01")+360*(0:6)
time
mydata = data.frame(length(sp)*length(time),value)
IDs = paste("ID",1:length(mydata))
stfdf = STFDF(sp, time, mydata)
vv<-variogramST(value~1,stfdf,tlags = 1:10,cutoff=300000, width =30000/20)
plot(vv,map=T)
library(lattice)
wireframe(gamma~spacelag*timelag+1, vv, drape=F,col.regions=bpy.colors)

Error: NAs are not allowed ........

How can I solve this problem.

I use blow program to fit ST variogram function

ExpVgmMetric = function(x, s, t, nugget = 0) {
 h = sqrt(s^2 + (x[3] * as.numeric(t))^2)
 ifelse(h == 0, 0, nugget + x[1] * (1 - exp(-h / x[2])))
}
ExpFitFn = function(x, gfn, v, trace = FALSE, ...) {
mod = gfn(x, v$spacelag, v$timelag, ...)
resid = v$gamma - mod
if (trace)
print(c(x, MSE = mean(resid^2)))
mean(resid^2)
}
pars.M = optim(c(sill = 5, range = 169, anis = 0), ExpFitFn,
gfn = ExpVgmMetric, v = vv, nugget = 0)
pars.M$par
vv$model = ExpVgmMetric(pars.M$par, vv$spacelag, vv$timelag, nugget = 0)
plot(vv)

but  it's sill is negative and in plot part model only has a single
value and dose not change by changing spatial and temporal lags.

Best,
Saman.

-- 
Saman Monfared
Msc, Department of Statistics, Shiraz University,
Shiraz 71454, Iran
Email: Samanmonfared1 at gmail.com

Tel: +98 917 5305167



More information about the R-sig-Geo mailing list