parview: Parallel coordinates view of a prediction model or function.

View source: R/parview.R

parview.functionR Documentation

Parallel coordinates view of a prediction model or function.

Description

Renders a parallel coordinates chart showing all input dimensions and the output simultaneously. Lines are colored by the output value (viridis palette), making it easy to identify which input regions drive high or low responses.

For model-based methods (km, Kriging, WarpKriging, glm, list) a space-filling LHS prediction grid is displayed together with the observed design points (in col_points color). Kriging-based methods also add y_low / y_up axes for the predictive confidence interval.

Two rendering engines are available via the engine argument:

"parallelPlot"

Interactive htmlwidget (default), requires the parallelPlot package.

"base"

Static base-R plot, no extra dependency.

Usage

## S3 method for class ''function''
parview(
  fun,
  vectorized = FALSE,
  n_points = 500,
  Xlim = c(0, 1),
  col_fun = if (!is.null(col)) col else "blue",
  col = NULL,
  Xlab = NULL,
  ylab = "y",
  engine = "parallelPlot",
  ...
)

## S3 method for class 'matrix'
parview(
  X,
  y,
  col_fun = if (!is.null(col)) col else "blue",
  col_points = if (!is.null(col)) col else "red",
  col = NULL,
  Xlab = NULL,
  ylab = NULL,
  engine = "parallelPlot",
  ...
)

## S3 method for class 'Kriging'
parview(
  Kriging_model,
  n_points = 500,
  col_fun = if (!is.null(col)) col else "blue",
  col_points = if (!is.null(col)) col else "red",
  col = NULL,
  conf_level = 0.95,
  Xlab = NULL,
  ylab = NULL,
  Xlim = NULL,
  engine = "parallelPlot",
  ...
)

## S3 method for class 'WarpKriging'
parview(
  WarpKriging_model,
  n_points = 500,
  col_fun = if (!is.null(col)) col else "blue",
  col_points = if (!is.null(col)) col else "red",
  col = NULL,
  conf_level = 0.95,
  Xlab = NULL,
  ylab = NULL,
  Xlim = NULL,
  engine = "parallelPlot",
  ...
)

## S3 method for class 'km'
parview(
  km_model,
  type = "UK",
  n_points = 500,
  col_fun = if (!is.null(col)) col else "blue",
  col_points = if (!is.null(col)) col else "red",
  col = NULL,
  conf_level = 0.95,
  Xlab = NULL,
  ylab = NULL,
  Xlim = NULL,
  engine = "parallelPlot",
  ...
)

## S3 method for class 'glm'
parview(
  glm_model,
  n_points = 500,
  col_fun = if (!is.null(col)) col else "blue",
  col_points = if (!is.null(col)) col else "red",
  col = NULL,
  conf_level = 0.95,
  Xlab = NULL,
  ylab = NULL,
  Xlim = NULL,
  engine = "parallelPlot",
  ...
)

## S3 method for class 'list'
parview(
  modelFit_model,
  n_points = 500,
  col_fun = if (!is.null(col)) col else "blue",
  col_points = if (!is.null(col)) col else "red",
  col = NULL,
  Xlab = NULL,
  ylab = NULL,
  Xlim = NULL,
  engine = "parallelPlot",
  ...
)

parview(...)

Arguments

fun

a function or 'predict()'-like function that returns a simple numeric, or a list(mean=...,se=...).

vectorized

is fun vectorized?

n_points

number of LHS prediction points.

Xlim

optional input bounds matrix (2 x D); defaults to design range.

col_fun

base color for the prediction color scale (HSV saturation ramp from white to this color, matching the contourview policy).

col

shorthand alias for both col_fun and col_points; overridden by the individual arguments if both are supplied.

Xlab

optional character vector of axis labels for inputs.

ylab

optional string label for the output axis.

engine

rendering engine: "parallelPlot" or "base".

...

arguments of the relevant parview.* method.

X

the matrix of input design.

y

the array of output values.

col_points

color of observed design points.

Kriging_model

an object of class "Kriging".

conf_level

confidence level for uncertainty bands shown as extra axes.

WarpKriging_model

an object of class "WarpKriging".

km_model

an object of class "km".

type

the kriging type to use for model prediction.

glm_model

an object of class "glm".

modelFit_model

an object returned by DiceEval::modelFit.

See Also

sectionview.function for 1D section plots.

sectionview.matrix for 1D section plots.

sectionview.Kriging for 1D section plots.

sectionview.WarpKriging for 1D section plots.

sectionview.km for 1D section plots.

sectionview.glm for 1D section plots.

sectionview.list for 1D section plots.

Examples

parview(branin, Xlim = rbind(c(0, 0), c(1, 1)), engine = "base")
X <- matrix(runif(15 * 2), ncol = 2)
y <- apply(X, 1, branin)
parview(X, y, engine = "base")
if (requireNamespace("rlibkriging")) { library(rlibkriging)
  X <- matrix(runif(15 * 2), ncol = 2)
  y <- apply(X, 1, branin)
  model <- Kriging(X = X, y = as.matrix(y), kernel = "matern3_2")
  parview(model, engine = "base")
}
if (requireNamespace("rlibkriging")) { library(rlibkriging)
  X <- matrix(runif(15 * 2), ncol = 2)
  y <- apply(X, 1, branin) + 5 * rnorm(15)
  model <- WarpKriging(y = y, X = X, warping = c("affine", "affine"), kernel = "matern3_2")
  parview(model, engine = "base")
}
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")
  parview(model, engine = "base")
}
x1 <- rnorm(15); x2 <- rnorm(15)
y <- x1 + x2^2 + rnorm(15)
model <- glm(y ~ x1 + I(x2^2))
parview(model, engine = "base")
if (requireNamespace("DiceEval")) { library(DiceEval)
  X <- matrix(runif(15 * 2), ncol = 2)
  y <- apply(X, 1, branin)
  model <- modelFit(X, y, type = "StepLinear")
  parview(model, engine = "base")
}
## Static base-R plot
parview(branin, Xlim = rbind(c(0, 0), c(1, 1)), engine = "base")

## Design points only
X <- matrix(runif(30 * 2), ncol = 2)
y <- apply(X, 1, branin)
parview(X, y, engine = "base")

DiceView documentation built on June 17, 2026, 5:07 p.m.