Statistics Glossary → Variogram + Kriging (Spatial Interpolation)
Variogram + Kriging (Spatial Interpolation)analysis
A spatial interpolation method that models how similarity between measurement points declines with distance using a variogram, and uses this model to estimate values, and the uncertainty of those estimates, at unmeasured locations.
Concept
Continuous variables such as soil, water or air quality can be measured only at a limited number of points, yet the result is usually wanted as a map covering the whole area. Simple interpolation methods give more weight to nearby points, but they set these weights by an arbitrary rule and say nothing about how reliable the estimate is. Kriging derives the weights from the data's own spatial structure and also gives a standard error for every estimate.
The first step is the empirical variogram: half the average squared difference in value between pairs of points at a given distance, γ(h). If nearby points resemble each other, γ is low at short distances and rises with distance. A theoretical model (spherical, exponential, Gaussian, Matérn) is fitted to these points and its three parameters are read: the nugget (measurement error and very small-scale variability at very short distances), the sill (the ceiling the variability reaches) and the range (the distance at which this ceiling is reached, beyond which points no longer resemble one another). With this model, kriging computes the unbiased weights that minimise the variance of the prediction error; ordinary kriging assumes an unknown constant mean, simple kriging a known mean, and universal kriging a trend depending on the coordinates or a covariate.
The method assumes that the spatial structure is the same throughout the area (stationarity) and usually that it does not depend on direction; a clear trend or directional variation (anisotropy) should be modelled separately. Prediction quality depends on how well the variogram model fits; leave-one-out cross-validation tests both the prediction error (RMSE) and the accuracy of the model's own uncertainty estimate (the mean squared standardised error should be close to 1). Standard errors grow at the edges, where samples are sparse.
When to use it
- To produce a prediction map and an uncertainty map for the whole area of a continuous variable measured at a limited number of points (soil nutrients, pollutants, rainfall, groundwater level).
- If the variable has a clear trend or a covariate that explains it, use universal kriging; if a quick surface with simple distance-decay weights is enough, use inverse distance weighting (IDW).
- If the density of event points rather than a measured value is wanted, use KDE; if the spatial clustering of values is only to be tested, Moran's I is preferred.
An everyday example
A farmer wants to spread fertiliser on a 50-hectare field according to need rather than evenly, and has soil samples taken at 120 points across the field to measure nitrogen. The variogram shows that samples closer than about 300 metres have similar nitrogen levels, while those further apart no longer resemble each other (a range of about 300 m). Using this structure, kriging produces a nitrogen estimate and its standard error for every 10-metre square of the field. The farmer sets the fertiliser spreader by the prediction map and takes a few extra samples from the corner where the standard error is large.
Parameters in MerQur
Classify by / Method / Palette
Concept: Classify colours the points by a categorical column before the analysis; Method chooses the analysis to run on the map tab; Palette sets only the colour scale. None of these changes the kriging result.
Everyday example: Colouring the samples as 'clay' or 'sandy' soil reveals in advance whether nitrogen seems linked to soil type. Changing the palette changes only how the nitrogen map looks, not the estimates.
What it does: Classify by colours the points by category (data exploration); Method selects the map method; Palette (Viridis, Plasma, Jet, RdYlBu) determines only the colour scale.
Effect on the result: Does not change the numeric output (expected no effect for the palette).
Coordinate type (Geographic (latitude / longitude, degrees), Projected (X / Y)), X (easting), Y (northing), Coordinate unit (m, km)
Concept: Sets the coordinate system in which distances are computed. With geographic coordinates (degrees) distances are computed after transforming to a plane; with projected coordinates (such as UTM, in metres or km) they are computed directly as straight-line distances. The range, cutoff and block size are read in that unit.
Everyday example: If the field samples were recorded by GPS as latitude and longitude, geographic is chosen. If the map is in a national projection in metres, projected and 'm' are chosen; the range is then read as '300', in metres.
What it does: With projected coordinates (UTM, national grid) it uses the planar Euclidean distance directly; cutoff, block and range are given in the coordinate unit. X, Y and unit are active only when Projected is selected.
Effect on the result: With the geographic choice, latitude-longitude is carried onto the local equirectangular plane; with the projected choice the distances are the original ones.
On the validation data: meuse RD metres: spherical 0.0506604 / 0.5906058 / 897.006 m. With real WGS84 latitude-longitude the spherical range is 0.8991 km.
→ Distance measure (Euclidean, Manhattan, Gower, great-circle)
Kriging type (Ordinary kriging (OK), Simple kriging (SK, known mean), Universal kriging (UK, trend))
Concept: The kriging type sets the assumption about the mean. Ordinary kriging assumes the mean is constant but unknown, simple kriging that it is known, and universal kriging that it varies with the coordinates or with an auxiliary variable (covariate).
Everyday example: If nitrogen fluctuates around a similar mean everywhere in the field, ordinary kriging is enough. If nitrogen rises steadily from the sloping north of the field to its flat south, this tendency is modelled with universal kriging.
What it does: OK estimates the unknown constant mean; SK uses the given mean (if empty, the sample mean 5.8858); UK uses a coordinate trend or covariate, and the variogram is computed from the trend residuals.
Effect on the result: Determines the prediction and prediction variance.
On the validation data: LOO RMSE: OK (spherical) 0.3918; SK mean empty 0.3924; UK linear exponential 0.3898; UK quadratic 0.4301; UK sqrt(dist) exponential 0.3777.
Variogram model (Automatic (smallest SSE), Spherical, Exponential, Gaussian, Matérn, Linear) and Matérn κ (smoothness)
Concept: The variogram model is the curve describing how similarity declines with distance. The spherical model reaches the sill exactly at a set range; the exponential model approaches the sill gradually; the Gaussian model assumes very smooth change at short distances; in the Matérn model κ tunes this smoothness. The automatic option compares the models and picks the best-fitting one.
Everyday example: If nitrogen beyond 300 metres is no longer related at all to neighbouring samples, the spherical model fits. If the relationship fades steadily with distance but never quite disappears, the exponential model fits better.
What it does: In automatic, the spherical, exponential, Gaussian and Matérn are fitted separately and the one with the smallest weighted SSE is chosen (automap criterion). κ is active only in Matérn and automatic (κ = 0.5 equals exponential).
Effect on the result: Determines the nugget, partial sill and range, hence all predictions.
On the validation data: Spherical is selected in automatic (SSE 9.011; exponential and Matérn(0.5) 16.283, Gaussian 17.616). Spherical: nugget 0.05066, partial sill 0.59061, range 0.89701 km.
Grid resolution (default 100) and Prediction area (Convex hull (mask), Bounding rectangle)
Concept: The grid resolution sets the number of cells, and hence the cell size, of the prediction map; a finer grid looks more detailed but produces no more information than the sampling density allows. The prediction area sets whether the map is drawn only within the region enclosed by the samples (convex hull) or over the whole bounding rectangle; outside the hull, prediction is extrapolation far from the data.
Everyday example: For the field, 10-metre cells match the working width of the fertiliser spreader; 1-metre cells look smoother but add no new information. If predictions are made in a corner of the field with no samples, the standard error grows markedly.
What it does: The number of cells along the long side (cell size = extent / value). The mask predicts only inside the convex hull of the observation points (no extrapolation) or uses the rectangle.
Effect on the result: Changes the resolution and extent of the surface; does not change cell values.
On the validation data: Cell 0.195 km for 20, 0.039 km for 100, 0.0097 km for 400; prediction range 4.78-7.48. In the rectangle the largest standard error is 0.825 (0.785 in the hull).
Leave-one-out cross-validation (LOO) (check box)
Concept: Leave-one-out cross-validation removes each measurement point from the data in turn, predicts it from the remaining points and compares the prediction with the actual value. RMSE shows the size of the prediction error, the mean error the bias, and MSDR how well the model's standard errors match the actual errors (it should be close to 1).
Everyday example: Each of the 120 samples is 'hidden' once and predicted from the other 119. If RMSE is low and MSDR is close to 1, the farmer can trust both the estimates and the uncertainty zones on the map.
What it does: Gives ME, MAE, RMSE, MSDR (mean standardised squared error) and the observed-predicted correlation by leave-one-out cross-validation.
Effect on the result: If turned off only the table row is removed, the prediction does not change.
On the validation data: With the spherical model RMSE 0.39180, MSDR 0.8185, r 0.8393.
Number of distance classes (lags) (default 15) and Cutoff (maximum distance)
Concept: The empirical variogram is computed by grouping pairs of points into classes by distance. The number of classes sets the width of each class, and the cutoff the largest distance considered; with very narrow classes the number of pairs falls and the variogram becomes noisy.
Everyday example: With a cutoff of 600 metres and 15 classes, each class covers a 40-metre distance band. Had the cutoff been shorter than the range (300 m), the sill where the variogram levels off would never appear and the range could not be estimated reliably.
What it does: Determines the number of classes and the maximum distance of the empirical variogram (class width = cutoff / number of classes). If cutoff is empty, 1/3 of the bounding box diagonal is used. It is in the Additional options group.
Effect on the result: Changes the empirical variogram and the fitted range.
On the validation data: For 5, 15, 50 classes the spherical range is 0.8835, 0.8970, 0.9216 km. For cutoff 1.0 km the range is 0.9655; at 0.5 km the exponential range is 7.39 km (warning that no sill is seen).
Variogram estimator (Classical (Matheron), Robust (Cressie-Hawkins))
Concept: Because the classical (Matheron) estimator averages squared differences, a few outliers can inflate the variogram. The Cressie-Hawkins estimator works with square roots of the differences and is more robust to outliers.
Everyday example: If one sample shows five times the usual nitrogen because of a lab error, every pair involving that sample has a very large difference and the classical variogram rises. Cressie-Hawkins reduces the influence of this single faulty sample.
What it does: The Cressie-Hawkins estimator is resistant to outliers.
Effect on the result: Changes the empirical variogram values and hence the fitted model.
On the validation data: Cressie-Hawkins spherical nugget 0.0082, range 0.9878.
Fitting weights (N/h² (gstat default, fit.method 7), Cressie: N/γ(h)² (fit.method 2), N (fit.method 1), Unweighted OLS (fit.method 6))
Concept: The variogram model is fitted to the empirical points by weighted least squares. The weighting options can give more importance to points based on many pairs and, as with the default N/h² weights, at short distances, on the grounds that short distances matter most for kriging predictions.
Everyday example: If the variogram point in the 50-metre class rests on hundreds of pairs, it is reliable and carries more weight in the fit. A distant class based on only a few pairs hardly affects the curve.
What it does: Estimates the nugget, partial sill and range by weighted least squares (weight N/h², N/γ(h)², N or unweighted).
Effect on the result: Changes the model parameters and hence the prediction surface.
On the validation data: Spherical range: N/h2 (default) 0.8970 km; 0.9110 for N; 0.8901 unweighted; 0.90015 with the Cressie weight.
Fit nugget effect (check box)
Concept: The nugget is the dissimilarity that remains even at distances very close to zero: the sum of measurement error and variability at scales smaller than the sampling interval. If it is not fitted, it is set to zero, which means assuming that repeated measurements at the same spot would always give the same result.
Everyday example: Even two samples taken half a metre apart can give different nitrogen values. The nugget models this short-scale difference; if it is fixed at zero, kriging gives the values at the measurement points more weight than it should when predicting nearby locations.
What it does: If unchecked, the nugget is fixed to 0.
Effect on the result: The partial sill and range are re-estimated; the short-distance behaviour changes.
On the validation data: When off, the spherical partial sill is 0.6211, range 0.7679 km.
Directional variogram (0°, 45°, 90°, 135°; anisotropy) (check box)
Concept: The directional variogram examines whether the rate at which similarity declines with distance depends on direction (anisotropy) by computing it in four separate directions. If the range differs clearly between directions, a direction-free model does not fully reflect the spatial structure.
Everyday example: If an old stream bed runs north-south across the field, nitrogen stays similar over long distances in that direction but changes quickly east-west. The directional variogram shows this as a longer range in the north-south direction.
What it does: Computes the variogram in four directions (+-22.5 degrees tolerance, clockwise from north) and the range per direction; the anisotropy ratio is reported.
Effect on the result: Adds a per-direction range and anisotropy table; does not change the isotropic kriging result.
On the validation data: In the 0, 45, 90, 135 degree directions the spherical range is 1.264 ... 1.042 km.
SK mean, UK trend (Linear coordinate trend (x + y), Quadratic coordinate trend, Covariate (external drift)) and Covariate
Concept: Sets the known mean used for simple kriging, or the form of the trend for universal kriging: a linear or quadratic function of the coordinates, or a separately measured auxiliary variable (external drift). For covariate-based prediction, the covariate's value must be known at every location to be predicted.
Everyday example: If soil nitrogen is known to be related to elevation and a detailed elevation map exists for the whole field, elevation is added as a covariate. Kriging then uses both the tendency explained by elevation and the spatial similarity beyond it.
What it does: Selects the known mean for SK, the trend form or the external drift variable for UK. In UK with a covariate, prediction is made in rows where the value column is empty but the covariate is filled.
Effect on the result: Changes the mean/trend structure and hence the prediction and the LOO error.
On the validation data: LOO RMSE 0.3917 with SK mean 6.0; UK linear exponential 0.3898; UK sqrt(dist) exponential 0.3777.
Block size
Concept: Block kriging estimates the average value over an area (block) of a given size instead of the value at a single point. Because averages fluctuate less than individual points, block estimates have smaller standard errors than point estimates.
Everyday example: Since the fertiliser spreader applies the same amount over each 10 × 10 metre area, what matters to the farmer is the average nitrogen in each block, not at a single point. With a 10-metre block size the map directly fits this decision, and the uncertainty appears smaller.
What it does: If > 0, estimates the mean of a square block (side, km) (block kriging; 4 x 4 Gauss discretisation).
Effect on the result: A block mean is less uncertain than a point value; the standard error falls.
On the validation data: The largest standard error is 0.739 for a 0.04 km block and 0.683 for 0.2 km (point kriging 0.785).
Number of neighbours (nmax)
Concept: Makes each prediction use only the nearest nmax measurement points instead of all of them (local kriging). Because distant points get very little weight anyway, the result usually changes little; in return, computation speeds up and the mean is allowed to vary slowly across the area.
Everyday example: When predicting a point at the northern end of the field, samples at the southern end contribute little. With nmax = 20 each prediction rests only on the 20 nearest samples, and the map is produced much faster.
What it does: Uses only the nearest nmax observations in each prediction (local kriging).
Effect on the result: Makes the prediction local; the prediction and the LOO error change.
On the validation data: LOO RMSE 0.3887 for nmax 30; 0.3879 for 10.
Compare with IDW (gstat idw) (check box) and IDW power (p)
Concept: Inverse distance weighting (IDW) gives each measurement point a weight inversely proportional to its distance raised to the power p; it does not model the spatial structure and produces no standard error. The larger p, the more the nearest points dominate. Comparing its LOO error with kriging's shows what variogram modelling adds to the prediction.
Everyday example: The farmer can compare the simpler IDW map with the kriging map. If kriging's cross-validation error is clearly smaller, working with the variogram has genuinely improved the fertiliser decisions.
What it does: Compares the inverse distance weighted interpolation surface and its LOO error with kriging (weight = distance^(-p); default p = 2).
Effect on the result: Does not change the kriging result; adds a comparison row.
On the validation data: LOO RMSE 0.6393 for p = 1; 0.5138 for p = 2; 0.4571 for p = 4 (kriging 0.3918).
Value (column)
Concept: Chooses the continuous variable to be mapped. If the variable is strongly skewed (e.g. pollutant concentrations), kriging is often done on the log-transformed value, because the variogram is heavily affected by extreme values.
Everyday example: Nitrogen (mg/kg) is chosen as the value. If nitrogen at a few points in the field is far above the rest, working with log nitrogen gives a more stable variogram.
What it does: Selects the variable to be estimated (log(zinc) etc.).
Effect on the result: The variogram, the model and all predictions rest on this variable.
On the validation data: logzinc in the default run.
Example on real data
Data: Meuse river floodplain, R sp meuse and meuse.grid
Variables: 155 soil samples (latitude/longitude on a km plane), value logzinc (zinc, log); 3103 grid rows with empty value are used only for covariate UK prediction
- Question: How does soil zinc (log) vary in space on the Meuse floodplain, and how well can it be predicted at unsampled points?
- Model: Four models were fitted to the 15-class empirical variogram; the spherical model was selected by the smallest weighted SSE: nugget = 0.051, partial sill = 0.591, range = 0.897 km.
- Spatial dependence: Nugget/sill ratio = 0.08; there is strong spatial dependence, samples closer than about 0.9 km resemble each other.
- Model fit (LOO): ME = -2.06e-05 (unbiased), RMSE = 0.392, r = 0.839; MSDR = 0.819 (close to 1): the kriging variance matches the actual errors.
- Prediction: The ordinary kriging surface ranges from 4.78 to 7.48 (logzinc); the largest standard error, 0.785, is at the edges where samples are sparse.
- Limitation: The variogram was assumed isotropic; a trend such as distance to the river should be tried separately with universal kriging.
- Report line: Spherical variogram (nugget = 0.051, partial sill = 0.591, range = 0.897 km); LOO RMSE = 0.392, r = .84, MSDR = 0.82.
Related concepts
Variogram (semivariogram)Kriging (simple, ordinary, universal, block)Leave-one-out (LOO)Nugget, sill and rangeAnisotropyInverse distance weighting (IDW)Observation window (study region)Distance measure (Euclidean, Manhattan, Gower, great-circle)
The numbers in the examples are MerQur's output on independent, publicly available validation data; see the MerQur Technical Note for details.