simulate_process.kmMonotonic1D: Simulate responses vectors from a kmMonotonic1D model

View source: R/simulate.kmMonotonic1D.R

simulate_process.kmMonotonic1DR Documentation

Simulate responses vectors from a kmMonotonic1D model

Usage

## S3 method for class 'kmMonotonic1D'
simulate_process(object, nsim, seed = NULL, newdata)

Arguments

object

kmMonotonic1D model

nsim

the number of response vectors to simulate

seed

optional random seed

newdata

a vector which represents the points where to performs predictions

Examples

design = c(0.1, 0.5, 0.9)
response = c(1, 5, 5.5)
model <- kmMonotonic1D(design, response, coef.var=2, coef.cov=0.5, basis.size=50)
x = seq(0, 1,, 100)
y = simulate_process(object=model, newdata=x, nsim=40)
graphics::matplot(x, y, col='gray', type='l', lty=1, ylab='response', xlab='input')
lines(x, constrSpline(object=model)(x), lty=1, col='black') 
lines(x, rowMeans(y), lty=2, col='black')
points(design, response, pch=19)
legend(0.21, 2, c("monotone GP sample paths", "posterior max", "posterior mean"), 
       col = c('gray', 'black', 'black'), text.col = "black",
       lty = c(1, 1, 2), pch=c(NA_integer_, NA_integer_, NA_integer_), lwd = c(1, 1, 1), text.font=1,box.lty=0, cex=1)
## Golchi Example
f <- function(x){
log(20*x+1)
}
design <- c(0, 0.1, 0.2, 0.3, 0.4, 0.9, 1)
response <- f(design)
meany <- mean(response)
f <- function(x){
 log(20*x+1)-meany
}
design <- c(0, 0.1, 0.2, 0.3, 0.4, 0.9, 1)
response <- f(design)
model = kmMonotonic1D(design, response, coef.var=335^2, coef.cov=4.37, basis.size=50)
x=seq(0, 1,, 100)
graphics::matplot(x, y=simulate_process(object=model, newdata=x, nsim=40), col='gray', type='l',lty=1, ylab='response', xlab='input')
lines(x, constrSpline(model)(x), lty=2, col='black', lwd=2)
lines(x, f(x))
points(design, response, pch=19)
legend(0.3, -0.5, c("true function", "posterior max"), 
       col = c('black', 'black'), text.col = "black",
       lty = c(1, 2), pch=c(NA_integer_, NA_integer_), lwd = c(2, 2), text.font=1, box.lty=0, cex=1)

maatouk/constrKriging documentation built on April 24, 2024, 7:13 p.m.