Description Usage Arguments Value Author(s) References See Also Examples
This function finds a spatial deformation for the coordinates of data from a Gaussian process. The deformation is based on the penalized fitting of a tensor product of B-spline basis functions.
1 2 3 4 5 |
x |
A n times 2 matrix of coordinates for the sampled data points. The rows must be unique, corresponding to distinct sample locations. Alternatively, a n times 3 matrix with the third column corresponding to time. The times must be in a regular grid and exist in all spatial locations (TODO generalize). |
y |
A vector of length n*m with the values taken by the response at the corresponding spatial locations in x, for each time point t_1, ..., t_m. |
tim |
A vector of equally spaced time positions, or NULL, in which the temporal component of the model is ignored. Defaults to NULL. Each time point must have the same corresponding locations as rows in x. |
cov.model |
A model for the spatial covariance function. See
|
type |
Method to fit the deformation model, a choice of "jacobian" (default), and "none" (no penalty). |
df1 |
Degrees of freedom for the tensor product of splines along the x[,1] coordinate. Defaults to 4. |
df2 |
Degrees of freedom for the tensor product of splines along the x[,2] coordinate. Defaults to 4. |
window |
A list with two named entries, "x" and "y", each a length 2 numeric vector with the minimum and maximum values taken for the respective coordinate in the sampled region. Defaults to the range of the columns in argument x. |
maxit |
The maximum number of iterations between optimization of the covariance parameters and estimation of the spline coefficients. Defaults to 2. |
traceback |
Whether the function will return each step of the optimization iterations, as a list. For debugging purposes. Defaults to FALSE. |
fullDes |
Whether the returned object will include a processed
copy of the dataset. Needed for the
|
iterate |
Keep iterating nonmetric multidimensional scaling using variogram function as transformation. Defaults to TRUE. Ignored if method = "likelihood". |
... |
Additional arguments for RFfit. |
bdef
returns an object of class
"bdef"
containing at least the following components
window |
The rectangular spatial domain in which the data was sampled |
basis |
list of B-spline basis functions, inherited from
|
theta1 |
B-spline coefficients for the coordinate x1 |
theta2 |
B-spline coefficients for the coordinate x2 |
Guilherme Ludwig and Ronaldo Dias
To add.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 | # Example using artificially generated data
set.seed(1)
m <- 10
x1 <- (0:m)/m
x2 <- (0:m)/m
x <- as.matrix(expand.grid(x1,x2))
n <- nrow(x)
F1 <- function(x1,x2, a = 2.5, b = 1.0) {
x <- x1 - 0.5; y <- x2 - 0.5
angle <- a*exp(-(x*x+y*y)/(b*b)) + 3*pi/2
return(cos(angle)*x + sin(angle)*y + 0.5)
}
F2 <- function(x1,x2, a = 2.5, b = 1.0) {
x <- x1 - 0.5; y <- x2 - 0.5
angle <- a*exp(-(x*x+y*y)/(b*b)) + 3*pi/2
return(-sin(angle)*x + cos(angle)*y + 0.5)
}
TIME <- 20
covModel <- RMexp(var = 1, scale = .25) + RMnugget(var = 1) # Independent in time
data <- RFsimulate(covModel, x = F1(x[,1],x[,2]), y = F2(x[,1],x[,2]),
T = seq(from = 1, by = 1, len = TIME)) # order ~ expand.grid(x, y, T)
y <- as.numeric(unlist(data@data))
# Model for spatial dependence, time is assumed independent
covModelM <- RMexp(var = NA, scale = NA) + RMnugget(var = NA)
# No deformation reference, entries are independent in time
test.nondef <- RFfit(covModelM, x = x[,1], y = x[,2],
# T = seq(from = 1, by = 1, len = TIME), # slow?
# data = y)
data = matrix(y, ncol = TIME))
# Calculates deformation, profle likelihood up to maxit times
test.def <- bdef(x, y, tim = 1:TIME, cov.model = covModelM, maxit = 10)
# Estimated deformation
plotGrid(test.def)
# Comparison of Variograms
plot(test.nondef, ylim = c(0,2), xlim = c(0,0.7),
model = list(`true model` = RMexp(var = 1, scale = .25) + RMnugget(var = 1)))
plot(test.def$model, ylim = c(0,2), xlim = c(0,0.7),
model = list(`true model` = RMexp(var = 1, scale = .25) + RMnugget(var = 1)))
## Not run:
test.def2 <- bdef(x, y, tim = 1:TIME, cov.model = covModelM, maxit = 10, iterate = TRUE)
# Estimated deformation
plotGrid(test.def2)
# Comparison of Variograms
plot(test.def2$model, ylim = c(0,2), xlim = c(0,0.7),
model = list(`true model` = RMexp(var = 1, scale = .25) + RMnugget(var = 1)))
## End(Not run)
|
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.