Skip to contents

Kriging Best Fit: kbfit - Fit variogram models and kriging models to spatial data and select the best model based on the metrics values

Usage

kbfit(response, formula, data, models, initial_values)

Arguments

response

A character string specifying the response variable

formula

A formula object specifying the model to fit: response ~ predictors

data

A simple feature object containing the variables in the formula

models

A list of characters vector specifying the variogram models to fit

initial_values

A list of named numeric vectors specifying the initial values for the variogram models: psill, range, nugget

Value

A list with two elements: all_models and best_model

Examples

if (FALSE) { # \dontrun{
# This is a dontrun example because it requires a spatial data object(data_sf).
# Try different initial values for fitting the variogram models
initial_values <- list(
  list(psill = 1, range = 100000, nugget = 10),
  list(psill = 0.5, range = 50000, nugget = 5),
  list(psill = 2, range = 150000, nugget = 15)
)

# Set some models to fit
models <- c("Sph", "Exp", "Gau")

# Select Best: Fit variogram models and kriging models
result <- hmsidwR::kbfit(response = "response",
                   formula = response ~ predictor1 + predictor2,
                   data = data_sf,
                   models = c("Sph", "Exp", "Gau", "Mat"),
                   initial_values = initial_values)

result$all_models
result$best_model
} # }