Description Usage Arguments Value Note Author(s) Examples
Simulation of paths from a gp
object.
1 2 3 4 5 6 7 8 9 10 11 |
object |
An object with class |
nsim |
Number of paths wanted. |
seed |
Not used yet. |
newdata |
A data frame containing the inputs values used for simulation as
well as the required trend covariates, if any. This is similar to
the |
cond |
Logical. Should the simulations be conditional on the observations used in the object or not? |
trendKnown |
Logical. If |
newVarNoise |
Variance of the noise for the "new" simulated observations. For the
default |
nuggetSim |
Small positive number ("nugget") added to the diagonal of conditional covariance matrices before computing a Cholesky decomposition, for numerical lack of positive-definiteness. This may happen when the covariance kernel is not (either theoretically or numerically) positive definite. |
checkNames |
Logical. It |
output |
The type of output wanted. A simple matrix as in standard simulation methods may be quite poor, since interesting intermediate results are then lost. |
label, unit |
A label and unit that will be copied into the output object
when |
... |
Further arguments to be passed to the |
A matrix with the simulated paths as its columns or a more complete
list with more results. This list which is given the S3 class
"simulate.gp"
has the following elements.
X
, F
, y
Inputs,
trend covariates and response.
XNew
,
FNew
New inputs, new trend covariates.
sim
Matrix of simulated paths.
trend
Matrix of simulated trends.
trendKnown
, noise
, newVarNoise
Values of the formals.
Call
The call.
When betaKnown
is FALSE
, the trend and the
smooth GP parts of a simulation are usually correlated, and
their sum will show less dispersion than each of the two
components. The covariance of the vector
β can be regarded as the
posterior distribution corresponding to a non-informative prior, the
distribution from which a new path is drawn being the predictive
distribution.
Yves Deville
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 48 49 50 51 52 53 54 55 56 57 58 59 | set.seed(314159)
n <- 40
x <- sort(runif(n))
y <- 2 + 4 * x + 2 * x^2 + 3 * sin(6 * pi * x ) + 1.0 * rnorm(n)
df <- data.frame(x = x, y = y)
##-------------------------------------------------------------------------
## use a Matern 3/2 covariance. With model #2, the trend is mispecified,
## so the smooth GP part of the model captures a part of the trend.
##-------------------------------------------------------------------------
myKern <- k1Matern3_2
inputNames(myKern) <- "x"
mygp <- list()
mygp[[1]] <- gp(formula = y ~ x + I(x^2) + sin(6 * pi * x), data = df,
parCovLower = c(0.01, 0.01), parCovUpper = c(10, 100),
cov = myKern, estim = TRUE, noise = TRUE)
mygp[[2]] <- gp(formula = y ~ sin(6 * pi * x), data = df,
parCovLower = c(0.01, 0.01), parCovUpper = c(10, 100),
cov = myKern, estim = TRUE, noise = TRUE)
##-------------------------------------------------------------------------
## New data
##-------------------------------------------------------------------------
nNew <- 150
xNew <- seq(from = -0.2, to= 1.2, length.out = nNew)
dfNew <- data.frame(x = xNew)
opar <- par(mfrow = c(2L, 2L))
nsim <- 40
for (i in 1:2) {
##--------------------------------------------------------------------
## beta known or not, conditional
##--------------------------------------------------------------------
simTU <- simulate(object = mygp[[i]], newdata = dfNew, nsim = nsim,
trendKnown = FALSE)
plot(simTU, main = "trend unknown, conditional")
simTK <- simulate(object = mygp[[i]], newdata = dfNew, nsim = nsim,
trendKnown = TRUE)
plot(simTK, main = "trend known, conditional")
##--------------------------------------------------------------------
## The same but UNconditional
##--------------------------------------------------------------------
simTU <- simulate(object = mygp[[i]], newdata = dfNew, nsim = nsim,
trendKnown = FALSE, cond = FALSE)
plot(simTU, main = "trend unknown, unconditional")
simTK <- simulate(object = mygp[[i]], newdata = dfNew, nsim = nsim,
trendKnown = TRUE, cond = FALSE)
plot(simTK, main = "trend known, unconditional")
}
par(opar)
|
Loading required package: Rcpp
Loading required package: testthat
Loading required package: nloptr
Warning messages:
1: executing %dopar% sequentially: no parallel backend registered
2: In nloptr.add.default.options(opts.user = opts, x0 = x0, num_constraints_ineq = num_constraints_ineq, :
No termination criterium specified, using default (relative x-tolerance = 1e-04)
Warning message:
In nloptr.add.default.options(opts.user = opts, x0 = x0, num_constraints_ineq = num_constraints_ineq, :
No termination criterium specified, using default (relative x-tolerance = 1e-04)
Loading required package: MASS
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.