Description Usage Arguments Details Value Author(s) References See Also Examples
View source: R/EmpiricalEstimators.r
The function returns an empirical estimate of the variogram (or its variants) for Gaussian, Binary and max-stable random field.
1 2 3 |
data |
A d-dimensional vector (a single spatial realisation) or a (n x d)-matrix
(n iid spatial realisations) or a (d x d)-matrix (a single spatial realisation on regular grid)
or an (d x d x n)-array (n iid spatial realisations on regular grid) or a
(t x d)-matrix (a single spatial-temporal realisation) or an (t x d x n)-array
(n iid spatial-temporal realisations) or or an (d x d x t)-array
(a single spatial-temporal realisation on regular grid) or an (d x d x t x n)-array
(n iid spatial-temporal realisations on regular grid). See |
coordx |
A numeric (d x 2)-matrix (where
|
coordy |
A numeric vector assigning 1-dimension of
spatial coordinates; |
coordt |
A numeric vector assigning 1-dimension of
temporal coordinates. Optional argument, the default is |
cloud |
Logical; if |
distance |
String; the name of the spatial distance. The default
is |
grid |
Logical; if |
gev |
A numeric vector with the three GEV parameters; |
maxdist |
A numeric value denoting the spatial maximum distance, see the Section Details. |
maxtime |
A numeric value denoting the temporal maximum distance, see the Section Details. |
numbins |
A numeric value denoting the numbers of bins, see the Section Details. |
replicates |
Numeric; a positive integer denoting the number of independent and identically distributed (iid) replications of a spatial or spatial-temporal random field. Optional argument, the default value is 1 then a single realisation is considered. |
type |
A String denoting the type of variogram. Four options
are available: |
We briefly report the definitions of variogram used in this function.
In the case of a spatial Gaussian random field
the sample variogram
estimator is defined by
\hat{γ}(h) = 0.5 ∑_{x_i, x_j \in N(h)} (Z(x_i) - Z(x_j))^2 / |N(h)|
where N(h) is the set of all the sample pairs whose distances fall into a tolerance region with size h (equispaced intervalls are considered). Observe, that in the literature often the above definition is termed semivariogram (see e.g. the first reference). Nevertheless, here this defition has been used in order to be consistent with the variogram defition used for the extremes (see e.g. the third reference).
In the case of a spatial max-stable random field, the sample madogram
estimator is defined similarly to the Gaussian case by
\hat{ν}(h) = 0.5 ∑_{x_i, x_j \in N(h)} |Z(x_i) - Z(x_j)| / |N(h)|.
In the case of a spatial binary random field, the sample lorelogram
estimator (the analogue of the correlation) is defined by
\hat{L}(h) = (N_{11}(h) N_{00}(h) )/ (N_{01}(h) N_{10}(h)).
where N_{11}(h) is the number of pairs who are both equal to 1 and that falls in the bin h. Similarly are defined the other quantities.
In the case of a spatio-temporal Gaussian random field the sample
variogram
estimator is defined by
\hat{γ}(h, u) = 0.5 ∑_{(x_i, l), (x_j, k) \in N(h, u)} (Z(x_i, l) - Z(x_j, k))^2 / |N(h, u)|
where N(h, u) is the set of all the sample pairs whose spatial distances fall into a tolerance region with size h and \|k-l\|=u. Note, that Z(x_i,l) is the observation at site x_i and time l. Taking this in mind and given the above definition of lorelogram, the spatio-temporal extention is straightforward.
The numbins
parameter indicates the number of adjacent
intervals to consider in order to grouped distances with which to
compute the (weighted) lest squares.
The maxdist
parameter indicates the maximum spatial distance below which
the shorter distances will be considered in the calculation of
the (weigthed) least squares.
The maxtime
parameter indicates the maximum temporal distance below which
the shorter distances will be considered in the calculation of
the (weigthed) least squares.
Returns an object of class Variogram
.
An object of class Variogram
is a list containing
at most the following components:
bins |
Adjacent intervals of grouped spatial distances if
|
bint |
Adjacent intervals of grouped temporal distances if
|
cloud |
If the variogram cloud is returned ( |
centers |
The centers of the spatial bins; |
distance |
The type of spatial distance; |
extcoeff |
The spatial extremal coefficient function. Available only if
|
lenbins |
The number of pairs in each spatial bin; |
lenbinst |
The number of pairs in each spatial-temporal bin; |
lenbint |
The number of pairs in each temporal bin; |
srange |
The maximum and minimum spatial distances used for the calculation of the variogram; |
variograms |
The empirical spatial variogram; |
variogramst |
The empirical spatial-temporal variogram; |
variogramt |
The empirical temporal variogram; |
trange |
The maximum and minimum temporal distance used for the calculation of the variogram; |
type |
The type of estimated variogram: the standard variogram or the madogram. |
Simone Padoan, simone.padoan@unibocconi.it, http://faculty.unibocconi.it/simonepadoan; Moreno Bevilacqua, moreno.bevilacqua@uv.cl, https://sites.google.com/a/uv.cl/moreno-bevilacqua/home.
Padoan, S. A. and Bevilacqua, M. (2015). Analysis of Random Fields Using CompRandFld. Journal of Statistical Software, 63(9), 1–27.
Cooley, D., Naveau, P. and Poncet, P. (2006) Variograms for spatial max-stable random fields. Dependence in Probability and Statistics, p. 373–390.
Cressie, N. A. C. (1993) Statistics for Spatial Data. New York: Wiley.
Gaetan, C. and Guyon, X. (2010) Spatial Statistics and Modelling. Spring Verlang, New York.
Heagerty, P. J., and Zeger, S. L. (1998). Lorelogram: A Regression Approach to Exploring Dependence in Longitudinal Categorical Responses. Journal of the American Statistical Association, 93(441), 150–162
Smith, R. L. (1990) Max-Stable Processes and Spatial Extremes. Unpublished manuscript, University of North California.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 | library(CompRandFld)
library(RandomFields)
set.seed(514)
# Set the coordinates of the sites:
x <- runif(150, 0, 10)
y <- runif(150, 0, 10)
################################################################
###
### Example 1. Empirical estimation of the variogram from a
### Gaussian random field with exponential correlation.
### One spatial replication is simulated.
###
###
###############################################################
# Set the model's parameters:
corrmodel <- "exponential"
mean <- 0
sill <- 1
nugget <- 0
scale <- 3
# Simulation of the spatial Gaussian random field:
data <- RFsim(x, y, corrmodel=corrmodel, param=list(mean=mean,
sill=sill, nugget=nugget, scale=scale))$data
# Empirical spatial variogram estimation:
fit <- EVariogram(data, x, y)
# Results:
plot(fit$centers, fit$variograms, xlab='h', ylab=expression(gamma(h)),
ylim=c(0, max(fit$variograms)), xlim=c(0, fit$srange[2]), pch=20,
main="variogram")
################################################################
###
### Example 2. Empirical estimation of the variogram from a
### spatio-temporal Gaussian random fields with Gneiting
### correlation function.
### One spatio-temporal replication is simulated
###
###############################################################
set.seed(331)
# Define the temporal sequence:
times <- seq(1,7,1)
# Simulation of a spatio-temporal Gaussian random field:
data <- RFsim(x, y, times, corrmodel="gneiting",
param=list(mean=0,scale_s=0.4,scale_t=1,sill=sill,
nugget=0,power_s=1,power_t=1,sep=0.5))$data
# Empirical spatio-temporal variogram estimation:
fit <- EVariogram(data, x, y, times, maxtime=5,maxdist=4)
# Results: Marginal spatial empirical variogram
par(mfrow=c(2,2), mai=c(.5,.5,.3,.3), mgp=c(1.4,.5, 0))
plot(fit$centers, fit$variograms, xlab='h', ylab=expression(gamma(h)),
ylim=c(0, max(fit$variograms)), xlim=c(0, max(fit$centers)),
pch=20,main="Marginal spatial Variogram",cex.axis=.8)
# Results: Marginal temporal empirical variogram
plot(fit$bint, fit$variogramt, xlab='t', ylab=expression(gamma(t)),
ylim=c(0, max(fit$variograms)),xlim=c(0,max(fit$bint)),
pch=20,main="Marginal temporal Variogram",cex.axis=.8)
# Building space-time variogram
st.vario <- matrix(fit$variogramst,length(fit$centers),length(fit$bint))
st.vario <- cbind(c(0,fit$variograms), rbind(fit$variogramt,st.vario))
# Results: 3d Spatio-temporal variogram
require(scatterplot3d)
st.grid <- expand.grid(c(0,fit$centers),c(0,fit$bint))
scatterplot3d(st.grid[,1], st.grid[,2], c(st.vario),
highlight.3d=TRUE, xlab="h",ylab="t",
zlab=expression(gamma(h,t)), pch=20,
main="Space-time variogram",cex.axis=.7,
mar=c(2,2,2,2), mgp=c(0,0,0),
cex.lab=.7)
# A smoothed version
par(mai=c(.2,.2,.2,.2),mgp=c(1,.3, 0))
persp(c(0,fit$centers), c(0,fit$bint), st.vario,
xlab="h", ylab="u", zlab=expression(gamma(h,u)),
ltheta=90, shade=0.75, ticktype="detailed", phi=30,
theta=30,main="Space-time variogram",cex.axis=.8,
cex.lab=.8)
################################################################
###
### Example 3. Empirical estimation of the madogram from a
### max-stable random field (Extremal Gaussian model) with
### exponential correlation.
### n iid spatial replications are simulated.
###
###############################################################
set.seed(7273)
# Simulation of the max-stable random field:
data <- RFsim(x, y, corrmodel=corrmodel, model="ExtGauss",
param=list(mean=mean, sill=sill, nugget=nugget,
scale=scale), replicates=40)$data
# Tranform data from from common unit Frechet to standard Gumbel margins:
data <- Dist2Dist(data, to='sGumbel')
# Empirical madogram estimation:
fit <- EVariogram(data, x, y, type='madogram', replicates=40, cloud=FALSE)
# Results:
par(mfrow=c(1,2), mai=c(.6,.6,.3,.3), mgp=c(1.6,.6, 0))
plot(fit$centers, fit$variograms, xlab='h', ylab=expression(nu(h)),
ylim=c(0, max(fit$variograms)), xlim=c(0, fit$srange[2]), pch=20,
main="madogram")
plot(fit$centers, fit$extcoeff, xlab='h', ylab=expression(theta(h)),
ylim=c(1, 2), xlim=c(0, fit$srange[2]), pch=20,
main="extremal coefficient")
|
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.