simulate.lineqGP: Simulation Method for the '"lineqGP"' S3 Class

Description Usage Arguments Details Value Author(s) References See Also Examples

View source: R/lineqGP.R

Description

Simulation method for the "lineqGP" S3 class.

Usage

1
2
## S3 method for class 'lineqGP'
simulate(object, nsim = 1, seed = NULL, xtest, ...)

Arguments

object

an object with class "lineqGP".

nsim

the number of simulations.

seed

see simulate.

xtest

a vector (or matrix) with the test input design.

...

further arguments passed to or from other methods.

Details

The posterior sample-path of the finite-dimensional GP with linear inequality constraints are computed. Here, ξ is a centred Gaussian vector with covariance Γ, s.t. Φ ξ = y (interpolation constraints) and lb ≤ Λ ξ ≤ ub (inequality constraints).

Value

A "lineqGP" object with the following elements.

x

a vector (or matrix) with the training input design.

y

the training output vector at x.

xtest

a vector (or matrix) with the test input design.

Phi.test

a matrix corresponding to the hat basis functions evaluated at xtest. The basis functions are indexed by rows.

xi.sim

the posterior sample-path of the finite-dimensional Gaussian vector.

ysim

the posterior sample-path of the observed GP. Note: ysim = Phi.test %*% xi.sim.

Author(s)

A. F. Lopez-Lopera.

References

Lopez-Lopera, A. F., Bachoc, F., Durrande, N., and Roustant, O. (2017), "Finite-dimensional Gaussian approximation with linear inequality constraints". ArXiv e-prints [link]

See Also

create.lineqGP, augment.lineqGP, predict.lineqGP

Examples

 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
# creating the model
sigfun <- function(x) return(1/(1+exp(-7*(x-0.5))))
x <- seq(0, 1, length = 5)
y <- sigfun(x)
model <- create(class = "lineqGP", x, y, constrType = "monotonicity")

# updating and expanding the model
model$localParam$m <- 30
model$kernParam$par <- c(1, 0.2)
model <- augment(model)

# sampling from the model
xtest <- seq(0, 1, length = 100)
ytest <- sigfun(xtest)
sim.model <- simulate(model, nsim = 50, seed = 1, xtest = xtest)
mu <- apply(sim.model$ysim, 1, mean)
qtls <- apply(sim.model$ysim, 1, quantile, probs = c(0.05, 0.95))
matplot(xtest, t(qtls), type = "l", lty = 1, col = "gray90",
        main = "Constrained Kriging model")
polygon(c(xtest, rev(xtest)), c(qtls[2,], rev(qtls[1,])), col = "gray90", border = NA)
lines(xtest, ytest, lty = 2)
lines(xtest, mu, type = "l", col = "darkgreen")
points(x, y, pch = 20)
legend("right", c("ytrain", "ytest", "mean", "confidence"), lty = c(NaN,2,1,NaN),
       pch = c(20,NaN,NaN,15), col = c("black", "black", "darkgreen", "gray80"))

lineqGPR documentation built on Jan. 11, 2020, 9:23 a.m.