sectionview.function {DiceView} | R Documentation |
Plot a section view of a prediction model or function, including design points if available.
Description
Plot a section view of a prediction model or function, including design points if available.
Usage
## S3 method for class ''function''
sectionview(
fun,
vectorized = FALSE,
dim = NULL,
center = NULL,
axis = NULL,
npoints = 100,
col_surf = "blue",
conf_lev = c(0.5, 0.8, 0.9, 0.95, 0.99),
conf_blend = NULL,
mfrow = NULL,
Xlab = NULL,
ylab = NULL,
Xlim = NULL,
ylim = NULL,
title = NULL,
add = FALSE,
...
)
## S3 method for class 'matrix'
sectionview(
X,
y,
sdy = NULL,
center = NULL,
axis = NULL,
npoints = 100,
col_points = "red",
conf_lev = c(0.5, 0.8, 0.9, 0.95, 0.99),
conf_blend = NULL,
bg_blend = 5,
mfrow = NULL,
Xlab = NULL,
ylab = NULL,
Xlim = NULL,
ylim = NULL,
title = NULL,
add = FALSE,
...
)
## S3 method for class 'km'
sectionview(
km_model,
type = "UK",
center = NULL,
axis = NULL,
npoints = 100,
col_points = "red",
col_surf = "blue",
conf_lev = c(0.5, 0.8, 0.9, 0.95, 0.99),
conf_blend = NULL,
bg_blend = 5,
mfrow = NULL,
Xlab = NULL,
ylab = NULL,
Xlim = NULL,
ylim = NULL,
title = NULL,
add = FALSE,
...
)
## S3 method for class 'Kriging'
sectionview(
Kriging_model,
center = NULL,
axis = NULL,
npoints = 100,
col_points = "red",
col_surf = "blue",
conf_lev = c(0.5, 0.8, 0.9, 0.95, 0.99),
conf_blend = NULL,
bg_blend = 5,
mfrow = NULL,
Xlab = NULL,
ylab = NULL,
Xlim = NULL,
ylim = NULL,
title = NULL,
add = FALSE,
...
)
## S3 method for class 'NuggetKriging'
sectionview(
NuggetKriging_model,
center = NULL,
axis = NULL,
npoints = 100,
col_points = "red",
col_surf = "blue",
conf_lev = c(0.5, 0.8, 0.9, 0.95, 0.99),
conf_blend = NULL,
bg_blend = 5,
mfrow = NULL,
Xlab = NULL,
ylab = NULL,
Xlim = NULL,
ylim = NULL,
title = NULL,
add = FALSE,
...
)
## S3 method for class 'NoiseKriging'
sectionview(
NoiseKriging_model,
center = NULL,
axis = NULL,
npoints = 100,
col_points = "red",
col_surf = "blue",
conf_lev = c(0.5, 0.8, 0.9, 0.95, 0.99),
conf_blend = NULL,
bg_blend = 5,
mfrow = NULL,
Xlab = NULL,
ylab = NULL,
Xlim = NULL,
ylim = NULL,
title = NULL,
add = FALSE,
...
)
## S3 method for class 'glm'
sectionview(
glm_model,
center = NULL,
axis = NULL,
npoints = 100,
col_points = "red",
col_surf = "blue",
conf_lev = c(0.5, 0.8, 0.9, 0.95, 0.99),
conf_blend = NULL,
bg_blend = 5,
mfrow = NULL,
Xlab = NULL,
ylab = NULL,
Xlim = NULL,
ylim = NULL,
title = NULL,
add = FALSE,
...
)
## S3 method for class 'list'
sectionview(
modelFit_model,
center = NULL,
axis = NULL,
npoints = 100,
col_points = "red",
col_surf = "blue",
bg_blend = 5,
mfrow = NULL,
Xlab = NULL,
ylab = NULL,
Xlim = NULL,
ylim = NULL,
title = NULL,
add = FALSE,
...
)
sectionview(...)
Arguments
fun |
a function or 'predict()'-like function that returns a simple numeric or mean and standard error: list(mean=...,se=...). |
vectorized |
is fun vectorized? |
dim |
input variables dimension of the model or function. |
center |
optional coordinates (as a list or data frame) of the center of the section view if the model's dimension is > 2. |
axis |
optional matrix of 2-axis combinations to plot, one by row. The value |
npoints |
an optional number of points to discretize plot of response surface and uncertainties. |
col_surf |
color for the surface. |
conf_lev |
an optional list of confidence interval values to display. |
conf_blend |
an optional factor of alpha (color channel) blending used to plot confidence intervals. |
mfrow |
an optional list to force |
Xlab |
an optional list of string to overload names for X. |
ylab |
an optional string to overload name for y. |
Xlim |
an optional list to force x range for all plots. The default value |
ylim |
an optional list to force y range for all plots. |
title |
an optional overload of main title. |
add |
to print graphics on an existing window. |
... |
arguments of the |
X |
the matrix of input design. |
y |
the array of output values. |
sdy |
optional array of output standard error. |
col_points |
color of points. |
bg_blend |
an optional factor of alpha (color channel) blending used to plot design points outside from this section. |
km_model |
an object of class |
type |
the kriging type to use for model prediction. |
Kriging_model |
an object of class |
NuggetKriging_model |
an object of class |
NoiseKriging_model |
an object of class |
glm_model |
an object of class |
modelFit_model |
an object returned by DiceEval::modelFit. |
Details
If available, experimental points are plotted with fading colors. Points that fall in the specified section (if any) have the color specified col_points
while points far away from the center have shaded versions of the same color. The amount of fading is determined using the Euclidean distance between the plotted point and center
.
Author(s)
Yann Richet, IRSN
See Also
sectionview.function
for a section plot, and sectionview3d.function
for a 2D section plot.
Vectorize.function
to wrap as vectorized a non-vectorized function.
sectionview.matrix
for a section plot, and sectionview3d.matrix
for a 2D section plot.
sectionview.km
for a section plot, and sectionview3d.km
for a 2D section plot.
sectionview.Kriging
for a section plot, and sectionview3d.Kriging
for a 2D section plot.
sectionview.NuggetKriging
for a section plot, and sectionview3d.NuggetKriging
for a 2D section plot.
sectionview.NoiseKriging
for a section plot, and sectionview3d.NoiseKriging
for a 2D section plot.
sectionview.glm
for a section plot, and sectionview3d.glm
for a 2D section plot.
sectionview.glm
for a section plot, and sectionview3d.glm
for a 2D section plot.
Examples
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')
## Not run:
## 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)
}
## End(Not run)