| Title: | Multi-Resolution Thin-Plate Splines on the Sphere |
|---|---|
| Description: | Constructs multi-resolution thin-plate spline (MRTS) basis functions on the sphere and fits the corresponding multi-resolution mixed model (MRMM) by generalised least squares with a tapered Matérn residual covariance, including kriging-style prediction with closed-form standard errors. Implements the system described in Huang, Huang, and Ing (2025) "Multi-Resolution Spatial Methods on the Sphere: Efficient Prediction for Global Data", Environmetrics, <doi:10.1002/env.70092>. Heavy basis computations are written in 'C++' via 'Rcpp' with optional 'OpenMP' parallelism. |
| Authors: | Hao-Yun Huang [aut, cre] (ORCID: <https://orcid.org/0009-0004-8384-3261>), Hsin-Cheng Huang [aut] (ORCID: <https://orcid.org/0000-0002-5613-349X>), Ching-Kang Ing [aut] (ORCID: <https://orcid.org/0000-0003-1362-8246>) |
| Maintainer: | Hao-Yun Huang <[email protected]> |
| License: | GPL (>= 2) |
| Version: | 0.2.0 |
| Built: | 2026-05-31 07:09:24 UTC |
| Source: | https://github.com/stlabtw/multi-resolution-sphere |
Combines the mrts_sphere() basis with a tapered Matérn residual
covariance and obtains the basis coefficients by generalised least
squares (GLS).
mrmm_fit( z, loc, knots, k, taper_range, matern_range, sill, nugget, smoothness = 0.5 )mrmm_fit( z, loc, knots, k, taper_range, matern_range, sill, nugget, smoothness = 0.5 )
z |
Numeric vector of observations at the training locations. |
loc |
Two-column numeric matrix of |
knots |
Two-column numeric matrix of |
k |
Integer. Number of MRTS basis functions to use
( |
taper_range |
Wendland compact-support range |
matern_range |
Matérn range parameter |
sill |
Sill of the structured residual component
( |
nugget |
Nugget variance ( |
smoothness |
Matérn smoothness |
Given training observations at locations
on the sphere, the model is
where is the MRTS basis at location and
is the tapered-Matérn covariance built by
tapered_matern_sphere() using the user-supplied parameters. The
GLS estimate
is computed via a Cholesky factorisation of . Predictions
(mean and standard error) at new locations are obtained with
predict.mrmm().
Covariance parameters must be supplied. A separate parameter-estimation
routine (mrmm_estimate_params()) is planned for a future release.
An object of class "mrmm": a list with components
coefficientsGLS estimate , length k.
fitted, residuals
Fitted values and residuals at the training locations.
coef_covThe matrix , used by
predict.mrmm() for standard errors.
sigma_cholUpper-triangular Cholesky factor of
at the training locations.
basis_train, train_loc, train_z
Stored training basis, locations, and observations.
knots, k, params, call
Inputs preserved on the fit.
Huang, H.-Y., Huang, H.-C., and Ing, C.-K. (2025). Multi-Resolution Spatial Methods on the Sphere: Efficient Prediction for Global Data. Environmetrics. doi:10.1002/env.70092
predict.mrmm(), mrts_sphere(),
tapered_matern_sphere().
set.seed(1) n <- 80 loc <- cbind(runif(n, -60, 60), runif(n, -180, 180)) z <- 2 + sin(loc[, 1] * pi / 180) + rnorm(n, sd = 0.3) knots <- loc[sample.int(n, 30), ] fit <- mrmm_fit(z = z, loc = loc, knots = knots, k = 8, taper_range = 1.0, matern_range = 0.2, sill = 0.5, nugget = 0.1, smoothness = 0.5) fit length(fit$coefficients) # kset.seed(1) n <- 80 loc <- cbind(runif(n, -60, 60), runif(n, -180, 180)) z <- 2 + sin(loc[, 1] * pi / 180) + rnorm(n, sd = 0.3) knots <- loc[sample.int(n, 30), ] fit <- mrmm_fit(z = z, loc = loc, knots = knots, k = 8, taper_range = 1.0, matern_range = 0.2, sill = 0.5, nugget = 0.1, smoothness = 0.5) fit length(fit$coefficients) # k
Builds a set of k multi-resolution thin-plate spline (MRTS) basis
functions on the sphere from a set of knot locations, and evaluates
them at the prediction locations X.
mrts_sphere(knot, k, X)mrts_sphere(knot, k, X)
knot |
Numeric matrix with two columns giving knot locations as
|
k |
Integer. Number of basis functions to construct (the rank of
the basis). Must satisfy |
X |
Numeric matrix with two columns giving prediction locations
as |
The first basis function is constant (sqrt(1/n)); the remaining
k - 1 basis functions are obtained from the eigen-decomposition of
the centered knot kernel matrix, following the construction described
in the reference.
A list with one element:
mrtsAn nrow(X) x k numeric matrix whose columns are the
basis functions evaluated at the rows of X.
Multi-resolution approximations of Gaussian processes for large spatial datasets on the sphere. Environmetrics, 2025. doi:10.1002/env.70092
## Build a small global grid in (lat, lon) degrees. n_lon <- 12 n_lat <- 8 lon_seq <- seq(-180, 150, length.out = n_lon) lat_seq <- seq( -80, 80, length.out = n_lat) grid <- as.matrix(expand.grid(lat = lat_seq, lon = lon_seq)) ## Pick 30 knots and evaluate the MRTS basis at every grid point. set.seed(1) knots <- grid[sample(nrow(grid), 30), ] res <- mrts_sphere(knots, k = 5, X = grid) dim(res$mrts) # nrow(grid) x k ## Recovering a simulated spherical exponential field with the basis. if (requireNamespace("fields", quietly = TRUE)) { # Great-circle distance (km) -> exponential covariance. d_grid <- fields::rdist.earth(grid[, 2:1], miles = FALSE) cov_field <- exp(-d_grid / 2000) y_true <- as.numeric(t(chol(cov_field + diag(1e-8, nrow(grid)))) %*% rnorm(nrow(grid))) # Noisy observations at the knot locations. obs_idx <- match(data.frame(t(knots)), data.frame(t(grid))) z_obs <- y_true[obs_idx] + rnorm(nrow(knots), sd = 0.3) # Project into the MRTS basis (least squares) and predict on the grid. B_obs <- res$mrts[obs_idx, , drop = FALSE] beta_hat <- qr.solve(B_obs, z_obs) y_hat <- res$mrts %*% beta_hat sqrt(mean((y_hat - y_true)^2)) # RMSE }## Build a small global grid in (lat, lon) degrees. n_lon <- 12 n_lat <- 8 lon_seq <- seq(-180, 150, length.out = n_lon) lat_seq <- seq( -80, 80, length.out = n_lat) grid <- as.matrix(expand.grid(lat = lat_seq, lon = lon_seq)) ## Pick 30 knots and evaluate the MRTS basis at every grid point. set.seed(1) knots <- grid[sample(nrow(grid), 30), ] res <- mrts_sphere(knots, k = 5, X = grid) dim(res$mrts) # nrow(grid) x k ## Recovering a simulated spherical exponential field with the basis. if (requireNamespace("fields", quietly = TRUE)) { # Great-circle distance (km) -> exponential covariance. d_grid <- fields::rdist.earth(grid[, 2:1], miles = FALSE) cov_field <- exp(-d_grid / 2000) y_true <- as.numeric(t(chol(cov_field + diag(1e-8, nrow(grid)))) %*% rnorm(nrow(grid))) # Noisy observations at the knot locations. obs_idx <- match(data.frame(t(knots)), data.frame(t(grid))) z_obs <- y_true[obs_idx] + rnorm(nrow(knots), sd = 0.3) # Project into the MRTS basis (least squares) and predict on the grid. B_obs <- res$mrts[obs_idx, , drop = FALSE] beta_hat <- qr.solve(B_obs, z_obs) y_hat <- res$mrts %*% beta_hat sqrt(mean((y_hat - y_true)^2)) # RMSE }
Computes kriging-style predictions and (optionally) prediction
standard errors at new spherical locations from an mrmm_fit()
object.
## S3 method for class 'mrmm' predict(object, newdata, se.fit = TRUE, ...)## S3 method for class 'mrmm' predict(object, newdata, se.fit = TRUE, ...)
object |
An object of class |
newdata |
Two-column numeric matrix of |
se.fit |
Logical; if |
... |
Currently unused. |
Given the GLS coefficient stored in object, the
prediction at a new location is
The prediction variance is the closed-form expression that arises in kriging with linear-trend basis (sometimes called "universal kriging"); see the reference.
A list with
fitNumeric vector of predicted values, one per row of
newdata.
se.fitNumeric vector of prediction standard errors (only
if se.fit = TRUE).
Huang, H.-Y., Huang, H.-C., and Ing, C.-K. (2025). Multi-Resolution Spatial Methods on the Sphere: Efficient Prediction for Global Data. Environmetrics. doi:10.1002/env.70092
set.seed(1) n <- 80 loc <- cbind(runif(n, -60, 60), runif(n, -180, 180)) z <- 2 + sin(loc[, 1] * pi / 180) + rnorm(n, sd = 0.3) knots <- loc[sample.int(n, 30), ] fit <- mrmm_fit(z = z, loc = loc, knots = knots, k = 8, taper_range = 1.0, matern_range = 0.2, sill = 0.5, nugget = 0.1) new_loc <- cbind(seq(-50, 50, length.out = 5), seq(-100, 100, length.out = 5)) p <- predict(fit, newdata = new_loc, se.fit = TRUE) p$fit p$se.fitset.seed(1) n <- 80 loc <- cbind(runif(n, -60, 60), runif(n, -180, 180)) z <- 2 + sin(loc[, 1] * pi / 180) + rnorm(n, sd = 0.3) knots <- loc[sample.int(n, 30), ] fit <- mrmm_fit(z = z, loc = loc, knots = knots, k = 8, taper_range = 1.0, matern_range = 0.2, sill = 0.5, nugget = 0.1) new_loc <- cbind(seq(-50, 50, length.out = 5), seq(-100, 100, length.out = 5)) p <- predict(fit, newdata = new_loc, se.fit = TRUE) p$fit p$se.fit
Builds a covariance matrix of the form
tapered_matern_sphere( loc1, loc2 = NULL, taper_range, matern_range, smoothness = 0.5, sill = 1, nugget = 0 )tapered_matern_sphere( loc1, loc2 = NULL, taper_range, matern_range, smoothness = 0.5, sill = 1, nugget = 0 )
loc1 |
Two-column numeric matrix of |
loc2 |
Optional second set of locations. If |
taper_range |
Compact-support range |
matern_range |
Range parameter |
smoothness |
Smoothness |
sill |
Marginal variance of the structured component. Must be non-negative. |
nugget |
Nugget variance, added on the diagonal when
|
where is the great-circle distance on the unit sphere
(radians), is the Matérn correlation with
range and smoothness , and is the
Wendland taper of compact support (degree
, dimension ). The nugget term is added only when
the matrix is symmetric, i.e. when loc2 = NULL.
An nrow(loc1) x nrow(loc2) numeric covariance matrix.
set.seed(1) loc <- cbind(runif(20, -60, 60), runif(20, -180, 180)) Sigma <- tapered_matern_sphere(loc, taper_range = 0.4, matern_range = 0.1, smoothness = 0.5, sill = 1.0, nugget = 0.05) isSymmetric(Sigma)set.seed(1) loc <- cbind(runif(20, -60, 60), runif(20, -180, 180)) Sigma <- tapered_matern_sphere(loc, taper_range = 0.4, matern_range = 0.1, smoothness = 0.5, sill = 1.0, nugget = 0.05) isSymmetric(Sigma)