Modeling spatial correlation

Semivariogram specification

Semivariogram models are specified using the GSTAT notation. For example a Spherical semivariogram model with a range of 1 and a sill of 0.1 is specified as

V = '0.1 Sph(1)'

Nested semivariogram models are specified as for example:

V= '0.1 Nug(0) + 0.1 Sph(1)'

2D anisotropy is specified as the angle of the primary direction clockwise from North, rotation, and the fraction of range of the range in the secondary direction (perpendicular to tha primary direction) to the range of the primary direction, anisotropy_factor:

V = 'sill Sph(range,rotation,anisotropy_factor)'

To specify an angle of 30 degrees from north and a fraction of 0.3 :

V = '0.1 Sph(1,30,.3)'

See more details in the GSTAT manual.

Internally in Matlab the string describing the semivariogram model is translated into a Matlab structure. There is significant computational improvements by doing this conversion, and it allows an easier way to set semivariogram parameters from Matlab. Converting a semivariogram from string format a Matlab structure can be done using “deformat_variogram”:

V = deformat_variogram('0.1 Sph(1,30,.3)')
V =
     par1: 0.1000
     par2: [1 30 0.3000]
     type: 'Sph'
    itype: 1

The semivariogram in form of the Matlab structure is also much easier to manipulate.

To convert a semivariogram in form of a Matlab structure back into a readable string using “format_variogram”:

format_variogram(V,1)
ans =
0.1 Sph(1,30,0.3)

Synthetic semivariogram

A synthetic semivariogram can be calculated using semivar_synth, “semivar_synth”:

V='0.1 Nug(0) + 1 Gau(1.5)';
[sv,d]=semivar_synth(,[0:.1:6]);
plot(d,sv)

Note that there are different conventions for the definition of som semivariogram models. GSLIB and S-GeMS use on convention, while for example GSTAT use another. Default mGstat make use of the definitions used in mGstat. To change this see “SEMIVAR_DEF”.

Experimental semivariogram

There are two ways to calculate the experimental semivariogram. A native matlab function and a wrapper to GSTAT. The native matlab function allows use of multidimensional data, while the GSTAT wrapper only allows up to 3D data observations. The native Matlab function allows computation of several angle ranges at once while the GSLIB wrapper must be called separately for each angle array. However, the GSLIB wrapper is much faster.

Native Matlab

“semivar_exp” is a native Matlab function to compute directional dependent experimental semivariograms from multi dimensional data observations. An example assuming an isotropic semivariogram model:

[gamma,h]=semivar_exp(pos,val);
plot(h,gamma);

The semivariogram in a number of angle ranges can be simultaneously calculated using:

% Example directional [0,45,90,135,180]: 
[gamma,h,angle_center]=semivar_exp(pos,val,20,4);
plot(h,gamma);
legend(num2str(angle_center))

This computes the semivariogram in for angle arrays, from 0-45, 45-90, 90-135, 135-380. 'angle_center' is the the center of each angle gather : 22.5, 67.5, 112.5, 157.6 degrees.

The angle range can manually be specified using:

% Example directional [0,45,90,135,180]: 
ang=[0 45 90 135 180];
[gamma,h,angle_center]=semivar_exp(pos,val,20,4);
plot(h,gamma);
legend(num2str(angle_center))

The semivariogram for angles between for example 13 and 22 degrees, can be computed using :

% Example directional 13-22 deg
[gamma,h,angle_center]=semivar_exp(pos,val,20,[13 22]);
plot(h,gamma);
legend(num2str(angle_center))

GSTAT

“semivar_exp_gstat” is a wrapper for GSTAT for computing the directional dependent experimental semivariogram for one angle range. Is supports up to three dimensional data observations. The angle range is specified as the angle and a tolerance. Thus the semivariogram in within the angle range 20 +-10 degrees is found using :

[gamma,h]=semivar_exp_gstat(pos,val,20,10)