simulate, covAll-method {kergp} | R Documentation |
Simulation of a covAll
Object
Description
Simulation of a covAll
object.
Usage
## S4 method for signature 'covAll'
simulate(object, nsim = 1, seed = NULL,
X, mu = NULL, method = "mvrnorm", checkNames = TRUE,
...)
Arguments
object |
A covariance kernel object. |
nsim |
Number of simulated paths. |
seed |
Not used yet. |
X |
A matrix with the needed inputs as its columns. |
mu |
Optional vector with length |
method |
Character used to choose the simulation method. For now the only
possible value is |
checkNames |
Logical. It |
... |
Other arguments for methods. |
Value
A numeric matrix with nrow(X)
rows and nsim
columns.
Each column is the vector of the simulated path at the simulation
locations.
Note
The simulation is unconditional.
See Also
The mvrnorm
function.
Examples
## -- as in example(kergp) define an argumentwise invariant kernel --
kernFun <- function(x1, x2, par) {
h <- (abs(x1) - abs(x2)) / par[1]
S <- sum(h^2)
d2 <- exp(-S)
K <- par[2] * d2
d1 <- 2 * K * S / par[1]
attr(K, "gradient") <- c(theta = d1, sigma2 = d2)
return(K)
}
covSymGauss <- covMan(kernel = kernFun,
hasGrad = TRUE,
label = "argumentwise invariant",
d = 2,
parNames = c("theta", "sigma2"),
par = c(theta = 0.5, sigma2 = 2))
## -- simulate a path from the corresponding GP --
nGrid <- 24; n <- nGrid^2; d <- 2
xGrid <- seq(from = -1, to = 1, length.out = nGrid)
Xgrid <- expand.grid(x1 = xGrid, x2 = xGrid)
ySim <- simulate(covSymGauss, X = Xgrid)
contour(x = xGrid, y = xGrid,
z = matrix(ySim, nrow = nGrid, ncol = nGrid),
nlevels = 15)