Skip to contents

The nugget variance of the variogram model behind a estimate_sac_range() result: the semivariance at zero separation, i.e. measurement error plus variation at scales shorter than the first lag bin of the empirical variogram (gstat's bins are cutoff / 15 wide, about max_dist / 30 at the default cutoff), which can be far wider than the spacing of close pairs. It is extrapolated to zero from that bin, not observed, and a fit that runs into its lower bound reports exactly 0. It is carried as the nugget attribute of every classed result, identified or rejected, because it is the number a resolution criterion for a tessellation needs (the short-lag variance that no cell can average away).

Usage

sac_nugget(x)

Arguments

x

A sac_range object, or anything else.

Value

A single number: the nugget in the units of the response's variance; NA_real_ when x carries no fitted model (a bare NA from a run that could not fit anything, a rejected result whose fits were all singular, or an object that is not a sac_range).

Examples

if (requireNamespace("gstat", quietly = TRUE)) {
  library(sf)
  # A field with a real nugget: half a unit of white noise on a unit sill.
  set.seed(3)
  n <- 250
  xy <- data.frame(x = 5e5 + runif(n, 0, 1000), y = 5e6 + runif(n, 0, 1000))
  D  <- as.matrix(dist(xy))
  xy$z <- as.numeric(t(chol(exp(-D / 150) + diag(0.5, n))) %*% rnorm(n))
  r <- estimate_sac_range(st_as_sf(xy, coords = c("x", "y"), crs = 32632), "z")
  print(sac_nugget(r))  # the fitted nugget variance, on the sill's scale
  sac_nugget(NA)        # nothing fitted: NA
}
#> [1] 0.4075242
#> [1] NA