I would like to plot a variable number of points as my sample size increases. However, for some reason the "variogram" function only plots 15 points every time.
I checked to make sure that the size of the data I'm passing "variogram" was varying correctly - it was.
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 is of length 25 - I checked #
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"
Both raw variograms only plot 15 points. Does anyone know why? I did not see this as a default.
?variogram
gives as a default for argument width
the value cutoff/15
, which causes the default of 15 points. If you make the value for width
smaller, you will see more points. Try
raw.vgm <- variogram(g25, width = .5)
plot(raw.vgm,main='Variogram of Raw Data for N = 25')
for more points, and try modifying cutoff
if you feel adventurous. I would not recommend type='b'
as the line connecting the sample variogram points suggests more than there is, really.