# sliceplot

##### Plot Slices of Bivariate Functions

This function plots slices from user defined values of bivariate surfaces.

- Keywords
- hplot

##### Usage

```
sliceplot(x, y = NULL, z = NULL, view = 1, c.select = NULL,
values = NULL, probs = c(0.1, 0.5, 0.9), grid = 100,
legend = TRUE, pos = "topright", digits = 2, data = NULL,
rawdata = FALSE, type = "akima", linear = FALSE,
extrap = FALSE, k = 40, rug = TRUE, rug.col = NULL,
jitter = TRUE, ...)
```

##### Arguments

- x
a matrix or data frame, containing the covariates for which the effect should be plotted in the first and second column and at least a third column containing the effect, typically the structure for bivariate functions returned within

`bayesx`

and`read.bayesx.output`

model term objects is used, also see`fitted.bayesx`

. Another possibility is to specify the plot via a`formula`

, e.g. for simple plotting of bivariate surfaces`z ~ x + y`

, also see the example.- y
if

`x`

is a vector the argument`y`

and`z`

must also be supplied as vectors.- z
if

`x`

is a vector the argument`y`

and`z`

must also be supplied as vectors,`z`

defines the surface given by \(z = f(x, y)\).- view
which variable should be used for the x-axis of the plot, the other variable will be used to compute the slices. May also be a

`character`

with the name of the corresponding variable.- c.select
`integer`

, selects the column that is used in the resulting matrix to be used as the`z`

argument.- values
the values of the

`x`

or`y`

variable that should be used for computing the slices, if set to`NULL`

, slices will be constructed according to the quantiles, see also argument`probs`

.- probs
numeric vector of probabilities with values in [0,1] to be used within function

`quantile`

to compute the`values`

for plotting the slices.- grid
the grid size of the surface where the slices are generated from.

- legend
if set to

`TRUE`

, a legend with the`values`

that where used for slicing will be added.- pos
the position of the legend, see also function

`legend`

.- digits
the decimal place the legend values should be rounded.

- data
if

`x`

is a`formula`

, a`data.frame`

or`list`

. By default the variables are taken from`environment(x)`

: typically the environment from which`plot3d`

is called.- rawdata
if set to

`TRUE`

, the data will not be interpolated, only raw data will be used. This is useful when displaying data on a regular grid.- type
character. Which type of interpolation metjod should be used. The default is

`type = "akima"`

, see function`interp`

. The two other options are`type = "mba"`

, which calls function`mba.surf`

of package MBA, or`type = "mgcv"`

, which uses a spatial smoother withing package mgcv for interpolation. The last option is definitely the slowest, since a full regression model needs to be estimated.- linear
logical. Should linear interpolation be used withing function

`interp`

?- extrap
logical. Should interpolations be computed outside the observation area (i.e., extrapolated)?

- k
integer. The number of basis functions to be used to compute the interpolated surface when

`type = "mgcv"`

.- rug
add a

`rug`

to the plot.- jitter
- rug.col
specify the color of the rug representation.

- …

##### Details

Similar to function `plot3d`

, this function first applies bivariate interpolation
on a regular `grid`

, afterwards the slices are computed from the resulting surface.

##### Note

Function `sliceplot`

uses per default the akima package to construct smooth interpolated
surfaces, therefore, package akima needs to be installed. The akima package has an ACM
license that restricts applications to non-commercial usage, see

http://www.acm.org/publications/policies/softwarecrnotice

Function `sliceplot`

prints a note refering to the ACM licence. This note can be supressed by
setting

`options("use.akima" = TRUE)`

##### See Also

`plot.bayesx`

, `bayesx`

, `read.bayesx.output`

,
`fitted.bayesx`

, `plot3d`

.

##### Examples

```
# NOT RUN {
## generate some data
set.seed(111)
n <- 500
## regressors
dat <- data.frame(z = runif(n, -3, 3), w = runif(n, 0, 6))
## response
dat$y <- with(dat, 1.5 + cos(z) * sin(w) + rnorm(n, sd = 0.6))
# }
# NOT RUN {
## estimate model
b <- bayesx(y ~ sx(z, w, bs = "te", knots = 5), data = dat, method = "REML")
summary(b)
## plot estimated effect
plot(b, term = "sx(z,w)", sliceplot = TRUE)
plot(b, term = "sx(z,w)", sliceplot = TRUE, view = 2)
plot(b, term = "sx(z,w)", sliceplot = TRUE, view = "w")
plot(b, term = "sx(z,w)", sliceplot = TRUE, c.select = 4)
plot(b, term = "sx(z,w)", sliceplot = TRUE, c.select = 6)
plot(b, term = "sx(z,w)", sliceplot = TRUE, probs = seq(0, 1, length = 10))
# }
# NOT RUN {
## another variation
dat$f1 <- with(dat, sin(z) * cos(w))
sliceplot(cbind(z = dat$z, w = dat$w, f1 = dat$f1))
## same with formula
sliceplot(sin(z) * cos(w) ~ z + w, ylab = "f(z)", data = dat)
## compare with plot3d()
plot3d(sin(z) * 1.5 * w ~ z + w, zlab = "f(z,w)", data = dat)
sliceplot(sin(z) * 1.5 * w ~ z + w, ylab = "f(z)", data = dat)
sliceplot(sin(z) * 1.5 * w ~ z + w, view = 2, ylab = "f(z)", data = dat)
# }
```

*Documentation reproduced from package R2BayesX, version 1.1-1, License: GPL-2 | GPL-3*