# Sample variogram

### Description

Computes the sample variogram from an `SpATS`

object.

### Usage

1 2 |

### Arguments

`x` |
an object of class |

`...` |
further arguments passed to or from other methods. Not yet implemented |

### Details

The present function computes the sample variogram on the basis of the (deviance) residuals of the fitted model. Currently, the function can only be applied for regular two-dimensional data, i.e, when the plots of the field are arranged in a regular two-dimensional array (usually defined by the column and row positions).
For each pair of (deviance) residuals *e_i* and *e_j*, the half-squared difference is computed

*v_{ij} = 0.5(e_i - e_j)^2,*

as well as the corresponding column (*cd_{ij}*) and row displacements (*rd_{ij}*), with

*cd_{ij} = |c_i - c_j|*

and

*rd_{ij} = |r_i - r_j|,*

where *c_k* and *r_k* denote the column and row position of plot *k* respectively. The sample variogram is then defined as the triplet

*(cd_{ij}, rd_{ij}, \bar{v}_{ij}),*

where *\bar{v}_{ij}* denotes the average of the *v_{ij}* that share the same column and row displacements.
For a more detailed description, see Gilmour et al. (1997).

### Value

An object of class `variogram.SpATS`

with the following components:

`data` |
data frame including the following information: “value”: the value of the sample variogram at each pair of column and row displacements; and “length”: the number of observations used to compute the sample variogram at the corresponding pair of displacements. |

`col.displacement` |
numerical vector containing the column displacements |

`row.displacement` |
numerical vector containing the row displacements |

### References

Gilmour, A.R., Cullis, B.R., and Verbyla, A.P. (1997). Accounting for Natural and Extraneous Variation in the Analysis of Field Experiments. Journal of Agricultural, Biological, and Environmental Statistics, 2, 269 - 293.

Stefanova, K.T., Smith, A.B. and Cullis, B.R. (2009). Enhanced Diagnostics for the Spatial Analysis of Field Trials. Journal of Agricultural, Biological, and Environmental Statistics, 14, 392 - 410.

### See Also

`SpATS`

, `plot.variogram.SpATS`

### Examples

1 2 3 4 5 6 7 8 9 10 11 12 13 | ```
library(SpATS)
data(wheatdata)
wheatdata$R <- as.factor(wheatdata$row)
wheatdata$C <- as.factor(wheatdata$col)
m0 <- SpATS(response = "yield", spatial = ~ SAP(col, row, nseg = c(10,20), degree = 3, pord = 2),
genotype = "geno", fixed = ~ colcode + rowcode, random = ~ R + C, data = wheatdata,
control = list(tolerance = 1e-03))
# Compute the variogram
var.m0 <- variogram(m0)
# Plot the variogram
plot(var.m0)
``` |