library(GeoModels)
################################################################
###
### Example 1. Empirical estimation of the semi-variogram from a
### spatial Gaussian random field with exponential correlation.
###
###############################################################
set.seed(514)
# Set the coordinates of the sites:
x = runif(200, 0, 1)
y = runif(200, 0, 1)
coords = cbind(x,y)
# Set the model's parameters:
corrmodel = "Matern"
mean = 0
sill = 1
nugget = 0
scale = 0.3/3
smooth=0.5
# Simulation of the spatial Gaussian random field:
data = GeoSim(coordx=coords, corrmodel=corrmodel, param=list(mean=mean,
smooth=smooth,sill=sill, nugget=nugget, scale=scale))$data
# Empirical spatial semi-variogram estimation:
vario = GeoVariogram(coordx=coords,data=data,maxdist=0.6)
plot(vario,pch=20,ylim=c(0,1),ylab="Semivariogram",xlab="Distance")
################################################################
###
### Example 2. Empirical estimation of the variogram from a
### spatio-temporal Gaussian random fields with Gneiting
### correlation function.
###
###############################################################
set.seed(331)
# Define the temporal sequence:
# Set the coordinates of the sites:
x = runif(200, 0, 1)
y = runif(200, 0, 1)
coords = cbind(x,y)
times = seq(1,10,1)
# Simulation of a spatio-temporal Gaussian random field:
data = GeoSim(coordx=coords, coordt=times, corrmodel="gneiting",
param=list(mean=0,scale_s=0.08,scale_t=0.4,sill=1,
nugget=0,power_s=1,power_t=1,sep=0.5))$data
# Empirical spatio-temporal semi-variogram estimation:
vario_st = GeoVariogram(data=data, coordx=coords, coordt=times, maxtime=7,maxdist=0.5)
plot(vario_st,pch=20)
################################################################
###
### Example 3. Empirical estimation of the (cross) semivariograms
### from a bivariate Gaussian random fields with Matern
### correlation function.
###
###############################################################
# Simulation of a bivariate spatial Gaussian random field:
set.seed(293)
# Define the spatial-coordinates of the points:
x = runif(400, 0, 1)
y = runif(400, 0, 1)
coords=cbind(x,y)
# Simulation of a bivariate Gaussian Random field
# with matern (cross) covariance function
param=list(mean_1=0,mean_2=0,scale_1=0.1/3,scale_2=0.15/3,scale_12=0.15/3,
sill_1=1,sill_2=1,nugget_1=0,nugget_2=0,
smooth_1=0.5,smooth_12=0.5,smooth_2=0.5,pcol=0.3)
data = GeoSim(coordx=coords, corrmodel="Bi_matern", param=param)$data
# Empirical semi-(cross)variogram estimation:
biv_vario=GeoVariogram(data,coordx=coords, bivariate=TRUE,maxdist=0.5)
plot(biv_vario,pch=20)
Run the code above in your browser using DataLab