Learn R Programming

CompRandFld (version 1.0.3-6)

Covariogram: Computes covariance, variogram and extremal coefficient functions

Description

The procedure computes and/or plots the covariance, the variogram or the extremal coefficient functions and the practical range estimated fitting a Gaussian or max-stable random field with the composite-likelihood or using the weighted least square method. Allows to add to the variogram or extremal coefficient plots the empirical estimates.

Usage

Covariogram(fitted, lags=NULL, lagt=NULL, answer.cov=FALSE,
            answer.vario=FALSE, answer.extc=FALSE,
            answer.range=FALSE, fix.lags=NULL, fix.lagt=NULL,
            show.cov=FALSE, show.vario=FALSE, show.extc=FALSE,
            show.range=FALSE, add.cov=FALSE, add.vario=FALSE,
            add.extc=FALSE, pract.range=95, vario, …)

Arguments

fitted

A fitted object obtained from the FitComposite or WLeastSquare procedures.

lags

A numeric vector of distances.

lagt

A numeric vector of temporal separations.

answer.cov

Logical; if TRUE a vector with the estimated covariance function is returned; if FALSE (the default) the covariance is not returned.

answer.vario

Logical; if TRUE a vector with the estimated variogram is returned; if FALSE (the default) the variogram is not returned.

answer.extc

Logical; if TRUE a vector with the estimated extremal coefficient is returned; if FALSE (the default) the variogram is not returned.

answer.range

Logical; if TRUE the estimated pratical range is returned; if FALSE (the default) the pratical range is not returned.

fix.lags

Integer; a positive value denoting the spatial lag to consider for the plot of the temporal profile.

fix.lagt

Integer; a positive value denoting the temporal lag to consider for the plot of the spatial profile.

show.cov

Logical; if TRUE the estimated covariance function is plotted; if FALSE (the default) the covariance function is not plotted.

show.vario

Logical; if TRUE the estimated variogram is plotted; if FALSE (the default) the variogram is not plotted.

show.extc

Logical; if TRUE the estimated extremal coefficient is plotted; if FALSE (the default) the extremal coefficient is not plotted.

show.range

Logical; if TRUE the estimated pratical range is added on the plot; if FALSE (the default) the pratical range is not added.

add.cov

Logical; if TRUE the vector of the estimated covariance function is added on the current plot; if FALSE (the default) the covariance is not added.

add.vario

Logical; if TRUE the vector with the estimated variogram is added on the current plot; if FALSE (the default) the correlation is not added.

add.extc

Logical; if TRUE the vector with the estimated extremal coefficient is added on the current plot; if FALSE (the default) the correlation is not added.

pract.range

Numeric; the percent of the sill to be reached.

vario

A Variogram object obtained from the EVariogram procedure.

other optional parameters which are passed to plot functions.

Value

The returned object is eventually a list with:

covariance

The vector of the estimated covariance function;

variogram

The vector of the estimated variogram function;

extrcoeff

The vector of the estimated extremal coefficient function;

pratical.range

The estimated practial range.

References

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.

Smith, R. L. (1990) Max-Stable Processes and Spatial Extremes. Unpublished manuscript, University of North California.

See Also

FitComposite, WLeastSquare

Examples

Run this code
# NOT RUN {
library(CompRandFld)
library(RandomFields)
library(scatterplot3d)
set.seed(31231)

# Set the coordinates of the points:
x <- runif(100, 0, 10)
y <- runif(100, 0, 10)
coords<-cbind(x,y)

################################################################
###
### Example 1. Plot of covariance and variogram functions
### estimated from a Gaussian random field with exponent 
### correlation. One spatial replication is simulated.
###
###
###############################################################

# Set the model's parameters:
corrmodel <- "exponential"
mean <- 0
sill <- 1
nugget <- 0
scale <- 2

# Simulation of the Gaussian random field:
data <- RFsim(coordx=coords, corrmodel=corrmodel, param=list(mean=mean,
              sill=sill, nugget=nugget, scale=scale))$data

# Maximum composite-likelihood fitting of the Gaussian random field:

start<-list(scale=scale,sill=sill,mean=mean(data))
fixed<-list(nugget=nugget)
# Maximum composite-likelihood fitting of the random field:
fit <- FitComposite(data, coordx=coords, corrmodel=corrmodel,likelihood="Marginal",
                     type="Pairwise",start=start,fixed=fixed,maxdist=6)

# Results:
print(fit)

# Empirical estimation of the variogram:
vario <- EVariogram(data, x, y)

# Plot of covariance and variogram functions:
par(mfrow=c(1,2))
Covariogram(fit, show.cov=TRUE, show.range=TRUE,
            show.vario=TRUE, vario=vario,pch=20)


################################################################
##
### Example 2. Plot of covariance and extremal coefficient
### functions estimated from a max-stable random field with
### exponential correlation. n idd spatial replications are
### simulated.
###
###############################################################

set.seed(1156)
# Simulation of the max-stable random field:
data <- RFsim(coordx=coords, corrmodel=corrmodel, model="ExtGauss", replicates=20,
              param=list(mean=mean,sill=sill,nugget=nugget,scale=scale))$data

start=list(sill=sill,scale=scale)
# Maximum composite-likelihood fitting of the max-stable random field:
fit <- FitComposite(data, coordx=coords, corrmodel=corrmodel, model='ExtGauss',
                    replicates=20, varest=TRUE, vartype='Sampling',
                    margins="Frechet",start=start)

data <- Dist2Dist(data, to='sGumbel')

# Empirical estimation of the madogram:
vario <- EVariogram(data, coordx=coords, type='madogram', replicates=20)

# Plot of correlation and extremal coefficient functions:
par(mfrow=c(1,2))
Covariogram(fit, show.cov=TRUE, show.range=TRUE, show.extc=TRUE,
            vario=vario, pract.range=84,pch=20)


################################################################
###
### Example 3. Plot of covariance and variogram functions
### estimated from a Gaussian spatio-temporal random field with
### double-exp correlation.
### One spatio-temporal replication is simulated.
###
###############################################################

# Define the spatial-coordinates of the points:
#x <- runif(20, 0, 1)
#y <- runif(20, 0, 1)
# Define the temporal sequence:
#time <- seq(0, 30, 1)

# Simulation of the spatio-temporal Gaussian random field:
#data <- RFsim(x, y, time, corrmodel="exp_exp",param=list(mean=mean,
#              nugget=nugget,scale_s=0.5,scale_t=1,sill=sill))$data

# Maximum composite-likelihood fitting of the space-time Gaussian random field:
#fit <- FitComposite(data, x, y, time, corrmodel="exp_exp", maxtime=5,
#                    likelihood="Marginal",type="Pairwise", fixed=list(
#                    nugget=nugget, mean=mean),start=list(scale_s=0.2,
#                    scale_t=1, sill=sill))

# Empirical estimation of spatio-temporal covariance:
#vario <- EVariogram(data, x, y, time, maxtime=10)

# Plot of the fitted space-time covariace
#Covariogram(fit,show.cov=TRUE)

# Plot of the fitted space-time variogram
#Covariogram(fit,vario=vario,show.vario=TRUE)

# Plot of covariance, variogram and spatio and temporal profiles:
#Covariogram(fit,vario=vario,fix.lagt=1,fix.lags=1,show.vario=TRUE,pch=20)

################################################################
###
### Example 4. Plot of parametric and empirical lorelograms
### estimated from a Binary Gaussian random fields with 
### exponential correlation. One spatial replication is
### simulated.
###
###############################################################

#set.seed(1240)

# Define the spatial-coordinates of the points:
#x <- seq(0,3, 0.1)
#y <- seq(0,3, 0.1)

# Simulation of the Binary Gaussian random field:
#data <- RFsim(x, y, corrmodel=corrmodel, model="BinaryGauss",
#              threshold=0,param=list(nugget=nugget,mean=mean,
#              scale=.6,sill=0.8))$data

# Maximum composite-likelihood fitting of the Binary Gaussian random field:
#fit <- FitComposite(data, x, y, corrmodel=corrmodel, model="BinaryGauss",
#                    maxdist=0.8, likelihood="Marginal", type="Pairwise",
#                    start=list(mean=mean,scale=0.1,sill=0.1))

# Empirical estimation of the lorelogram:
#vario <- EVariogram(data, x, y, type="lorelogram", maxdist=2)

# Plot of fitted and empirical lorelograms:
#Covariogram(fit, vario=vario, show.vario=TRUE, lags=seq(0.1,2,0.1),pch=20)
# }

Run the code above in your browser using DataLab