contours | R Documentation |
Contours of a kriging function or statistic related to a kriging model object with two inputs. This can be the kriging mean, the kriging (conditional) standard deviation and more.
contours( object, which = "mean", other = NULL, lower = c(0, 0), upper = c(1, 1), nGrid = 50, grad = FALSE, otherGrad = NULL, whereGrad = "levels", ... )
object |
An object with class |
which |
Character vector. Name of the kriging
function(s)/statistic(s) to be shown. Can contain
|
other |
Character. Name of a function. This can be a function
to be compared to the stat(s) given in |
lower, upper |
Numeric vectors with length 2 definign the bounds of the rectangular region for the contours. |
nGrid |
Integer. Number of grid points. Can be of length 2 if different grids are to be used for the two dimensions. |
grad |
Logical. If |
otherGrad |
Character. Name of the gradient function of the
function given in |
whereGrad |
Either a character with length one or a data
frame or matrix with two columns. This defines the points at
which the gradient will be evaluated and plotted as a small
arrow in a vector-field fashion. The default is
|
... |
Not used yet. |
When several functions are given, they will be displayed on different facets of the plot. These functions should then have the same dimension because only one colour scale is used. For instance it makes no sense to give the mean and the variance which do not have the same dimension, nor even the mean and the standard deviation because these two functions may have different order of magnitude. We can usefully want the true function and the kriging mean, or the kriging mean and the kriging trend.
A graphical object inheriting from "ggplot"
.
set.seed(1521) n <- 9 design <- matrix(runif(n * 2), ncol = 2, dimnames = list(NULL, c("x1", "x2"))) design <- data.frame(design) y <- apply(design, 1, branin) model <- km(~1, design = design, response = y) ## Contours only ## ============= contours(model) + ggtitle("kriging mean (default in 'contours')") contours(model, other = "branin") + ggtitle("'branin' and kriging mean") contours(model, which = c("mean", "trend")) + ggtitle("Kriging mean and trend") contours(model, which = "sd") + ggtitle("Kriging sd") ## Display gradients ## ================= contours(model, which = "mean", grad = TRUE) + ggtitle("Kriging mean, gradients at contours") contours(model, which = "sd", grad = TRUE) + ggtitle("Kriging sd, gradients at contours") contours(model, which = "sd", grad = TRUE, whereGrad = "grid") + ggtitle("Kriging sd, gradients at grid points") ## more involved examples ## ====================== ## Not run: braninG <- function(x) branin_with_grad(x)$gradient contours(model, which = character(0), grad = TRUE, other = "branin", otherGrad = "braninG", whereGrad = "grid") + ggtitle("Branin function and its gradient") contours(model, which = character(0), grad = TRUE, other = "EI", otherGrad = "EI.grad", whereGrad = "grid") + ggtitle("Expected Improvement and its gradient") ## End(Not run)
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.