# CovarianceFct

0th

Percentile

##### Basic Covariance And Variogram Models

CovarianceFct returns the values of a covariance function; see Covariance for sophisticated models Variogram returns the values of a variogram model

Keywords
spatial
##### Usage
Covariance(x, y=NULL, model, param=NULL, dim=ifelse(is.matrix(x),ncol(x),1),
Distances, fctcall=c("Cov", "Variogram", "CovMatrix"))
CovarianceFct(...)
CovMatrix(...)Variogram(x, model, param, dim=ifelse(is.matrix(x),ncol(x),1))
##### Arguments
x
vector or $(n \times \code{dim})$-matrix. In particular, if the model is isotropic or dim=1 then x is a vector.
y
second vector or matrix in case of non-stationary covariance functions
model
for basic models, model is one of the names given in the Details.
param
The simplest form of param is the vector param=c(mean,variance,nugget,scale,...), in this order; The dots ... stand for additional parameters of the model, e.g. the smoothing parameter in the whittle
 dim dimension of the space in which the model is applied Distances for covariance matrices, the lower triangular part of the distance matrix can be given instead of the values x themselves fctcall internal. This parameter should not be considered by the user ... The function CovarianceFct is identical to the function Covariance. 
 
 Details Here, only the basic, isotropic models are listed; see sophisticated models for nonisotropic and hyper models. See GetModel for commands in R to get information about implemented models and currently used ones. The implemented models are in standard notation for a covariance function (variance 1, nugget 0, scale 1) and for positive real arguments $h$: +see sophisticated'*see sophisticated'$see sophisticated'ave1see sophisticated'ave2see sophisticated'bessel$$C(h)=2^\nu \Gamma(\nu+1)h^{-\nu} J_\nu(h)$$The parameter$\nu$is greater than or equal to$\frac{d-2}2$, where$d$is the dimension of the random field.Brownian motion seefractalBcardinal sine seewavecauchy (normal scale mixture)$$C(h)=\left(1+h^2\right)^{-\beta}$$The parameter$\beta$is positive. The model possesses two generalisations, thegencauchymodel and thehyperbolicmodel. See alsononstatcauchyinCovariance.cauchytbm$$C(h)= (1+(1-\beta/\gamma)h^\alpha)(1+h^\alpha)^(-\beta/\alpha-1)$$The parameter$\alpha$is in (0,2] and$\beta$is positive. The model is valid for dimensions$d\le\gamma$; this has been shown for integer$\gamma$, but the package allows real values of$\gamma$. It allows for simulating random fields where fractal dimension and Hurst coefficient can be chosen independently. It has negative correlations for$\beta>\gamma$and large$h$. This model is equivalent to the modellist("tbm3", n=gamma, list("gencauchy", alpha=alpha, beta=beta))circular$$C(h)= \left(1-\frac 2\pi \left(h \sqrt{1-h^2} + \arcsin(h)\right)\right) 1_{[0,1]}(h)$$This isotropic covariance function is valid only for dimensions less than or equal to 2.cone This model is used only for methods based on marked point processes (seeRFMethods); it is defined only in two dimensions. The corresponding (boolean) function is a truncated cone with socle. The base has radius$\frac12$. The model has three parameters,$r$,$s$, and$h$:$r$gives the radius of the top circle of the cone, given as part of the socle radius;$r \in [0,1)$.$s$gives the height of the socle.$h$gives the height of the truncated cone. coxishamseesophisticated.cutoffseesophisticated.cubic$$C(h)=(1- 7h^2+8.75h^3-3.5h^5+0.75 h^7)1_{[0,1]}(h)$$This model is valid only for dimensions less than or equal to 3. It is a 2 times differentiable covariance functions with compact support. %(See Chiles&Delfiner, 1998)dagum$$C(h) = 1-(1 + h^{-\beta})^{-\gamma/\beta}$$RandomFields allows to vary the parameters$\beta$and$\gamma$within the intervals$(0,1]$and$(0,1)$, respectively.dampedcosine(hole effect model)$$C(h)= e^{-\lambda h} \cos(h), \quad h\ge0$$This model is valid for dimension 1 iff$\lambda \ge 1$, for dimension 2 iff$\lambda \ge 1$, and for dimension 3 iff$\lambda \ge \sqrt{3}$.DeWijsian$$\gamma(h) = \log(\|h\|^\alpha + 1)$$generalised version of the DeWijsian model with$\alpha \in (0,2]$EAxxAand see sophisticated'EtAxxAand see sophisticated'exponential (normal scale mixture)$$C(h)=e^{-h}, \quad h\ge0$$This model is a special case of thewhittlemodel (for$\nu=\frac12$there) and thestableclass (for$\alpha = 1$).FD$$C(k) = \frac{(-1)^k \Gamma(1-a/2)^2}{\Gamma(1-a/2+k) \Gamma(1-a/2-k), \qquad k \in {\bf N}}$$and linearly interpolated otherwise. Here,$\Gamma$is the Gamma function and$a \in [-1, 1)$. The model is defined in 1 dimension only. Remark: the fractionally differenced process stems from time series modelling where the grid locations are multiples of the scale parameter.fractalB(fractal Brownian motion)$$gamma(h) = h^\alpha$$Here,$\alpha \in (0,2]$. (Implemented for up to three dimensions). See alsogenB.fractgauss$$C(h) = 0.5 (|h+1|^{\alpha} - 2|h|^{\alpha} + |h-1|^{\alpha})$$This model is the covariance function for the fractional Gaussian noise with Hurst parameter$H=\alpha /2$,$\alpha \in (0,2]$. In particular, the model is valid only in one dimension.gauss (normal scale mixture)$$C(h)=e^{-h^2}$$This model is a special case of thestableclass (for$\kappa=2$there). Note that the corresponding function for the random coins method (cf. the methods based on marked point processes inRFMethods) is$$e^{- 2 h^2}.$$Seegneitingfor an alternative model that does not have the disadvantages of the Gaussian model.genB(generalised fractal Brownian motion)$$\gamma(h) = (h^{\alpha}+1)^{\delta} -1$$Here,$\alpha \in(0,2]$and$\delta \in (0,1)$. (Implemented for up to three dimensions). See alsofractalB.gencauchy(generalisedcauchy; normal scale mixture) $$C(h)= \left(1+h^\alpha\right)^(-\beta/\alpha)$$The parameter$\alpha$is in (0,2], and$\beta$is positive. This model allows for simulating random fields where fractal dimension and Hurst coefficient can be chosen independently.gengneiting(generalisedgneiting) If$n=1$then$$C(h)=\left(1+(\alpha+1)h\right) * (1-h)^{\alpha+1} 1_{[0,1]}(h)$$If$n=2$then$$C(h)=\left(1+(\alpha+2)h+\left((\alpha+2)^2-1\right)h^2/3\right) (1-h)^{\alpha+2} 1_{[0,1]}(h)$$If$n=3$then$$C(h)=\left(1+(\alpha+3)h+\left(2(\alpha+3)^2-3\right)h^2/5 +\left((\alpha+3)^2-4\right)(\alpha+3)h^3/15\right)(1-h)^{\alpha+3} 1_{[0,1]}(h)$$The parameter$n$is a positive integer; here only the cases$n=1, 2, 3$are implemented. The parameter$\alpha$is greater than or equal to$(d + 2n +1)/2$where$d$is the dimension of the random field. % the differentiability is ??gneiting$$C(h)=\left(1 + 8 sh + 25 (sh)^2 + 32 (sh)^3\right)(1-sh)^8 1_{[0,1]}(sh)$$where$s=0.301187465825$. This isotropic covariance function is valid only for dimensions less than or equal to 3. It is a 6 times differentiable covariance functions with compact support. It is an alternative to thegaussianmodel since its graph is visually hardly distinguishable from the graph of the Gaussian model, but possesses neither the mathematical and nor the numerical disadvantages of the Gaussian model. This model is a special case ofgengneiting(for$n=3$and$\alpha=5$there). Note that, in the original work by Gneiting (1999),$s=\frac{10\sqrt2}{47}\approx 0.3008965$, a numerical value slightly deviating from the optimal one.gneitingdiff is obsolete, see the last example inSophisticatedfor a user's definition ofgneitingdiff.$$C(h)=( 1 + 8 h \alpha^{-1} + 25 h^2\alpha^{-2} + 32 h^3 \alpha^{-3} ) ( 1-h \alpha^{-1} )^8 2^{1-\nu} (\Gamma(\nu))^{-1} h^{\nu} K_{\nu}(h) 1_{[0,\alpha]}(h)$$This isotropic covariance function is valid only for dimensions less than or equal to 3. The parameters$\nu$and$\alpha$are positive. This class of models with compact support allows for smooth parametrisation of the differentiability up to order 6.hyperbolic (normal scale mixture)$$C(h)= \delta^{-\lambda} (K_{\lambda}(\nu \delta))^{-1} ( \delta^2 + h^2 )^{\lambda/2} K_{\lambda}( \nu [ \delta^2 + h^2 ]^{1/2} )$$The parameters are such that$\delta\ge0$,$\nu>0$and$\lambda>0,\quad$or$\delta>0$,$\nu>0$and$\lambda=0,\quad$or$\delta>0$,$\nu\ge0$, and$\lambda<0$. note="" that="" this="" class="" is="" over-parametrised;="" always="" one="" of="" the="" three="" parameters$\nu$,$\delta$,="" and="" scale="" can="" be="" eliminated="" in="" formula.="" therefore,="" these="" parameters="" should="" kept="" fixed="" any="" simulation="" study.="" model="" contains="" as="" special="" cases="" thewhittlemodel and thecauchymodel, for$\delta=0$and$\nu=0$, respectively. See alsononstathyperbolicinCovariance.iacocesare(non-separabel space time model)$$C(h, t)=(1+\|h\|^\nu+|t|^\lambda)^{-\delta}$$The parameters$\nu$and$\lambda$take values in$[1,2]$; the parameters$\delta$must be greater than or equal to half the space-time dimension.J-Bessel seebesselK-Bessel seewhittleandmaternlinear with sill Seepower(a=1there).lgd1(local-global distinguisher)$$C(h)= 1-\frac\beta{\alpha+\beta}|h|^{\alpha}, |h|\le 1 \qquad \hbox{and} \qquad \frac\alpha{\alpha+\beta}|h|^{-\beta}, |h|> 1$$Here$\beta>0$and$\alpha$is in$(0,(3 - d)/2]$for dimension$d=1,2$. The random field has fractal dimension$d + 1 - \alpha/2$and Hurst coefficient$1 -\beta/2$for$\beta \in (0,1]$% \item \code{matern}\cr % equals \eqn{W_\nu(\sqrt{2\nu}x)} where \eqn{W_\nu} is thematern (normal scale mixture) $$C(x)=W_a(x) = 2^{1-\nu} \Gamma(\nu)^{-1} (\sqrt{2 \nu} x)^\nu K_\nu(\sqrt{2 \nu}x)$$The parameter$\nu$is positive. This is the model of choice if the smoothness of a random field is to be parametrised: if$\nu > m$then the graph is$m$times differentiable. In contrast to thewhittlemodel this model separates the effects of the scaling parameter and the shape parameter. For$\nu=0.5$we get the exponential model; for$\nu=\infty$we get$C(x) = \exp(0.5 x^2)$. The model$C(x \sqrt{2})$equals the Handcock-Wallis (1994) parameterisation. The model allows further to replace$nu$by$1/\nu$, setting the second parameterinvnu=TRUE. See alsowhittle, andnonstatwhittleinCovariance.Mand see sophisticated'masteinsee sophisticated'mixedsee sophisticated'nugget$$C(h)=1_{{0}}(h)$$If the model is used inparam-definition mode, eitherparam, thevariance, orparam, thenugget, must be zero. If the model is used in the list-definition mode, the anisotropy matrix must be given in an anisotropic context, but not the scale parameter in an isotropic context. See alsosophisticated.penta$$C(x)= \left(1 - \frac{22}3 x^2 +33 x^4 - \frac{77}2 x^5 + \frac{33}2 x^7 -\frac{11}2 x^9 + \frac 56 x^{11} \right)1_{[0,1]}(x)$$valid only for dimensions less than or equal to 3. This is a 4 times differentiable covariance functions with compact support. %(See Chiles&Delfiner, 1998)power$$C(x)= (1-x)^a 1_{[0,1]}(x)$$This covariance function is valid for dimension$d$if$a \ge (d+1)/2$. For$\kappa=1$we get the well-known triangle (or tent) model, which is valid on the real line, only. % proposition 3.8 in phd thesis tilmann gneiting % Golubov, Zastavnyipowered exponential Seestable.qexponential$$C(x)= ( 2 e^{-x} - \alpha e^{-2x} ) / ( 2 - \alpha )$$The parameter$\alpha$takes values in$[0,1]$. % \item rational quadratic model\cr % See \code{cauchy} for \eqn{\kappa=1}{a=1}. % (Cressie)rationaland see sophisticated'spherical$$C(x)=\left(1- 1.5 x+0.5 x^3\right) 1_{[0,1]}(x)$$%{C(x)= % 1 - 1.5 x + 0.5 x^3 if 0<=x<=1, 0="" otherwise}="" this="" isotropic="" covariance="" function="" is="" valid="" only="" for="" dimensions="" less="" than="" or="" equal="" to="" 3.<="" li="">stable$$C(x)=\exp\left(-x^\alpha\right)$$The parameter$\alpha$is in$(0,2]$. Seeexponentialandgaussianfor special cases.Steinand see sophisticated'steinst1and see sophisticated'symmetric stable Seestable.tbm2and see sophisticated'tbm3and see sophisticated'tent model Seepower.triangle Seepower.wave$$C(x)=\frac{\sin x}x, \quad x>0 \qquad \hbox{and } C(0)=1$$This isotropic covariance function is valid only for dimensions less than or equal to 3. It is a special case of thebesselmodel (for$\kappa$$=0.5).whittle (normal scale mixture)$$C(x)=W_\nu(x) = 2^{1-\nu} \Gamma(\nu)^{-1} x^\nu K_\nu(x)$$The parameter\nuis positive. This is the model of choice if the smoothness of a random field is to be parametrised: if\nu > mthen the graph ismtimes differentiable. The model is a special case of thehyperbolicmodel (for\nu_3=0there). See alsononstWMinsophisticated. Let \code{cov} be a model given in standard notation. Then the covariance model applied with arbitrary variance and scale equals$$\code{variance} * \code{cov}( (\cdot)/ \code{scale}).$$The parameters can be passed by the vector param, param=c(mean, variance, nugget, scale, ...). Here ... stands for additional parameters such as \nu in the whittle model. In case a model has several parameters, as in hyperbolic, the parameters must be given in the sequence they are explained aboved. However, it is strongly recommended to use the list notation explained in sophisticated. The list definition available in RandomFields V 1.x, is depreciated! For a given covariance function cov the variogram \gamma equals$$\gamma(x) = cov(0) - cov(x).$$Note: The value of the covariance function or variogram depends also onRFparameters()PracticalRange. If the latter isTRUEand the covariance model is isotropic then the covariance function is internally rescaled such that cov(1)\approx 0.05for standard parameters (scale=1).Some models allow certain parameter combinations only for certain dimensions. As any model valid inddimensions is also valid in 1 dimension, the default inCovarianceFctandVariogramisdim=1. Value CovarianceFct returns a vector of values of the covariance function. Variogram returns a vector of values of the variogram model. CovMatrix return a covariance matrix. Here a matrix of of coordinates (x) or a vector or a matrix of Distances is expected. CovMatrix allows also for variogram models. Then negative of variogram matrix is returned. References Overviews: Chiles, J.-P. and Delfiner, P. (1999)Geostatistics. Modeling Spatial Uncertainty.New York: Wiley.Gneiting, T. and Schlather, M. (2004) Statistical modeling with covariance functions.In preparation.Schlather, M. (1999)An introduction to positive definite functions and to unconditional simulation of random fields.Technical report ST 99-10, Dept. of Maths and Statistics, Lancaster University.Schlather, M. (2002) Models for stationary max-stable random fields.Extremes5, 33-44.Yaglom, A.M. (1987)Correlation Theory of Stationary and Related Random Functions I, Basic Results.New York: Springer.Wackernagel, H. (2003)Multivariate Geostatistics.Berlin: Springer, 3nd edition. Cauchy models, generalisations and extensions Gneiting, T. and Schlather, M. (2004) Stochastic models which separate fractal dimension and Hurst effect.SIAM review46, 269-282.% see also lgd Dagum model Porcu, E., Zini, A. and Pini, R. (2007) Modelling spatio-temporal data: A new variogram and covariance structure proposalStats. Probab. Lett.,77, 83-89.Berg, C., Mateu, J. and Porcu, E. (2008) The Dagum family of isotropic correlation functionsBernoulli,14, 1134-1149. Generalised fractal Brownian motion Gneiting, T. (2002) Nonseparable, stationary covariance functions for space-time data,JASA97, 590-600. Gneiting's models Gneiting, T. (1999) Correlation functions for atmospheric data analysis.Q. J. Roy. Meteor. Soc., Part A125, 2449-2464. Holeeffect model Zastavnyi, V.P. (1993) Positive definite functions depending on a norm.Russian Acad. Sci. Dokl. Math.46, 112-114. Hyperbolic model Shkarofsky, I.P. (1968) Generalized turbulence space-correlation and wave-number spectrum-function pairs.Can. J. Phys.46, 2133-2153. fractalB Stein, M.L. (2002) Fast and exact simulation of fractional Brownian surfaces.J. Comput. Graph. Statist.11, 587-599. genB Schlather, M. (2010) On some covariance models based on normal scale mixtures.Bernoulli,16, 780-797. lgd Gneiting, T. and Schlather, M. (2004) Stochastic models which separate fractal dimension and Hurst effect.SIAM review% see also cauchy Power model Golubov, B.I. (1981) On Abel-Poisson type and Riesz means,Analysis Mathematica7, 161-184.Zastavnyi, V.P. (2000) On positive definiteness of some functions,J. Multiv. Analys.73, 55-81. See Also sophisticated, EmpiricalVariogram, GetModel, GetPracticalRange, parameter.range, RandomFields, RFparameters, ShowModels. Aliases CovarianceFct Covariance Variogram CovMatrix Examples PrintModelList() x <- 0:100 ## the following five model definitions are the same! ## ## (1) very traditional form (cv <- CovarianceFct(x, model="bessel", param=c(NA,2,1,5,0.5))) plot(x, cv) ## (2) above model in the very general list definition model <- list("+", list("", var=2, scale=5, list("bessel", 0.5)), list("nugget")) cv <- CovarianceFct(x, model=model) points(x, cv, col="red", pch=20) ## no differnce to first ## (3) nested model definition ## this kind of definiton models is depreciated from Version 2.0 on cv <- CovarianceFct(x, model="bessel", param=rbind(c(2, 5, 0.5), c(1, 0, 0))) points(x, cv, col="blue", pch=20, cex=0.5) ## (4) anisotropic notation model <- list("+", list("", var=2, aniso=as.matrix(0.2), list("bessel", nu=0.5) ), list("nugget") ) cv <- CovarianceFct(as.matrix(x), model=model) points(x, cv, col="green", pch=4) ## Depreciated list defintions in Version 1.x ## this way of defining a model still works, but ## is not supported anymore ## (isotropic version) model <- list(list(model="bessel", var=2, kappa=0.5, scale=5), "+", list(model="nugget", var=1, scale=1)) cv <- CovarianceFct(x, model=model) points(x, cv, col="black", pch=5) Documentation reproduced from package RandomFields, version 2.0.71, License: GPL (>= 2) Community examples Looks like there are no examples yet. Post a new example:       R package Rdocumentation.org Created by DataCamp.com   Put your R skills to the test window.MathJax = { tex: { inlineMath: [ ['',''], ['\$$','\$$'] ], displayMath: [ ['$$',''] ], processEscapes: true, packages: ['base', 'ams', 'noerrors', 'noundefined'] }, options: { ignoreHtmlClass: 'tex2jax_ignore', processHtmlClass: 'tex2jax_process' }, loader: { load: ['[tex]/noerrors'] } }; var $jq = jQuery.noConflict(); ;(function(p,l,o,w,i,n,g){if(!p[i]){p.GlobalSnowplowNamespace=p.GlobalSnowplowNamespace||[]; p.GlobalSnowplowNamespace.push(i);p[i]=function(){(p[i].q=p[i].q||[]).push(arguments) };p[i].q=p[i].q||[];n=l.createElement(o);g=l.getElementsByTagName(o);n.async=1; n.src=w;g.parentNode.insertBefore(n,g)}}(window,document,"script","//cdn.datacamp.com/sp/2.10.2.js","snowplow")); var options = { appId: 'rdocumentation', platform: 'web', post: true, discoverRootDomain: true, contexts: { webPage: true, performanceTiming: true } }; options.forceSecureTracker = true; options.postPath = '/spevent'; window.snowplow('newTracker', 'co', "www.datacamp.com", options); window.snowplow('enableActivityTracking', 10, 10); // Ping every 10 seconds after 10 seconds window.snowplow('enableLinkClickTracking'); window.snowplow('trackPageView', null, [ { schema: 'iglu:com.datacamp/user/jsonschema/1-0-0', data: { anonId:$jq.cookie('dc_aid'), } } ]); var config = { forms: { whitelist: ["snowplow_tracked"] }, fields: { blacklist: ['password', 'password_confirmation'] } }; window.snowplow('enableFormTracking', config); (function(i,s,o,g,r,a,m){i['GoogleAnalyticsObject']=r;i[r]=i[r]||function(){ (i[r].q=i[r].q||[]).push(arguments)},i[r].l=1*new Date();a=s.createElement(o), m=s.getElementsByTagName(o);a.async=1;a.src=g;m.parentNode.insertBefore(a,m) })(window,document,'script','https://www.google-analytics.com/analytics.js','ga'); ga('create', 'UA-41577880-1', 'rdocumentation.org'); ga('send', 'pageview'); `