Title: | Automatic Fixed Rank Kriging |
---|---|
Description: | Automatic fixed rank kriging for (irregularly located) spatial data using a class of basis functions with multi-resolution features and ordered in terms of their resolutions. The model parameters are estimated by maximum likelihood (ML) and the number of basis functions is determined by Akaike's information criterion (AIC). For spatial data with either one realization or independent replicates, the ML estimates and AIC are efficiently computed using their closed-form expressions when no missing value occurs. Details regarding the basis function construction, parameter estimation, and AIC calculation can be found in Tzeng and Huang (2018) <doi:10.1080/00401706.2017.1345701>. For data with missing values, the ML estimates are obtained using the expectation- maximization algorithm. Apart from the number of basis functions, there are no other tuning parameters, making the method fully automatic. Users can also include a stationary structure in the spatial covariance, which utilizes 'LatticeKrig' package. |
Authors: | ShengLi Tzeng [aut, cre], Hsin-Cheng Huang [aut], Wen-Ting Wang [ctb], Douglas Nychka [ctb], Colin Gillespie [ctb] |
Maintainer: | ShengLi Tzeng <[email protected]> |
License: | GPL (>= 2) |
Version: | 1.4.3 |
Built: | 2024-11-06 04:11:53 UTC |
Source: | https://github.com/cran/autoFRK |
This function performs resolution adaptive fixed rank kriging based on spatial data observed at one or multiple time points via the following spatial random-effects model:
where is an n-vector of (partially) observed data at n locations,
is an n-vector of deterministic mean values,
is a given n by n matrix,
is a given n by K matrix,
is an n-vector of random variables corresponding to a spatial stationary process,
and
is a K-vector of unobservable random weights.
Parameters are estimated by maximum likelihood in a closed-form expression. The matrix
corresponding to basis functions is
given by an ordered class of thin-plate spline functions, with the number of basis functions
selected by Akaike's information criterion.
autoFRK( Data, loc, mu = 0, D = diag.spam(NROW(Data)), G = NULL, finescale = FALSE, maxit = 50, tolerance = 0.1^6, maxK = NULL, Kseq = NULL, method = c("fast", "EM"), n.neighbor = 3, maxknot = 5000 )
autoFRK( Data, loc, mu = 0, D = diag.spam(NROW(Data)), G = NULL, finescale = FALSE, maxit = 50, tolerance = 0.1^6, maxK = NULL, Kseq = NULL, method = c("fast", "EM"), n.neighbor = 3, maxknot = 5000 )
Data |
n by T data matrix (NA allowed) with
|
loc |
n by d matrix of coordinates corresponding to n locations. |
mu |
n-vector or scalar for |
D |
n by n matrix (preferably sparse) for the covariance matrix of the measurement errors up to a constant scale. Default is an identity matrix. |
G |
n by K matrix of basis function values with each column being a basis function taken values at |
finescale |
logical; if |
maxit |
maximum number of iterations. Default is 50. |
tolerance |
precision tolerance for convergence check. Default is 0.1^6. |
maxK |
maximum number of basis functions considered. Default is
|
Kseq |
user-specified vector of numbers of basis functions considered. Default is
|
method |
"fast" or " EM"; if "fast" then the missing data are filled in using k-nearest-neighbor imputation; if "EM" then the missing data are taken care by the EM algorithm. Default is "fast". |
n.neighbor |
number of neighbors to be used in the "fast" imputation method. Default is 3. |
maxknot |
maximum number of knots to be used in generating basis functions. Default is 5000. |
The function computes the ML estimate of M using the closed-form expression in Tzeng and Huang (2018).
If the user would like to specify
a D
other than an identity matrix for a large n, it is better to provided via spam
function
in spam
package.
an object of class FRK
is returned, which is a list of the following components:
M |
ML estimate of |
s |
estimate for the scale parameter of measurement errors. |
negloglik |
negative log-likelihood. |
w |
K by T matrix with |
V |
K by K matrix of the prediction error covariance matrix of |
G |
user specified basis function matrix or an automatically generated |
LKobj |
a list from calling |
ShengLi Tzeng and Hsin-Cheng Huang.
Tzeng, S., & Huang, H.-C. (2018). Resolution Adaptive Fixed Rank Kriging, Technometrics, https://doi.org/10.1080/00401706.2017.1345701.
#### generating data from two eigenfunctions originalPar <- par(no.readonly = TRUE) set.seed(0) n <- 150 s <- 5 grid1 <- grid2 <- seq(0, 1, l = 30) grids <- expand.grid(grid1, grid2) fn <- matrix(0, 900, 2) fn[, 1] <- cos(sqrt((grids[, 1] - 0)^2 + (grids[, 2] - 1)^2) * pi) fn[, 2] <- cos(sqrt((grids[, 1] - 0.75)^2 + (grids[, 2] - 0.25)^2) * 2 * pi) #### single realization simulation example w <- c(rnorm(1, sd = 5), rnorm(1, sd = 3)) y <- fn %*% w obs <- sample(900, n) z <- y[obs] + rnorm(n) * sqrt(s) X <- grids[obs, ] #### method1: automatic selection and prediction one.imat <- autoFRK(Data = z, loc = X, maxK = 15) yhat <- predict(one.imat, newloc = grids) #### method2: user-specified basis functions G <- mrts(X, 15) Gpred <- predict(G, newx = grids) one.usr <- autoFRK(Data = z, loc = X, G = G) yhat2 <- predict(one.usr, newloc = grids, basis = Gpred) require(fields) par(mfrow = c(2, 2)) image.plot(matrix(y, 30, 30), main = "True") points(X, cex = 0.5, col = "grey") image.plot(matrix(yhat$pred.value, 30, 30), main = "Predicted") points(X, cex = 0.5, col = "grey") image.plot(matrix(yhat2$pred.value, 30, 30), main = "Predicted (method 2)") points(X, cex = 0.5, col = "grey") plot(yhat$pred.value, yhat2$pred.value, mgp = c(2, 0.5, 0)) par(originalPar) #### end of single realization simulation example #### independent multi-realization simulation example set.seed(0) wt <- matrix(0, 2, 20) for (tt in 1:20) wt[, tt] <- c(rnorm(1, sd = 5), rnorm(1, sd = 3)) yt <- fn %*% wt obs <- sample(900, n) zt <- yt[obs, ] + matrix(rnorm(n * 20), n, 20) * sqrt(s) X <- grids[obs, ] multi.imat <- autoFRK(Data = zt, loc = X, maxK = 15) Gpred <- predict(multi.imat$G, newx = grids) G <- multi.imat$G Mhat <- multi.imat$M dec <- eigen(G %*% Mhat %*% t(G)) fhat <- Gpred %*% Mhat %*% t(G) %*% dec$vector[, 1:2] par(mfrow = c(2, 2)) image.plot(matrix(fn[, 1], 30, 30), main = "True Eigenfn 1") image.plot(matrix(fn[, 2], 30, 30), main = "True Eigenfn 2") image.plot(matrix(fhat[, 1], 30, 30), main = "Estimated Eigenfn 1") image.plot(matrix(fhat[, 2], 30, 30), main = "Estimated Eigenfn 2") par(originalPar) #### end of independent multi-realization simulation example
#### generating data from two eigenfunctions originalPar <- par(no.readonly = TRUE) set.seed(0) n <- 150 s <- 5 grid1 <- grid2 <- seq(0, 1, l = 30) grids <- expand.grid(grid1, grid2) fn <- matrix(0, 900, 2) fn[, 1] <- cos(sqrt((grids[, 1] - 0)^2 + (grids[, 2] - 1)^2) * pi) fn[, 2] <- cos(sqrt((grids[, 1] - 0.75)^2 + (grids[, 2] - 0.25)^2) * 2 * pi) #### single realization simulation example w <- c(rnorm(1, sd = 5), rnorm(1, sd = 3)) y <- fn %*% w obs <- sample(900, n) z <- y[obs] + rnorm(n) * sqrt(s) X <- grids[obs, ] #### method1: automatic selection and prediction one.imat <- autoFRK(Data = z, loc = X, maxK = 15) yhat <- predict(one.imat, newloc = grids) #### method2: user-specified basis functions G <- mrts(X, 15) Gpred <- predict(G, newx = grids) one.usr <- autoFRK(Data = z, loc = X, G = G) yhat2 <- predict(one.usr, newloc = grids, basis = Gpred) require(fields) par(mfrow = c(2, 2)) image.plot(matrix(y, 30, 30), main = "True") points(X, cex = 0.5, col = "grey") image.plot(matrix(yhat$pred.value, 30, 30), main = "Predicted") points(X, cex = 0.5, col = "grey") image.plot(matrix(yhat2$pred.value, 30, 30), main = "Predicted (method 2)") points(X, cex = 0.5, col = "grey") plot(yhat$pred.value, yhat2$pred.value, mgp = c(2, 0.5, 0)) par(originalPar) #### end of single realization simulation example #### independent multi-realization simulation example set.seed(0) wt <- matrix(0, 2, 20) for (tt in 1:20) wt[, tt] <- c(rnorm(1, sd = 5), rnorm(1, sd = 3)) yt <- fn %*% wt obs <- sample(900, n) zt <- yt[obs, ] + matrix(rnorm(n * 20), n, 20) * sqrt(s) X <- grids[obs, ] multi.imat <- autoFRK(Data = zt, loc = X, maxK = 15) Gpred <- predict(multi.imat$G, newx = grids) G <- multi.imat$G Mhat <- multi.imat$M dec <- eigen(G %*% Mhat %*% t(G)) fhat <- Gpred %*% Mhat %*% t(G) %*% dec$vector[, 1:2] par(mfrow = c(2, 2)) image.plot(matrix(fn[, 1], 30, 30), main = "True Eigenfn 1") image.plot(matrix(fn[, 2], 30, 30), main = "True Eigenfn 2") image.plot(matrix(fhat[, 1], 30, 30), main = "Estimated Eigenfn 1") image.plot(matrix(fhat[, 2], 30, 30), main = "Estimated Eigenfn 2") par(originalPar) #### end of independent multi-realization simulation example
This function generates multi-resolution thin-plate spline basis functions. The basis functions are (descendingly) ordered in terms of their degrees of smoothness with a higher-order function corresponding to larger-scale features and a lower-order one corresponding to smaller-scale details. They are useful in the spatio-temporal random effects model.
mrts(knot, k, x = NULL, maxknot = 5000)
mrts(knot, k, x = NULL, maxknot = 5000)
knot |
m by d matrix (d<=3) for m locations of d-dimensional knots as in ordinary splines. Missing values are not allowed. |
k |
the number (<=m) of basis functions. |
x |
n by d matrix of coordinates corresponding to n locations where the values of basis functions to be evaluated.
Default is |
maxknot |
maximum number of knots to be used in generating basis functions. If |
An mrts
object is generated. If x=NULL
(default) it returns
an m by k matrix of k basis function taken values at knots.
With x
given, it returns n by k matrix for basis functions taken values at x
.
ShengLi Tzeng and Hsin-Cheng Huang.
Tzeng, S., & Huang, H. C. (2018). Resolution Adaptive Fixed Rank Kriging. Technometrics, https://doi.org/10.1080/00401706.2017.1345701. Tzeng, S., & Huang, H. C. (2015). Multi-Resolution Spatial Random-Effects Models for Irregularly Spaced Data. arXiv preprint arXiv:1504.05659.
originalPar <- par(no.readonly = TRUE) knot <- seq(0, 1, l = 30) b <- mrts(knot, 30) x0 <- seq(0, 1, l = 200) bx <- predict(b, x0) par(mfrow = c(5, 6), mar = c(0, 0, 0, 0)) for (i in 1:30) { plot(bx[, i], type = "l", axes = FALSE) box() } par(originalPar)
originalPar <- par(no.readonly = TRUE) knot <- seq(0, 1, l = 30) b <- mrts(knot, 30) x0 <- seq(0, 1, l = 200) bx <- predict(b, x0) par(mfrow = c(5, 6), mar = c(0, 0, 0, 0)) for (i in 1:30) { plot(bx[, i], type = "l", axes = FALSE) box() } par(originalPar)
Predicted values and estimate of standard errors based on an "autoFRK
" model object.
## S3 method for class 'FRK' predict( object, obsData = NULL, obsloc = NULL, mu.obs = 0, newloc = obsloc, basis = NULL, mu.new = 0, se.report = FALSE, ... )
## S3 method for class 'FRK' predict( object, obsData = NULL, obsloc = NULL, mu.obs = 0, newloc = obsloc, basis = NULL, mu.new = 0, se.report = FALSE, ... )
object |
a model object obtained from " |
obsData |
a vector with observed data used for prediction.
Default is |
obsloc |
a matrix with rows being coordinates of observation locations for |
mu.obs |
a vector or scalar for the deterministic mean values at |
newloc |
a matrix with rows being coordinates of new locations for prediction.
Default is |
basis |
a matrix with each column being a basis function taken values at |
mu.new |
a vector or scalar for the deterministic mean values at |
se.report |
logical; if |
... |
not used but needed for the S3 generic/method compatibility. |
A list with the components described below.
pred.value |
a matrix with the (i,t) element being the predicted value at i-th location and time t. |
se |
a vector with the i-th element being the standard error of the predicted value at the i-th location. |
ShengLi Tzeng and Hsin-Cheng Huang.
Evaluate multi-resolution thin-plate spline basis functions at given locations.
This function provides a generic prediction method for mrts
objects,
in a similar way as predict.ns
and predict.bs
in splines
package.
## S3 method for class 'mrts' predict(object, newx, ...)
## S3 method for class 'mrts' predict(object, newx, ...)
object |
object produced from calling mrts. |
newx |
an n by d matrix of coordinates corresponding to n locations. |
... |
not used but needed for the S3 generic/method compatibility. |
an n by k matrix of the k basis function in object
taken values at newx
.
ShengLi Tzeng and Hsin-Cheng Huang.