| Title: | tidymodels-Compatible Gaussian Process Model Zoo |
|---|---|
| Description: | A gateway to various Gaussian Process (GP) packages available on CRAN, including gstat, fields, GPvecchia, spNNGP, and PrestoGP. Provides a unified tidymodels-native interface through parsnip for model parameter adjustment and hyperparameter tuning. Supports spatial-only and spatiotemporal Kriging, sf inputs, prediction capabilities, and covariates for residual Gaussian Process (Universal Kriging) models. Parameters are automatically matched between the unified Kriging-centered argument names in gstat and the formulaic arguments used in other packages for the same construct. |
| Authors: | Insang Song [aut, cre], C Codex [aut] |
| Maintainer: | Insang Song <[email protected]> |
| License: | MIT + file LICENSE |
| Version: | 0.5.1 |
| Built: | 2026-06-01 07:31:59 UTC |
| Source: | https://github.com/sigmafelix/gopher |
Covariance function type (qualitative tuning parameter)
covariance_function( values = c("exponential", "spherical", "gaussian", "matern") )covariance_function( values = c("exponential", "spherical", "gaussian", "matern") )
values |
Character vector of allowable covariance function names. Defaults to the four most common choices. |
A dials qualitative parameter object.
covariance_function()covariance_function()
This function is called internally by parsnip. End users should call
parsnip::fit.model_spec() on a gaussian_process_spatial specification
with set_engine("fields").
fields_gp_fit( formula, data, covariance_function = "exponential", range = NULL, nugget = NULL, sill = NULL, coord_cols = NULL, use_mKrig = FALSE, ... )fields_gp_fit( formula, data, covariance_function = "exponential", range = NULL, nugget = NULL, sill = NULL, coord_cols = NULL, use_mKrig = FALSE, ... )
formula |
A two-sided formula. Use |
data |
An |
covariance_function |
Canonical covariance name. Defaults to
|
range |
Range (aRange) parameter for the covariance. |
nugget |
Nugget variance. Used to compute |
sill |
Partial sill (sigma2). |
coord_cols |
Character(2) coordinate column names (non-sf path). |
use_mKrig |
Logical. Use |
... |
Additional arguments forwarded to |
A list of class "gopher_fields_fit".
if (requireNamespace("spacetime", quietly = TRUE) && requireNamespace("fields", quietly = TRUE)) { data("air", package = "spacetime") day_id <- which.max(colSums(!is.na(air))) air_day <- data.frame( station = rownames(air), pm10 = air[, day_id], day = dates[day_id], sp::coordinates(stations) ) air_day <- air_day[stats::complete.cases(air_day$pm10), ] air_sf <- sf::st_as_sf( air_day, coords = c("coords.x1", "coords.x2"), crs = 4326, remove = FALSE ) fit <- fields_gp_fit(pm10 ~ coords.x1 + coords.x2, data = air_sf) fit }if (requireNamespace("spacetime", quietly = TRUE) && requireNamespace("fields", quietly = TRUE)) { data("air", package = "spacetime") day_id <- which.max(colSums(!is.na(air))) air_day <- data.frame( station = rownames(air), pm10 = air[, day_id], day = dates[day_id], sp::coordinates(stations) ) air_day <- air_day[stats::complete.cases(air_day$pm10), ] air_sf <- sf::st_as_sf( air_day, coords = c("coords.x1", "coords.x2"), crs = 4326, remove = FALSE ) fit <- fields_gp_fit(pm10 ~ coords.x1 + coords.x2, data = air_sf) fit }
Predict from a fields-fitted Gaussian Process model
fields_gp_predict( object, new_data, type = "numeric", level = 0.95, coord_cols = NULL, ... )fields_gp_predict( object, new_data, type = "numeric", level = 0.95, coord_cols = NULL, ... )
object |
A |
new_data |
An |
type |
|
level |
Confidence level for prediction intervals (default |
coord_cols |
Character(2) coord column names (non-sf path). |
... |
Forwarded to |
A tibble::tibble() with prediction columns.
if (requireNamespace("spacetime", quietly = TRUE) && requireNamespace("fields", quietly = TRUE)) { data("air", package = "spacetime") day_id <- which.max(colSums(!is.na(air))) air_day <- data.frame( station = rownames(air), pm10 = air[, day_id], day = dates[day_id], sp::coordinates(stations) ) air_day <- air_day[stats::complete.cases(air_day$pm10), ] air_sf <- sf::st_as_sf( air_day, coords = c("coords.x1", "coords.x2"), crs = 4326, remove = FALSE ) n_train <- floor(0.8 * nrow(air_sf)) train_sf <- air_sf[seq_len(n_train), ] test_sf <- air_sf[seq.int(n_train + 1L, nrow(air_sf)), ] fit <- fields_gp_fit(pm10 ~ coords.x1 + coords.x2, data = train_sf) fields_gp_predict(fit, new_data = test_sf, type = "pred_int") }if (requireNamespace("spacetime", quietly = TRUE) && requireNamespace("fields", quietly = TRUE)) { data("air", package = "spacetime") day_id <- which.max(colSums(!is.na(air))) air_day <- data.frame( station = rownames(air), pm10 = air[, day_id], day = dates[day_id], sp::coordinates(stations) ) air_day <- air_day[stats::complete.cases(air_day$pm10), ] air_sf <- sf::st_as_sf( air_day, coords = c("coords.x1", "coords.x2"), crs = 4326, remove = FALSE ) n_train <- floor(0.8 * nrow(air_sf)) train_sf <- air_sf[seq_len(n_train), ] test_sf <- air_sf[seq.int(n_train + 1L, nrow(air_sf)), ] fit <- fields_gp_fit(pm10 ~ coords.x1 + coords.x2, data = train_sf) fields_gp_predict(fit, new_data = test_sf, type = "pred_int") }
gaussian_process_spatial() defines a Gaussian Process model for spatial
and spatiotemporal data. This model supports multiple backends ("engines"),
including gstat, fields, GPvecchia, spNNGP, and
PrestoGP.
gaussian_process_spatial( mode = "regression", covariance_function = NULL, range = NULL, nugget = NULL, sill = NULL ) ## S3 method for class 'gaussian_process_spatial' update( object, parameters = NULL, covariance_function = NULL, range = NULL, nugget = NULL, sill = NULL, fresh = FALSE, ... )gaussian_process_spatial( mode = "regression", covariance_function = NULL, range = NULL, nugget = NULL, sill = NULL ) ## S3 method for class 'gaussian_process_spatial' update( object, parameters = NULL, covariance_function = NULL, range = NULL, nugget = NULL, sill = NULL, fresh = FALSE, ... )
mode |
A single character string for the prediction outcome mode.
The only possible value for this model is |
covariance_function |
The type of covariance function (variogram model)
to use. One of |
range |
The range (or scale) parameter of the covariance function.
Controls the distance at which spatial correlation effectively vanishes.
Defaults to |
nugget |
The nugget variance representing micro-scale variation and
measurement error. Defaults to |
sill |
The partial sill, i.e., the spatially structured variance
component. Defaults to |
Gaussian Process (GP) models — commonly known as Kriging in geostatistics —
predict values at unobserved locations by leveraging spatial autocorrelation.
The model assumes observations are a realisation of a GP with a specified
covariance structure. The covariance structure is characterised by a
variogram model parameterised by range, nugget, and sill.
The following engines are available:
"gstat" — Uses the gstat package for variogram-based kriging
(ordinary, universal, and simple kriging). Supports spatiotemporal
kriging with a time_col engine argument.
"fields" — Uses the fields package (Krig/mKrig) for spatial
kriging. Supports large datasets via mKrig.
"GPvecchia" — Uses the GPvecchia package for Vecchia-approximated
GP inference, suitable for large spatial and spatiotemporal datasets via
time_col.
"spNNGP" — Uses the spNNGP package for Nearest Neighbor Gaussian
Process models, scalable for large spatial datasets.
"PrestoGP" — Uses the PrestoGP package for scalable penalized
spatiotemporal Gaussian process models with built-in missing-value
imputation and limit-of-detection handling.
"sdmTMB" — Uses the sdmTMB package for spatial and spatiotemporal
models via Template Model Builder (TMB) with an INLA-style SPDE mesh.
Supports spatiotemporal modelling via time_col and spatiotemporal
engine arguments.
Parameters are automatically mapped between the unified gopher interface and engine-specific argument names:
| gopher | gstat (vgm) | fields (Krig) | GPvecchia | spNNGP | PrestoGP | sdmTMB |
covariance_function |
model |
Covariance |
covFun |
cov.model |
Matérn-only (mapped) | Matérn via SPDE mesh |
range |
range |
aRange |
range |
phi |
estimated internally | estimated internally |
nugget |
nugget |
sigma2 |
nugget |
tau.sq |
estimated internally | estimated internally |
sill |
psill |
sigma2 |
sigma2 |
sigma.sq |
estimated internally | estimated internally |
Input data can be provided as:
An sf object — geometry column is used for coordinates automatically.
A data.frame with columns x and y (or lon and lat).
When covariates are included in the formula (e.g., y ~ x1 + x2), the
model performs Universal Kriging — fitting a linear trend model with
spatial correlation of residuals. Use y ~ 1 for Ordinary Kriging
(no covariates, constant mean).
Spatiotemporal Gaussian process modelling is supported through the "gstat",
"GPvecchia", "PrestoGP", and "sdmTMB" engines by passing time_col as
an engine argument via set_engine(). The column specified must contain
date/time values (or numeric time indices). For "sdmTMB", also pass
spatiotemporal (one of "iid", "ar1", "rw") to enable the
spatiotemporal random field.
A gaussian_process_spatial model specification of class
c("gaussian_process_spatial", "model_spec").
parsnip::set_engine(), parsnip::fit.model_spec(),
parsnip::predict.model_fit()
if (requireNamespace("spacetime", quietly = TRUE) && requireNamespace("gstat", quietly = TRUE)) { data("air", package = "spacetime") # Convert legacy ST components from `air` to a single-day `sf` table. day_id <- which.max(colSums(!is.na(air))) air_day <- data.frame( station = rownames(air), pm10 = air[, day_id], day = dates[day_id], sp::coordinates(stations) ) air_day <- air_day[stats::complete.cases(air_day$pm10), ] air_sf <- sf::st_as_sf( air_day, coords = c("coords.x1", "coords.x2"), crs = 4326, remove = FALSE ) n_train <- floor(0.8 * nrow(air_sf)) train_sf <- air_sf[seq_len(n_train), ] test_sf <- air_sf[seq.int(n_train + 1L, nrow(air_sf)), ] gp_spec <- gaussian_process_spatial( covariance_function = "exponential" ) |> parsnip::set_engine("gstat") gp_fit <- parsnip::fit( gp_spec, pm10 ~ coords.x1 + coords.x2, data = train_sf ) predict(gp_fit, new_data = test_sf, type = "pred_int") }if (requireNamespace("spacetime", quietly = TRUE) && requireNamespace("gstat", quietly = TRUE)) { data("air", package = "spacetime") # Convert legacy ST components from `air` to a single-day `sf` table. day_id <- which.max(colSums(!is.na(air))) air_day <- data.frame( station = rownames(air), pm10 = air[, day_id], day = dates[day_id], sp::coordinates(stations) ) air_day <- air_day[stats::complete.cases(air_day$pm10), ] air_sf <- sf::st_as_sf( air_day, coords = c("coords.x1", "coords.x2"), crs = 4326, remove = FALSE ) n_train <- floor(0.8 * nrow(air_sf)) train_sf <- air_sf[seq_len(n_train), ] test_sf <- air_sf[seq.int(n_train + 1L, nrow(air_sf)), ] gp_spec <- gaussian_process_spatial( covariance_function = "exponential" ) |> parsnip::set_engine("gstat") gp_fit <- parsnip::fit( gp_spec, pm10 ~ coords.x1 + coords.x2, data = train_sf ) predict(gp_fit, new_data = test_sf, type = "pred_int") }
GP nugget variance (quantitative tuning parameter)
gp_nugget(range = c(0, 5), trans = NULL)gp_nugget(range = c(0, 5), trans = NULL)
range |
A numeric vector of length 2 giving lower and upper bounds. |
trans |
A |
A dials quantitative parameter object.
gp_nugget()gp_nugget()
GP range parameter (quantitative tuning parameter)
gp_range(range = c(0.001, 1000), trans = NULL)gp_range(range = c(0.001, 1000), trans = NULL)
range |
A numeric vector of length 2 giving the lower and upper bounds of the range parameter search space. Values are on the original scale. |
trans |
A |
A dials quantitative parameter object.
gp_range()gp_range()
GP partial sill variance (quantitative tuning parameter)
gp_sill(range = c(1e-06, 1000), trans = NULL)gp_sill(range = c(1e-06, 1000), trans = NULL)
range |
A numeric vector of length 2 giving lower and upper bounds. |
trans |
A |
A dials quantitative parameter object.
gp_sill()gp_sill()
This function is called internally by parsnip. End users should call
parsnip::fit.model_spec() on a gaussian_process_spatial specification
with set_engine("GPvecchia").
GPvecchia_gp_fit( formula, data, covariance_function = "exponential", range = NULL, nugget = NULL, sill = NULL, m = 15L, coord_cols = NULL, time_col = NULL, time_scale = 1, ... )GPvecchia_gp_fit( formula, data, covariance_function = "exponential", range = NULL, nugget = NULL, sill = NULL, m = 15L, coord_cols = NULL, time_col = NULL, time_scale = 1, ... )
formula |
A two-sided formula. Covariates are used as fixed-effect trend (Universal Kriging / residual GP). |
data |
An |
covariance_function |
Canonical covariance name. Defaults to
|
range |
Range parameter (scale). |
nugget |
Nugget (noise) variance. |
sill |
Signal variance (sigma^2). |
m |
Number of nearest neighbours for Vecchia approximation.
Default |
coord_cols |
Character(2) coordinate column names (non-sf path). |
time_col |
Optional character scalar specifying a time column for spatiotemporal modelling. |
time_scale |
Numeric scalar used to rescale time when |
... |
Additional arguments forwarded to
|
A list of class "gopher_GPvecchia_fit".
if (requireNamespace("spacetime", quietly = TRUE) && requireNamespace("GPvecchia", quietly = TRUE)) { data("air", package = "spacetime") day_id <- which.max(colSums(!is.na(air))) air_day <- data.frame( station = rownames(air), pm10 = air[, day_id], day = dates[day_id], sp::coordinates(stations) ) air_day <- air_day[stats::complete.cases(air_day$pm10), ] air_sf <- sf::st_as_sf( air_day, coords = c("coords.x1", "coords.x2"), crs = 4326, remove = FALSE ) fit <- GPvecchia_gp_fit(pm10 ~ coords.x1 + coords.x2, data = air_sf, m = 10) fit }if (requireNamespace("spacetime", quietly = TRUE) && requireNamespace("GPvecchia", quietly = TRUE)) { data("air", package = "spacetime") day_id <- which.max(colSums(!is.na(air))) air_day <- data.frame( station = rownames(air), pm10 = air[, day_id], day = dates[day_id], sp::coordinates(stations) ) air_day <- air_day[stats::complete.cases(air_day$pm10), ] air_sf <- sf::st_as_sf( air_day, coords = c("coords.x1", "coords.x2"), crs = 4326, remove = FALSE ) fit <- GPvecchia_gp_fit(pm10 ~ coords.x1 + coords.x2, data = air_sf, m = 10) fit }
Predict from a GPvecchia-fitted Gaussian Process model
GPvecchia_gp_predict( object, new_data, type = "numeric", level = 0.95, m_pred = NULL, coord_cols = NULL, time_col = NULL, time_scale = 1, ... )GPvecchia_gp_predict( object, new_data, type = "numeric", level = 0.95, m_pred = NULL, coord_cols = NULL, time_col = NULL, time_scale = 1, ... )
object |
A |
new_data |
An |
type |
|
level |
Confidence level for prediction intervals (default |
m_pred |
Number of nearest neighbours for prediction approximation.
Defaults to the training |
coord_cols |
Character(2) coord column names (non-sf path). |
time_col |
Optional character scalar specifying a time column for spatiotemporal modelling. |
time_scale |
Numeric scalar used to rescale time when |
... |
Additional arguments forwarded to
|
A tibble::tibble() with prediction columns.
if (requireNamespace("spacetime", quietly = TRUE) && requireNamespace("GPvecchia", quietly = TRUE)) { data("air", package = "spacetime") day_id <- which.max(colSums(!is.na(air))) air_day <- data.frame( station = rownames(air), pm10 = air[, day_id], day = dates[day_id], sp::coordinates(stations) ) air_day <- air_day[stats::complete.cases(air_day$pm10), ] air_sf <- sf::st_as_sf( air_day, coords = c("coords.x1", "coords.x2"), crs = 4326, remove = FALSE ) n_train <- floor(0.8 * nrow(air_sf)) train_sf <- air_sf[seq_len(n_train), ] test_sf <- air_sf[seq.int(n_train + 1L, nrow(air_sf)), ] fit <- GPvecchia_gp_fit(pm10 ~ coords.x1 + coords.x2, data = train_sf, m = 10) GPvecchia_gp_predict(fit, new_data = test_sf, type = "pred_int") }if (requireNamespace("spacetime", quietly = TRUE) && requireNamespace("GPvecchia", quietly = TRUE)) { data("air", package = "spacetime") day_id <- which.max(colSums(!is.na(air))) air_day <- data.frame( station = rownames(air), pm10 = air[, day_id], day = dates[day_id], sp::coordinates(stations) ) air_day <- air_day[stats::complete.cases(air_day$pm10), ] air_sf <- sf::st_as_sf( air_day, coords = c("coords.x1", "coords.x2"), crs = 4326, remove = FALSE ) n_train <- floor(0.8 * nrow(air_sf)) train_sf <- air_sf[seq_len(n_train), ] test_sf <- air_sf[seq.int(n_train + 1L, nrow(air_sf)), ] fit <- GPvecchia_gp_fit(pm10 ~ coords.x1 + coords.x2, data = train_sf, m = 10) GPvecchia_gp_predict(fit, new_data = test_sf, type = "pred_int") }
This function is called internally by parsnip. End users should call
parsnip::fit.model_spec() on a gaussian_process_spatial specification
with set_engine("gstat").
gstat_gp_fit( formula, data, covariance_function = "exponential", range = NULL, nugget = NULL, sill = NULL, coord_cols = NULL, time_col = NULL, fit_variogram = TRUE, cutoff = NULL, width = NULL, ... )gstat_gp_fit( formula, data, covariance_function = "exponential", range = NULL, nugget = NULL, sill = NULL, coord_cols = NULL, time_col = NULL, fit_variogram = TRUE, cutoff = NULL, width = NULL, ... )
formula |
A two-sided formula. Use |
data |
An |
covariance_function |
Canonical covariance name (see
|
range |
Initial/fixed range parameter. |
nugget |
Initial/fixed nugget. |
sill |
Initial/fixed partial sill. |
coord_cols |
Character(2) column names for coordinates when |
time_col |
Character name of the date/time column for spatiotemporal
kriging. |
fit_variogram |
Logical. When |
cutoff |
Passed to |
width |
Passed to |
... |
Additional arguments forwarded to |
A list of class "gopher_gstat_fit" containing the fitted
variogram model, the original training data, and the formula.
if (requireNamespace("spacetime", quietly = TRUE)) { data("air", package = "spacetime") # `air` is provided as legacy ST components (matrix + SpatialPoints + Date). # Convert one day to an `sf` object for spatial GP fitting. day_id <- which.max(colSums(!is.na(air))) air_day <- data.frame( station = rownames(air), pm10 = air[, day_id], day = dates[day_id], sp::coordinates(stations) ) air_day <- air_day[stats::complete.cases(air_day$pm10), ] air_sf <- sf::st_as_sf( air_day, coords = c("coords.x1", "coords.x2"), crs = 4326, remove = FALSE ) fit <- gstat_gp_fit(pm10 ~ 1, data = air_sf) fit }if (requireNamespace("spacetime", quietly = TRUE)) { data("air", package = "spacetime") # `air` is provided as legacy ST components (matrix + SpatialPoints + Date). # Convert one day to an `sf` object for spatial GP fitting. day_id <- which.max(colSums(!is.na(air))) air_day <- data.frame( station = rownames(air), pm10 = air[, day_id], day = dates[day_id], sp::coordinates(stations) ) air_day <- air_day[stats::complete.cases(air_day$pm10), ] air_sf <- sf::st_as_sf( air_day, coords = c("coords.x1", "coords.x2"), crs = 4326, remove = FALSE ) fit <- gstat_gp_fit(pm10 ~ 1, data = air_sf) fit }
Predict from a gstat-fitted Gaussian Process model
gstat_gp_predict( object, new_data, type = "numeric", level = 0.95, coord_cols = NULL, ... )gstat_gp_predict( object, new_data, type = "numeric", level = 0.95, coord_cols = NULL, ... )
object |
A |
new_data |
An |
type |
One of |
level |
Confidence level for prediction intervals (default |
coord_cols |
Character(2) coord column names (non-sf path). |
... |
Forwarded to |
A tibble::tibble() with prediction columns.
if (requireNamespace("spacetime", quietly = TRUE)) { data("air", package = "spacetime") day_id <- which.max(colSums(!is.na(air))) air_day <- data.frame( station = rownames(air), pm10 = air[, day_id], day = dates[day_id], sp::coordinates(stations) ) air_day <- air_day[stats::complete.cases(air_day$pm10), ] air_sf <- sf::st_as_sf( air_day, coords = c("coords.x1", "coords.x2"), crs = 4326, remove = FALSE ) n_train <- floor(0.8 * nrow(air_sf)) train_sf <- air_sf[seq_len(n_train), ] test_sf <- air_sf[seq.int(n_train + 1L, nrow(air_sf)), ] fit <- gstat_gp_fit(pm10 ~ coords.x1 + coords.x2, data = train_sf) gstat_gp_predict(fit, new_data = test_sf, type = "pred_int") }if (requireNamespace("spacetime", quietly = TRUE)) { data("air", package = "spacetime") day_id <- which.max(colSums(!is.na(air))) air_day <- data.frame( station = rownames(air), pm10 = air[, day_id], day = dates[day_id], sp::coordinates(stations) ) air_day <- air_day[stats::complete.cases(air_day$pm10), ] air_sf <- sf::st_as_sf( air_day, coords = c("coords.x1", "coords.x2"), crs = 4326, remove = FALSE ) n_train <- floor(0.8 * nrow(air_sf)) train_sf <- air_sf[seq_len(n_train), ] test_sf <- air_sf[seq.int(n_train + 1L, nrow(air_sf)), ] fit <- gstat_gp_fit(pm10 ~ coords.x1 + coords.x2, data = train_sf) gstat_gp_predict(fit, new_data = test_sf, type = "pred_int") }
This function is called internally by parsnip. End users should call
parsnip::fit.model_spec() on a gaussian_process_spatial specification
with set_engine("PrestoGP").
PrestoGP_gp_fit( formula, data, covariance_function = "matern", range = NULL, nugget = NULL, sill = NULL, n_neighbors = 15L, model_type = c("vecchia", "full"), coord_cols = NULL, time_col = NULL, time_scale = 1, scaling = NULL, common_scale = NULL, impute_y = NULL, lod_upper = NULL, lod_lower = NULL, n_impute = 10L, eps_impute = 0.01, maxit_impute = 0L, penalty = c("lasso", "relaxed", "MCP", "SCAD"), alpha = 1, family = c("gaussian", "binomial"), quiet = TRUE, ... )PrestoGP_gp_fit( formula, data, covariance_function = "matern", range = NULL, nugget = NULL, sill = NULL, n_neighbors = 15L, model_type = c("vecchia", "full"), coord_cols = NULL, time_col = NULL, time_scale = 1, scaling = NULL, common_scale = NULL, impute_y = NULL, lod_upper = NULL, lod_lower = NULL, n_impute = 10L, eps_impute = 0.01, maxit_impute = 0L, penalty = c("lasso", "relaxed", "MCP", "SCAD"), alpha = 1, family = c("gaussian", "binomial"), quiet = TRUE, ... )
formula |
A two-sided formula. |
data |
An |
covariance_function |
Canonical covariance name. PrestoGP currently uses Matérn covariance internally; non-Matérn values are accepted but mapped to Matérn. |
range |
Unused by PrestoGP in the current adapter (kept for unified interface compatibility). |
nugget |
Unused by PrestoGP in the current adapter (kept for unified interface compatibility). |
sill |
Unused by PrestoGP in the current adapter (kept for unified interface compatibility). |
n_neighbors |
Number of neighbors for Vecchia approximation. |
model_type |
|
coord_cols |
Character(2) coordinate column names for non-sf input. |
time_col |
Optional character scalar specifying a time column for spatiotemporal modelling. |
time_scale |
Numeric scalar used to rescale time when |
scaling |
Optional integer vector passed to |
common_scale |
Optional logical passed to |
impute_y |
Logical or |
lod_upper |
Upper LOD bound(s) passed to |
lod_lower |
Lower LOD bound(s) passed to |
n_impute |
Number of multiple imputations for LOD-aware missingness. |
eps_impute |
Convergence tolerance for multiple imputation. |
maxit_impute |
Maximum iterations for multiple imputation. |
penalty |
Penalty type passed to PrestoGP ( |
alpha |
Elastic-net mixing parameter passed to PrestoGP. |
family |
GLM family passed to PrestoGP ( |
quiet |
Logical; suppress iterative fit messages if |
... |
Additional arguments forwarded to |
A list of class "gopher_PrestoGP_fit".
Predict from a PrestoGP-fitted Gaussian Process model
PrestoGP_gp_predict( object, new_data, type = "numeric", level = 0.95, m_pred = NULL, coord_cols = NULL, time_col = NULL, time_scale = 1, ... )PrestoGP_gp_predict( object, new_data, type = "numeric", level = 0.95, m_pred = NULL, coord_cols = NULL, time_col = NULL, time_scale = 1, ... )
object |
A |
new_data |
An |
type |
|
level |
Confidence level for prediction intervals (default |
m_pred |
Optional number of neighbors for prediction. |
coord_cols |
Character(2) coordinate column names for non-sf input. |
time_col |
Optional character scalar specifying a time column for spatiotemporal modelling. |
time_scale |
Numeric scalar used to rescale time when |
... |
Forwarded to |
A tibble::tibble() with prediction columns.
This function is called internally by parsnip. End users should call
parsnip::fit.model_spec() on a gaussian_process_spatial specification
with set_engine("sdmTMB").
sdmTMB_gp_fit( formula, data, covariance_function = "matern", range = NULL, nugget = NULL, sill = NULL, coord_cols = NULL, time_col = NULL, spatial = "on", spatiotemporal = "off", mesh_cutoff = NULL, n_knots = NULL, family = stats::gaussian(), share_range = FALSE, extra_time = NULL, silent = TRUE, ... )sdmTMB_gp_fit( formula, data, covariance_function = "matern", range = NULL, nugget = NULL, sill = NULL, coord_cols = NULL, time_col = NULL, spatial = "on", spatiotemporal = "off", mesh_cutoff = NULL, n_knots = NULL, family = stats::gaussian(), share_range = FALSE, extra_time = NULL, silent = TRUE, ... )
formula |
A two-sided formula. Use |
data |
An |
covariance_function |
Canonical covariance name (see
|
range |
Unused by sdmTMB in the current adapter (estimated internally via maximum likelihood). Kept for unified interface compatibility. |
nugget |
Unused by sdmTMB in the current adapter. Kept for unified interface compatibility. |
sill |
Unused by sdmTMB in the current adapter. Kept for unified interface compatibility. |
coord_cols |
Character vector of length 2 giving the coordinate column
names for non- |
time_col |
Character scalar naming the time column for spatiotemporal
models. |
spatial |
One of |
spatiotemporal |
One of |
mesh_cutoff |
Numeric scalar passed to |
n_knots |
Integer. Number of mesh knots for the k-means mesh type.
If provided, |
family |
A |
share_range |
Logical. Whether to share the spatial range between the
spatial and spatiotemporal random fields. Default |
extra_time |
Integer or numeric vector of additional time values to
include in the model that are not present in |
silent |
Logical. Suppress model-fitting messages. Default |
... |
Additional arguments forwarded to |
A list of class "gopher_sdmTMB_fit" containing:
sdmtmb_fit — the fitted sdmTMB model object.
mesh — the sdmTMBmesh used for fitting.
formula — the model formula.
xy_cols — internal coordinate column names used in the data.
coord_cols — user-supplied coord_cols (may be NULL).
time_col — the time column name (may be NULL).
extra_time — additional time values declared at fit time (may be
NULL).
family — the family object.
if (requireNamespace("sdmTMB", quietly = TRUE)) { train <- data.frame( x = runif(50, 0, 10), y = runif(50, 0, 10) ) train$z <- sin(train$x) + cos(train$y) + rnorm(50, 0, 0.3) train_sf <- sf::st_as_sf(train, coords = c("x", "y"), crs = 4326) fit <- sdmTMB_gp_fit(z ~ 1, data = train_sf) fit }if (requireNamespace("sdmTMB", quietly = TRUE)) { train <- data.frame( x = runif(50, 0, 10), y = runif(50, 0, 10) ) train$z <- sin(train$x) + cos(train$y) + rnorm(50, 0, 0.3) train_sf <- sf::st_as_sf(train, coords = c("x", "y"), crs = 4326) fit <- sdmTMB_gp_fit(z ~ 1, data = train_sf) fit }
Predict from an sdmTMB-fitted Gaussian Process model
sdmTMB_gp_predict( object, new_data, type = "numeric", level = 0.95, coord_cols = NULL, ... )sdmTMB_gp_predict( object, new_data, type = "numeric", level = 0.95, coord_cols = NULL, ... )
object |
A |
new_data |
An |
type |
One of |
level |
Confidence level for prediction intervals (default |
coord_cols |
Character vector of length 2 giving coordinate column
names for non- |
... |
Additional arguments forwarded to |
A tibble::tibble() with prediction columns.
if (requireNamespace("sdmTMB", quietly = TRUE)) { set.seed(1) train <- data.frame(x = runif(50, 0, 10), y = runif(50, 0, 10)) train$z <- sin(train$x) + cos(train$y) + rnorm(50, 0, 0.3) train_sf <- sf::st_as_sf(train, coords = c("x", "y"), crs = 4326) newdat <- sf::st_as_sf( expand.grid(x = seq(1, 9, l = 4), y = seq(1, 9, l = 4)), coords = c("x", "y"), crs = 4326 ) fit <- sdmTMB_gp_fit(z ~ 1, data = train_sf) sdmTMB_gp_predict(fit, new_data = newdat) }if (requireNamespace("sdmTMB", quietly = TRUE)) { set.seed(1) train <- data.frame(x = runif(50, 0, 10), y = runif(50, 0, 10)) train$z <- sin(train$x) + cos(train$y) + rnorm(50, 0, 0.3) train_sf <- sf::st_as_sf(train, coords = c("x", "y"), crs = 4326) newdat <- sf::st_as_sf( expand.grid(x = seq(1, 9, l = 4), y = seq(1, 9, l = 4)), coords = c("x", "y"), crs = 4326 ) fit <- sdmTMB_gp_fit(z ~ 1, data = train_sf) sdmTMB_gp_predict(fit, new_data = newdat) }
This function is called internally by parsnip. End users should call
parsnip::fit.model_spec() on a gaussian_process_spatial specification
with set_engine("spNNGP").
spNNGP_gp_fit( formula, data, covariance_function = "exponential", range = NULL, nugget = NULL, sill = NULL, n_neighbors = 15L, n_samples = 1000L, n_burnin = 500L, method = "response", coord_cols = NULL, time_col = NULL, time_scale = 1, ... )spNNGP_gp_fit( formula, data, covariance_function = "exponential", range = NULL, nugget = NULL, sill = NULL, n_neighbors = 15L, n_samples = 1000L, n_burnin = 500L, method = "response", coord_cols = NULL, time_col = NULL, time_scale = 1, ... )
formula |
A two-sided formula. Covariates are included as fixed effects (Universal Kriging). |
data |
An |
covariance_function |
Canonical covariance name. Defaults to
|
range |
Starting value for the range parameter ( |
nugget |
Starting value for the nugget ( |
sill |
Starting value for the partial sill ( |
n_neighbors |
Number of nearest neighbours. Default |
n_samples |
Number of MCMC samples. Default |
n_burnin |
MCMC burn-in. Default |
method |
spNNGP method: |
coord_cols |
Character(2) coordinate column names (non-sf path). |
time_col |
Optional character scalar specifying a time column for spatiotemporal modelling. |
time_scale |
Numeric scalar used to rescale time when |
... |
Additional arguments forwarded to |
A list of class "gopher_spNNGP_fit".
if (requireNamespace("spacetime", quietly = TRUE) && requireNamespace("spNNGP", quietly = TRUE)) { data("air", package = "spacetime") day_id <- which.max(colSums(!is.na(air))) air_day <- data.frame( station = rownames(air), pm10 = air[, day_id], day = dates[day_id], sp::coordinates(stations) ) air_day <- air_day[stats::complete.cases(air_day$pm10), ] air_sf <- sf::st_as_sf( air_day, coords = c("coords.x1", "coords.x2"), crs = 4326, remove = FALSE ) fit <- spNNGP_gp_fit( pm10 ~ coords.x1 + coords.x2, data = air_sf, n_neighbors = 8, n_samples = 80, n_burnin = 40 ) fit }if (requireNamespace("spacetime", quietly = TRUE) && requireNamespace("spNNGP", quietly = TRUE)) { data("air", package = "spacetime") day_id <- which.max(colSums(!is.na(air))) air_day <- data.frame( station = rownames(air), pm10 = air[, day_id], day = dates[day_id], sp::coordinates(stations) ) air_day <- air_day[stats::complete.cases(air_day$pm10), ] air_sf <- sf::st_as_sf( air_day, coords = c("coords.x1", "coords.x2"), crs = 4326, remove = FALSE ) fit <- spNNGP_gp_fit( pm10 ~ coords.x1 + coords.x2, data = air_sf, n_neighbors = 8, n_samples = 80, n_burnin = 40 ) fit }
Predict from an spNNGP-fitted Gaussian Process model
spNNGP_gp_predict( object, new_data, type = "numeric", level = 0.95, coord_cols = NULL, time_col = NULL, time_scale = 1, ... )spNNGP_gp_predict( object, new_data, type = "numeric", level = 0.95, coord_cols = NULL, time_col = NULL, time_scale = 1, ... )
object |
A |
new_data |
An |
type |
|
level |
Confidence level for prediction intervals (default |
coord_cols |
Character(2) coord column names (non-sf path). |
time_col |
Optional character scalar specifying a time column for spatiotemporal modelling. |
time_scale |
Numeric scalar used to rescale time when |
... |
Forwarded to |
A tibble::tibble() with prediction columns.
if (requireNamespace("spacetime", quietly = TRUE) && requireNamespace("spNNGP", quietly = TRUE)) { data("air", package = "spacetime") day_id <- which.max(colSums(!is.na(air))) air_day <- data.frame( station = rownames(air), pm10 = air[, day_id], day = dates[day_id], sp::coordinates(stations) ) air_day <- air_day[stats::complete.cases(air_day$pm10), ] air_sf <- sf::st_as_sf( air_day, coords = c("coords.x1", "coords.x2"), crs = 4326, remove = FALSE ) n_train <- floor(0.8 * nrow(air_sf)) train_sf <- air_sf[seq_len(n_train), ] test_sf <- air_sf[seq.int(n_train + 1L, nrow(air_sf)), ] fit <- spNNGP_gp_fit( pm10 ~ coords.x1 + coords.x2, data = train_sf, n_neighbors = 8, n_samples = 80, n_burnin = 40 ) spNNGP_gp_predict(fit, new_data = test_sf, type = "pred_int") }if (requireNamespace("spacetime", quietly = TRUE) && requireNamespace("spNNGP", quietly = TRUE)) { data("air", package = "spacetime") day_id <- which.max(colSums(!is.na(air))) air_day <- data.frame( station = rownames(air), pm10 = air[, day_id], day = dates[day_id], sp::coordinates(stations) ) air_day <- air_day[stats::complete.cases(air_day$pm10), ] air_sf <- sf::st_as_sf( air_day, coords = c("coords.x1", "coords.x2"), crs = 4326, remove = FALSE ) n_train <- floor(0.8 * nrow(air_sf)) train_sf <- air_sf[seq_len(n_train), ] test_sf <- air_sf[seq.int(n_train + 1L, nrow(air_sf)), ] fit <- spNNGP_gp_fit( pm10 ~ coords.x1 + coords.x2, data = train_sf, n_neighbors = 8, n_samples = 80, n_burnin = 40 ) spNNGP_gp_predict(fit, new_data = test_sf, type = "pred_int") }