为什么变差函数总是在 R 中绘制 15 个点?

Why does variogram always plots 15 points in R?

我想随着样本量的增加绘制可变数量的点。但是,由于某些原因,"variogram" 函数每次只绘制 15 个点。

我检查以确保我传递的数据大小 "variogram" 变化正确 - 是的。

library(gstat)
library(RandomFields)
library(lattice)
library(latticeExtra)
mod <- RMexp(var=1, scale=5) + RMtrend(mean=3)
# theoretical mean 3 

# (x,y) coordinates for simulation grid
x <- seq(0,50,by=0.5)
y <- seq(0,0,by=0.5)
xx <- rep(x, times=length(y))
yy <- rep(y, each=length(x))

zz <- RFsimulate(mod, x=xx, y=yy,spConform=FALSE)

field <- data.frame(x=xx,y=yy,z=zz)


d <- sample(zz,10)
g <- gstat(formula=z~1, locations=~x+y, data=raw.dat)

# N=10:
n10 <- sample(1:length(field[[1]]),10,replace=F)

#g <- gstat(formula=z~1, locations=~x+y, data=raw.dat) 
f10 = field[n10,]
g10 <- gstat(formula=z~1, locations=~x+y, data=f10)


raw.vgm <- variogram(g10) # create method of class "gstatVariogram"
plot(raw.vgm,main='Variogram of Raw Data for N = 10',type='b') # plot method     for class "gstatVariogram"

# N=25:
n25 <- sample(1:length(field[[1]]),25,replace=F)

#g <- gstat(formula=z~1, locations=~x+y, data=raw.dat) 
f25 = field[n25,]
g25 <- gstat(formula=z~1, locations=~x+y, data=f25)

#f25 的长度为 25 - 我检查过#

raw.vgm <- variogram(g25) # create method of class "gstatVariogram"
plot(raw.vgm,main='Variogram of Raw Data for N = 25',type='b') # plot method for class "gstatVariogram"

两个原始变异函数都只绘制了 15 个点。有谁知道为什么?我没有将此视为默认设置。

?variogram 作为参数 width 的默认值 cutoff/15,这导致默认值为 15 点。如果将 width 的值调小,您会看到更多的点。尝试

raw.vgm <- variogram(g25, width = .5)
plot(raw.vgm,main='Variogram of Raw Data for N = 25')

获取更多积分,如果您喜欢冒险,请尝试修改 cutoff。我不推荐 type='b',因为连接样本变差函数点的线所暗示的比实际上更多。