sliceplot | R Documentation |
This function plots slices from user defined values of bivariate surfaces.
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 = "interp", linear = FALSE,
extrap = FALSE, k = 40, rug = TRUE, rug.col = NULL,
jitter = TRUE, ...)
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 |
y |
if |
z |
if |
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 |
c.select |
|
values |
the values of the |
probs |
numeric vector of probabilities with values in [0,1] to be used within function
|
grid |
the grid size of the surface where the slices are generated from. |
legend |
if set to |
pos |
the position of the legend, see also function |
digits |
the decimal place the legend values should be rounded. |
data |
if |
rawdata |
if set to |
type |
character. Which type of interpolation metjod should be used. The default is
|
linear |
logical. Should linear interpolation be used withing function
|
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 |
rug |
add a |
jitter |
if set to |
rug.col |
specify the color of the rug representation. |
... |
parameters passed to |
Similar to function plot3d
, this function first applies bivariate interpolation
on a regular grid
, afterwards the slices are computed from the resulting surface.
Nikolaus Umlauf, Thomas Kneib, Stefan Lang, Achim Zeileis.
plot.bayesx
, bayesx
, read.bayesx.output
,
fitted.bayesx
, plot3d
.
## 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))
## End(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)
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.