| Title: | Automatic Spatio-Temporal Kriging |
|---|---|
| Description: | Automatic spatio-temporal Kriging extending the automap package (Hiemstra et al. 2010). Provides automatic variogram model fitting with data-driven initial parameter estimation (practical-range based) and multiple optimisers: L-BFGS-B with multi-start, LHS grid search, Simulated Annealing (SANN), and Genetic Algorithm (via the GA package or built-in Differential Evolution fallback). Covariance structure selection via AIC/BIC or cross-validation, and spatiotemporal prediction via gstat. Input classes sf, sftime, spacetime ST*DF, and cubble are all supported. Four cross-validation strategies for spatiotemporal data are implemented. |
| Authors: | Insang Song [aut, cre] (ORCID: <https://orcid.org/0000-0001-8732-3256>) |
| Maintainer: | Insang Song <[email protected]> |
| License: | MIT + file LICENSE |
| Version: | 2.1.2 |
| Built: | 2026-05-23 05:46:44 UTC |
| Source: | https://github.com/sigmafelix/autoSTK |
Fits a spatio-temporal variogram model to a spatio-temporal data frame using automatic parameter estimation. Supports multiple optimisers and objective functions (v2.0+).
autofitVariogramST( stf, formula, typestv = "sumMetric", candidate_model = c("Ste", "Exc", "Exp", "Wav"), guess_nugget = NULL, guess_psill = NULL, tlags = 0:6, cutoff = 20000, width = 500, aniso_method = "vgm", type_joint = "Exp", prodsum_k = NULL, surface = FALSE, measurement_error = c(0, 0, 0), cores = 1L, verbose = FALSE, optimizer = c("lbfgsb", "grid", "sa", "ga"), objective = c("WLS", "MLE"), n_restart = 1L, optimizer_control = list() )autofitVariogramST( stf, formula, typestv = "sumMetric", candidate_model = c("Ste", "Exc", "Exp", "Wav"), guess_nugget = NULL, guess_psill = NULL, tlags = 0:6, cutoff = 20000, width = 500, aniso_method = "vgm", type_joint = "Exp", prodsum_k = NULL, surface = FALSE, measurement_error = c(0, 0, 0), cores = 1L, verbose = FALSE, optimizer = c("lbfgsb", "grid", "sa", "ga"), objective = c("WLS", "MLE"), n_restart = 1L, optimizer_control = list() )
stf |
A spatio-temporal data frame (STFDF, STSDF, STIDF, or sftime). |
formula |
A formula specifying the response and explanatory variables. |
typestv |
Character. ST variogram model type. One of |
candidate_model |
Character vector of candidate spatial/temporal
variogram model families (e.g. |
guess_nugget |
Optional initial guess for the nugget. Estimated if NULL. |
guess_psill |
Optional initial guess for the partial sill. Estimated if NULL. |
tlags |
Integer vector of temporal lags. |
cutoff |
Numeric. Maximum spatial lag distance. |
width |
Numeric. Width of spatial lag bins. |
aniso_method |
Character. Method for estimating ST anisotropy ratio
( |
type_joint |
Character. Model family for the joint variogram component. |
prodsum_k |
Numeric. k parameter for productSum models. |
surface |
Logical. If TRUE, also compute and return the variogram surface. |
measurement_error |
Numeric vector of length 3: spatial, temporal, joint. |
cores |
Integer. Number of cores for |
verbose |
Logical. If TRUE, print diagnostic messages. |
optimizer |
Character. Optimisation strategy:
|
objective |
Character. Fitting criterion: |
n_restart |
Integer. Number of optimisation restarts for
|
optimizer_control |
Named list of extra arguments forwarded to the optimiser. Recognised keys differ by optimiser:
|
A STVariogramFit object (list) with elements:
Fitted ST variogram model.
Empirical ST variogram.
Fitted spatial marginal variogram.
Fitted temporal marginal variogram.
(Optional) Variogram surface if surface = TRUE.
Character. Optimiser used.
Character. Objective function used.
Numeric. Log-likelihood (only when objective = "MLE").
Integer. Number of observations (for AIC/BIC).
fitVariogramST, selectModelST,
test_separability
library(spacetime) library(sp) library(sftime) data(air) stations <- st_as_sf(stations) stations <- st_transform(stations, 'EPSG:3857') airdf <- data.frame(PM10 = as.vector(air)) stations_full <- do.call(c, rep(stations, length(dates))) dates_full <- rep(dates, each = nrow(stations)) rural <- cbind(airdf, time = dates_full, stations_full) rural <- st_as_sftime(rural, sf_column_name = 'geometry') rr <- rural[match(rural$time, dates[3001:3060], nomatch = FALSE) > 0, ] rr <- as(as(as(rr, "STIDF"), "STFDF"), "STSDF") rrstv <- autofitVariogramST( stf = rr, formula = PM10 ~ 1, surface = TRUE, cutoff = 2e6, width = 2e5, tlags = 0:6) rrstvlibrary(spacetime) library(sp) library(sftime) data(air) stations <- st_as_sf(stations) stations <- st_transform(stations, 'EPSG:3857') airdf <- data.frame(PM10 = as.vector(air)) stations_full <- do.call(c, rep(stations, length(dates))) dates_full <- rep(dates, each = nrow(stations)) rural <- cbind(airdf, time = dates_full, stations_full) rural <- st_as_sftime(rural, sf_column_name = 'geometry') rr <- rural[match(rural$time, dates[3001:3060], nomatch = FALSE) > 0, ] rr <- as(as(as(rr, "STIDF"), "STFDF"), "STSDF") rrstv <- autofitVariogramST( stf = rr, formula = PM10 ~ 1, surface = TRUE, cutoff = 2e6, width = 2e5, tlags = 0:6) rrstv
Convenience wrapper that fits the variogram and predicts in one call.
Internally calls fitVariogramST then
predictKrigeST.
autoKrigeST( formula, input_data, new_data, type_stv = "sumMetric", block = 0, model = c("Sph", "Exp", "Gau", "Ste"), kappa = c(0.05, seq(0.2, 2, 0.1), 5, 10), fix.values = c(NA, NA, NA), newdata_mode = "rect", newdata_npoints = 3000, GLS.model = NA, tlags = 0:6, cutoff = 20000, width = 500, forward = 6, predict_chunk = NULL, nmax = Inf, aniso_method = "vgm", type_joint = "Exp", prodsum_k = 0.25, surface = FALSE, start_vals = c(NA, NA, NA), miscFitOptions = list(), measurement_error = c(0, 0, 0), cores = 1L, verbose = TRUE, optimizer = "lbfgsb", objective = "WLS", n_restart = 1L, optimizer_control = list() )autoKrigeST( formula, input_data, new_data, type_stv = "sumMetric", block = 0, model = c("Sph", "Exp", "Gau", "Ste"), kappa = c(0.05, seq(0.2, 2, 0.1), 5, 10), fix.values = c(NA, NA, NA), newdata_mode = "rect", newdata_npoints = 3000, GLS.model = NA, tlags = 0:6, cutoff = 20000, width = 500, forward = 6, predict_chunk = NULL, nmax = Inf, aniso_method = "vgm", type_joint = "Exp", prodsum_k = 0.25, surface = FALSE, start_vals = c(NA, NA, NA), miscFitOptions = list(), measurement_error = c(0, 0, 0), cores = 1L, verbose = TRUE, optimizer = "lbfgsb", objective = "WLS", n_restart = 1L, optimizer_control = list() )
formula |
A formula (e.g. |
input_data |
Training data (STFDF, STSDF, STIDF, or sftime). |
new_data |
Prediction grid. If missing, generated automatically via
|
type_stv |
Character. ST variogram model type. Passed as |
block |
Numeric. Block size for block Kriging. |
model |
Character vector. Candidate marginal variogram model families. |
kappa |
Numeric vector. Kappa values for Matern-family models. |
fix.values |
Numeric vector (3). Fixed initial values for nugget, range, sill. |
newdata_mode |
Character. |
newdata_npoints |
Integer. Number of prediction grid points. |
GLS.model |
Variogram model for GLS sample variogram (rarely needed). |
tlags |
Integer vector. Temporal lags. |
cutoff |
Numeric. Maximum spatial lag. |
width |
Numeric. Spatial lag bin width. |
forward |
Integer. Number of future time steps to predict. |
predict_chunk |
Integer or NULL. Chunk size for large prediction grids. |
nmax |
Numeric. Maximum number of ST neighbours. |
aniso_method |
Character. Anisotropy estimation method. |
type_joint |
Character. Joint variogram component model family. |
prodsum_k |
Numeric. k parameter for productSum models. |
surface |
Logical. Return variogram surface? |
start_vals |
Numeric vector (3). Not used in v2.0 (kept for API compat). |
miscFitOptions |
List. Not used in v2.0 (kept for API compat). |
measurement_error |
Numeric vector (3). Measurement error components. |
cores |
Integer. Cores for variogramST computation. |
verbose |
Logical. Print progress messages. |
optimizer |
Character. One of |
objective |
Character. |
n_restart |
Integer. Number of optimisation restarts. |
optimizer_control |
List. Extra control arguments for the optimiser. |
An autoKrigeST object.
library(spacetime) library(gstat) data(air) deair <- STFDF(stations, dates, data.frame(PM10 = as.vector(air))) deair_rs <- deair[, 3751:3800] ## Not run: ## Not run: akst <- autoKrigeST(formula = PM10 ~ 1, input_data = deair_rs, cutoff = 300000, width = 30000, tlags = 0:7, cores = 4) ## End(Not run)library(spacetime) library(gstat) data(air) deair <- STFDF(stations, dates, data.frame(PM10 = as.vector(air))) deair_rs <- deair[, 3751:3800] ## Not run: ## Not run: akst <- autoKrigeST(formula = PM10 ~ 1, input_data = deair_rs, cutoff = 300000, width = 30000, tlags = 0:7, cores = 4) ## End(Not run)
Cross-validation of spatiotemporal Kriging
autoKrigeST.cv( data, fold_dim = c("spatial", "temporal", "random", "spacetime"), nfold = 10L, formula, type_stv = "sumMetric", block = 0, model = c("Sph", "Exp", "Gau", "Ste"), kappa = c(0.05, seq(0.2, 2, 0.1), 5, 10), fix.values = c(NA, NA, NA), tlags = 0:6, cutoff = 20000, width = 500, nmax = Inf, aniso_method = "vgm", type_joint = "Exp", prodsum_k = 0.25, surface = FALSE, start_vals = c(NA, NA, NA), miscFitOptions = list(), measurement_error = c(0, 0, 0), cores = 1, seed = 130425L, variogram_from_full = FALSE, optimizer = "lbfgsb", objective = "WLS", n_restart = 1L, optimizer_control = list() )autoKrigeST.cv( data, fold_dim = c("spatial", "temporal", "random", "spacetime"), nfold = 10L, formula, type_stv = "sumMetric", block = 0, model = c("Sph", "Exp", "Gau", "Ste"), kappa = c(0.05, seq(0.2, 2, 0.1), 5, 10), fix.values = c(NA, NA, NA), tlags = 0:6, cutoff = 20000, width = 500, nmax = Inf, aniso_method = "vgm", type_joint = "Exp", prodsum_k = 0.25, surface = FALSE, start_vals = c(NA, NA, NA), miscFitOptions = list(), measurement_error = c(0, 0, 0), cores = 1, seed = 130425L, variogram_from_full = FALSE, optimizer = "lbfgsb", objective = "WLS", n_restart = 1L, optimizer_control = list() )
data |
a 'STFDF'-class object |
fold_dim |
character. the dimension at which you want to cross-validate (spatial, temporal, and random) |
nfold |
integer. the number of folds. 10 as the default |
formula |
formula. e.g., y~1 |
type_stv |
character. One of 'sumMetric', 'metric', 'productSum', and 'separable' |
block |
numeric. passed to conduct block spatiotemporal Kriging. |
model |
character vector. Default is c("Sph", "Exp", "Gau", "Ste"), but users can specify the list of theoretical variograms by referring gstat::vgm. |
kappa |
numeric vector. Kappa values tested for Matern-family variogram models. |
fix.values |
numeric vector. Initial values in order of nugget, range, and sill, respectively. |
tlags |
integer vector (increasing, preferably to be consecutive). temporal lags. |
cutoff |
numeric. The maximum distance at which the sample variogram will be computed. |
width |
numeric. The interval at which the variogram cloud will be summarized. |
nmax |
integer or positive infinite. The maximum number of spatiotemporal neighbors to conduct the local spatiotemporal Kriging. |
aniso_method |
character. One of 'vgm', 'linear', 'range', and 'metric'. Please refer to ?gstat::estiStAni. |
type_joint |
character. The model form of joint spatiotemporal variogram. |
prodsum_k |
numeric. The parameter for the case when 'productSum' is chosen for type_stv. |
surface |
logical. If TRUE, also return variogram surface in fitting path. |
start_vals |
numeric vector (3). The initial values to optimize the spatiotemporal variogram model. |
miscFitOptions |
list. See ?automap::autofitVariogram. |
measurement_error |
numeric vector of length 3: spatial, temporal, and joint measurement error terms. |
cores |
integer. The number of threads that will be used to compute the sample spatiotemporal variogram. |
seed |
integer. Random seed for fold generation. |
variogram_from_full |
logical. If TRUE, fit one ST variogram on full data and reuse across folds. |
optimizer |
character. Optimization method passed to ST variogram fitting. |
objective |
character. Objective for ST variogram fitting ('WLS' or 'MLE'). |
n_restart |
integer. Number of restarts for optimizer = 'lbfgsb'. |
optimizer_control |
list. Extra control options forwarded to the selected optimizer. |
The cross-validated spatiotemporal Kriging results.
library(sp) library(gstat) library(spacetime) library(stars) library(dplyr) data(air) deair <- STFDF(stations, dates, data.frame(PM10 = as.vector(air))) deair_sf <- st_as_stars(deair, crs = "+proj=longlat +ellps=sphere") deair_sf <- st_transform(deair_sf, 3857) deair_r <- as(deair_sf, "STFDF") deair_r@sp@proj4string <- CRS("EPSG:3857") deair_rs <- deair_r[, 3751:3800] ## autoKrigeST.cv test ## Not run: akst_cv_t <- autoKrigeST.cv( formula = PM10 ~ 1, data = deair_rs, nfold = 3, fold_dim = "temporal", cutoff = 300000, width = 30000, tlags = 0:7, cores = 8 ) akst_cv_s <- autoKrigeST.cv( formula = PM10 ~ 1, data = deair_rs, nfold = 3, fold_dim = "spatial", cutoff = 300000, width = 30000, tlags = 0:7, cores = 8 ) # akst_cv_r = autoKrigeST.cv(formula = PM10~1, data = deair_rs, nfold = 3, fold_dim = 'random', # cutoff = 300000, width = 30000, tlags = 0:7, cores = 8) akst_cv_spt <- autoKrigeST.cv( formula = PM10 ~ 1, data = deair_rs, nfold = 4, fold_dim = "spacetime", cutoff = 300000, width = 30000, tlags = 0:7, cores = 8 ) ## End(Not run)library(sp) library(gstat) library(spacetime) library(stars) library(dplyr) data(air) deair <- STFDF(stations, dates, data.frame(PM10 = as.vector(air))) deair_sf <- st_as_stars(deair, crs = "+proj=longlat +ellps=sphere") deair_sf <- st_transform(deair_sf, 3857) deair_r <- as(deair_sf, "STFDF") deair_r@sp@proj4string <- CRS("EPSG:3857") deair_rs <- deair_r[, 3751:3800] ## autoKrigeST.cv test ## Not run: akst_cv_t <- autoKrigeST.cv( formula = PM10 ~ 1, data = deair_rs, nfold = 3, fold_dim = "temporal", cutoff = 300000, width = 30000, tlags = 0:7, cores = 8 ) akst_cv_s <- autoKrigeST.cv( formula = PM10 ~ 1, data = deair_rs, nfold = 3, fold_dim = "spatial", cutoff = 300000, width = 30000, tlags = 0:7, cores = 8 ) # akst_cv_r = autoKrigeST.cv(formula = PM10~1, data = deair_rs, nfold = 3, fold_dim = 'random', # cutoff = 300000, width = 30000, tlags = 0:7, cores = 8) akst_cv_spt <- autoKrigeST.cv( formula = PM10 ~ 1, data = deair_rs, nfold = 4, fold_dim = "spacetime", cutoff = 300000, width = 30000, tlags = 0:7, cores = 8 ) ## End(Not run)
Create new spatial data for interpolation
create_new_data(obj, gen_mode = "chull", npoints = 10000, return_class = "sf")create_new_data(obj, gen_mode = "chull", npoints = 10000, return_class = "sf")
obj |
A Spatial*DataFrame. |
gen_mode |
character. One of 'rect' (rectangular) and 'chull' (convex hull). |
npoints |
integer. the number of points that will be generated |
return_class |
character(1). One of 'sf' and 'sp' |
A sf (return_class == 'sf') or SpatialPointsDataFrame (return_class == 'sp').
Generate a new spatiotemporal points for the spatiotemporal prediction and interpolation
create_new_data.ST(obj, form, gen_mode = "chull", npoints = 10000, forward = 6)create_new_data.ST(obj, form, gen_mode = "chull", npoints = 10000, forward = 6)
obj |
a sftime object. |
form |
formula. |
gen_mode |
character. The type of shape by the surface is generated. One of 'rect' (rectangular) and 'chull' (convex hull). |
npoints |
integer. the number of points that will be generated |
forward |
integer. the time length of the data will generate ahead of the last time point of the input data. If NULL is passed, the spatiotemporal interpolation mode in obj will be conducted. |
A sftime object.
Generate a new spatiotemporal points for the spatiotemporal prediction and interpolation (legacy sp)
create_new_data.ST.legacy( obj, form, gen_mode = "chull", npoints = 10000, forward = 6 )create_new_data.ST.legacy( obj, form, gen_mode = "chull", npoints = 10000, forward = 6 )
obj |
a ST*DF object. |
form |
formula. |
gen_mode |
character. One of 'rect' (rectangular) and 'chull' (convex hull). |
npoints |
integer. the number of points that will be generated |
forward |
integer. the time length of the data will generate ahead of the last time point of the input data. If NULL is passed, the spatiotemporal interpolation mode in obj will be conducted. |
A STFDF object.
Handles both nested and temporal faces of a cubble object. The
resulting sftime has one row per (location × time) observation with
the spatial geometry attached to every row.
cubble_to_sftime(x, time_col = NULL, key_col = NULL)cubble_to_sftime(x, time_col = NULL, key_col = NULL)
x |
A |
time_col |
Character. Name of the time column in the temporal face.
If |
key_col |
Character. Name of the site identifier column shared by the
spatial and temporal faces. Detected automatically from
|
An sftime object with a geometry column (sfc_POINT).
Autodetect the temporal unit
detect_temporal_unit(temporal)detect_temporal_unit(temporal)
temporal |
xts object. |
A character that indicates the temporal unit of the input xts object.
Autodetect the temporal unit in a lubridate/POSIXct object
detect_temporal_unit.generic(temporal)detect_temporal_unit.generic(temporal)
temporal |
a lubridate/POSIXct object. |
A character that indicates the temporal unit of the input xts object.
Autodetect the temporal unit in a xts object
detect_temporal_unit.xts(temporal)detect_temporal_unit.xts(temporal)
temporal |
a xts object. |
A character that indicates the temporal unit of the input xts object.
Derives nugget, partial sill, spatial range, and temporal range directly from the empirical spatio-temporal variogram instead of relying on fixed arithmetic heuristics. The approach is:
estimate_initial_params( stva_emp, nugget_quantile = 0.25, sill_quantile = 0.95, practical_range_target = 0.95 )estimate_initial_params( stva_emp, nugget_quantile = 0.25, sill_quantile = 0.95, practical_range_target = 0.95 )
stva_emp |
An empirical |
nugget_quantile |
Numeric in (0, 1). Quantile of near-zero-lag gamma used as the nugget estimate. Default 0.25 (lower quartile of the first decile of spatial bins). |
sill_quantile |
Numeric in (0, 1). Quantile of the spatial-marginal gamma values used as the plateau estimate. Default 0.95. |
practical_range_target |
Numeric in (0, 1). Fraction of the sill at which the practical range is read off. Default 0.95. |
Nugget — median over the first decile of
spatial lags (extrapolation toward zero-lag).
Sill — 95th percentile of values over all
spatial lags at the minimum time lag (spatial marginal plateau).
Spatial practical range — smallest spatial lag at which the spatial marginal exceeds 95% of the estimated sill; falls back to 50% of the maximum spatial lag when the variogram never reaches the sill within the sampling window.
Temporal practical range — same rule applied to the temporal marginal at the minimum spatial lag.
A named list:
Estimated nugget (>= 0).
Estimated partial sill (sill - nugget, >= 0).
Estimated total sill.
Estimated spatial practical range.
Estimated temporal practical range.
Maximum observed gamma.
Maximum spatial lag in the empirical variogram.
Maximum temporal lag (numeric).
A named wrapper around autofitVariogramST that makes the
fit/predict separation explicit. Returns a STVariogramFit object
which can be passed directly to predictKrigeST.
fitVariogramST(formula, data, ...)fitVariogramST(formula, data, ...)
formula |
A formula (e.g. |
data |
A spatio-temporal data object (STFDF, STSDF, STIDF, or sftime). |
... |
Arguments forwarded to |
A STVariogramFit object.
Compute AIC and BIC for a fitted STVariogramFit (MLE-based)
ic_stv(fit_obj, n_obs)ic_stv(fit_obj, n_obs)
fit_obj |
A |
n_obs |
Integer. Number of observations used for fitting. |
A named list: AIC, BIC, k (number of free
parameters), loglik.
Compute the marginal spatial or temporal sample variogram
marginal.variogramST(stv, bound, spatial = TRUE)marginal.variogramST(stv, bound, spatial = TRUE)
stv |
A StVariogram and data.frame object. |
bound |
numeric. The maximum distance that will be used to compute a spatial variogram. |
spatial |
boolean. if TRUE, the spatial marginal variogram will be obtained, temporal otherwise. |
A gstatVariogram object.
Evaluates gstat::estiStAni at a sequence of spatial intervals and
plots how the estimated anisotropy ratio varies. Useful for diagnosing
whether the single-interval estimate used in autofitVariogramST is
stable.
plot_aniso_sensitivity( stva_emp, spatial_vgm, temporal_vgm, n_intervals = 20L, plot = TRUE )plot_aniso_sensitivity( stva_emp, spatial_vgm, temporal_vgm, n_intervals = 20L, plot = TRUE )
stva_emp |
Empirical ST variogram from |
spatial_vgm |
Fitted spatial marginal variogram model. |
temporal_vgm |
Fitted temporal marginal variogram model. |
n_intervals |
Integer. Number of evaluation intervals. |
plot |
Logical. Whether to produce a base-R plot. |
Invisibly, a data.frame with columns interval and
stAni.
Plot the automatically fitted variogram
## S3 method for class 'autofitVariogram' plot( x, plotit = TRUE, title = "Experimental variogram and fitted variogram model", ... )## S3 method for class 'autofitVariogram' plot( x, plotit = TRUE, title = "Experimental variogram and fitted variogram model", ... )
x |
A result object of autofitVariogram. |
plotit |
boolean. Print graph or not. |
title |
character. the title of the plot. |
... |
passed to xyplot |
A lattice::xyplot object.
Takes a STVariogramFit object (from fitVariogramST or
autofitVariogramST) and performs spatiotemporal Kriging at the
locations in newdata.
predictKrigeST( fit, data, newdata, formula, nmax = Inf, predict_chunk = NULL, ... )predictKrigeST( fit, data, newdata, formula, nmax = Inf, predict_chunk = NULL, ... )
fit |
A |
data |
The original data used to fit the variogram (STFDF, STSDF, STIDF, or sftime). |
newdata |
Prediction grid (STFDF or sftime). |
formula |
Formula used during fitting. |
nmax |
Passed to |
predict_chunk |
Optional integer; splits |
... |
Additional arguments forwarded to |
An autoKrigeST object (list) with elements krige_output
(STFDF) and var_model.
Fits multiple ST covariance model types and ranks them by a user-chosen criterion.
selectModelST( stf, formula, candidates = c("separable", "productSum", "sumMetric", "simpleSumMetric", "metric"), criterion = c("WLS", "AIC", "BIC"), optimizer = "lbfgsb", cores = 1L, ... )selectModelST( stf, formula, candidates = c("separable", "productSum", "sumMetric", "simpleSumMetric", "metric"), criterion = c("WLS", "AIC", "BIC"), optimizer = "lbfgsb", cores = 1L, ... )
stf |
A spatio-temporal data object (STFDF, STSDF, STIDF, or sftime). |
formula |
A formula (e.g., |
candidates |
Character vector of ST model types to try. Defaults to all six supported types. |
criterion |
One of |
optimizer |
Passed to |
cores |
Passed to |
... |
Additional arguments forwarded to |
An STModelSelection object (list) with elements
best_model, comparison (data.frame), and all_fits.
A convenience function for the sample spatiotemporal variogram
setSTI( stf, formula, tlags = 0:6, cutoff = 30000, width = 1000, assumeRegular = FALSE, pseudo = TRUE, na.omit = TRUE, wireframe = FALSE, plot3d = FALSE, cores = 1 )setSTI( stf, formula, tlags = 0:6, cutoff = 30000, width = 1000, assumeRegular = FALSE, pseudo = TRUE, na.omit = TRUE, wireframe = FALSE, plot3d = FALSE, cores = 1 )
stf |
A ST*DF object. |
formula |
formula (inherits the same parameter in variogramST) |
tlags |
temporal lags to compute semivariance (inherits the same parameter in variogramST) |
cutoff |
the maximum bound of the set of spatial lags (inherits the same parameter in variogramST) |
width |
integer (1). spatial lag (inherits the same parameter in variogramST) |
assumeRegular |
Boolean. Assuming regular grid? |
pseudo |
Boolean. See ?gstat::variogramST |
na.omit |
Boolean. Omit NA values. |
wireframe |
Boolean. Whether you plot a StVariogram in wireframe or not. If not, the return will be in class of data.frame, not a list |
plot3d |
Boolean. Wheter you make a three-dimensional graph with rgl package |
cores |
Integer. Number of threads passed to |
Depends on the arguments wireframe (if TRUE, list of length 2) and plot3d (if TRUE, list of length 3), a StVariogram object otherwise.
Compute parameter bounds for vgmST model optimisation
st_param_bounds( model_template, stva_emp, sill_scale = 2, range_scale = 3, ani_scale = 20 )st_param_bounds( model_template, stva_emp, sill_scale = 2, range_scale = 3, ani_scale = 20 )
model_template |
A |
stva_emp |
Empirical ST variogram ( |
sill_scale |
Numeric (2). Upper bound multiplier applied to
|
range_scale |
Numeric (3). Upper bound multiplier applied to the maximum spatial lag for range parameters. |
ani_scale |
Numeric (20). Controls the breadth of the stAni search interval relative to the data extent. |
A named list with elements lower and upper (both
named numeric vectors matching gstat::extractPar(model_template)).
Tests whether a separable covariance structure is adequate versus the more
general sumMetric model using a likelihood ratio test (LRT). Both models
are fitted with objective = "MLE".
test_separability(stf, formula, ...)test_separability(stf, formula, ...)
stf |
Spatio-temporal data (STFDF, STSDF, STIDF, or sftime). |
formula |
Formula, e.g. |
... |
Additional arguments forwarded to |
A list with elements:
LRT chi-squared statistic.
Degrees of freedom (difference in number of parameters).
p-value from chi-squared distribution.
Fitted STVariogramFit for the separable model.
Fitted STVariogramFit for the sumMetric model.