x1 <- rnorm(15)
x2 <- rnorm(15)
y <- x1 + x2 + rnorm(15)
model <- lm(y ~ x1 + x2)
sectionview(function(x) sum(x),
dim=2, center=c(0,0), Xlim=cbind(range(x1),range(x2)), col='black')
sectionview(function(x) {
x = as.data.frame(x)
colnames(x) <- names(model$coefficients[-1])
p = predict.lm(model, newdata=x, se.fit=TRUE)
list(mean=p$fit, se=p$se.fit)
}, vectorized=TRUE,
dim=2, center=c(0,0), Xlim=cbind(range(x1),range(x2)), add=TRUE)
X = matrix(runif(15*2),ncol=2)
y = apply(X,1,branin)
sectionview(X,y, center=c(.5,.5))
if (requireNamespace("DiceKriging")) { library(DiceKriging)
X = matrix(runif(15*2),ncol=2)
y = apply(X,1,branin)
model <- km(design = X, response = y, covtype="matern3_2")
sectionview(model, center=c(.5,.5))
}
if (requireNamespace("rlibkriging")) { library(rlibkriging)
X = matrix(runif(15*2),ncol=2)
y = apply(X,1,branin)
model <- Kriging(X = X, y = y, kernel="matern3_2")
sectionview(model, center=c(.5,.5))
}
if (requireNamespace("rlibkriging")) { library(rlibkriging)
X = matrix(runif(15*2),ncol=2)
y = apply(X,1,branin) + 5*rnorm(15)
model <- NuggetKriging(X = X, y = y, kernel="matern3_2")
sectionview(model, center=c(.5,.5))
}
if (requireNamespace("rlibkriging")) { library(rlibkriging)
X = matrix(runif(15*2),ncol=2)
y = apply(X,1,branin) + 5*rnorm(15)
model <- NoiseKriging(X = X, y = y, kernel="matern3_2", noise=rep(5^2,15))
sectionview(model, center=c(.5,.5))
}
x1 <- rnorm(15)
x2 <- rnorm(15)
y <- x1 + x2^2 + rnorm(15)
model <- glm(y ~ x1 + I(x2^2))
sectionview(model, center=c(.5,.5))
if (requireNamespace("DiceEval")) { library(DiceEval)
X = matrix(runif(15*2),ncol=2)
y = apply(X,1,branin)
model <- modelFit(X, y, type = "StepLinear")
sectionview(model, center=c(.5,.5))
}
## A 2D example - Branin-Hoo function
sectionview(branin, center= c(.5,.5), col='black')
if (FALSE) {
## a 16-points factorial design, and the corresponding response
d <- 2; n <- 16
design.fact <- expand.grid(seq(0, 1, length = 4), seq(0, 1, length = 4))
design.fact <- data.frame(design.fact); names(design.fact) <- c("x1", "x2")
y <- branin(design.fact); names(y) <- "y"
if (requireNamespace("DiceKriging")) { library(DiceKriging)
## model: km
model <- DiceKriging::km(design = design.fact, response = y)
sectionview(model, center= c(.5,.5))
sectionview(branin, center= c(.5,.5), col='red', add=TRUE)
}
if (requireNamespace("rlibkriging")) { library(rlibkriging)
## model: Kriging
model <- Kriging(X = as.matrix(design.fact), y = as.matrix(y), kernel="matern3_2")
sectionview(model, center= c(.5,.5))
sectionview(branin, center= c(.5,.5), col='red', add=TRUE)
}
## model: glm
model <- glm(y ~ 1+ x1 + x2 + I(x1^2) + I(x2^2) + x1*x2, data=cbind(y,design.fact))
sectionview(model, center= c(.5,.5))
sectionview(branin, center= c(.5,.5), col='red', add=TRUE)
if (requireNamespace("DiceEval")) { library(DiceEval)
## model: StepLinear
model <- modelFit(design.fact, y, type = "StepLinear")
sectionview(model, center= c(.5,.5))
sectionview(branin, center= c(.5,.5), col='red', add=TRUE)
}
}
Run the code above in your browser using DataLab