Learn R Programming

R2BayesX (version 1.1-5)

plot3d: 3D Effect Plot

Description

Function to plot 3D graphics or image and/or contour plots for bivariate effects/functions, typically used for objects of class "sm.bayesx" and "geo.bayesx" returned from function bayesx and read.bayesx.output.

Usage

plot3d(x, residuals = FALSE, col.surface = NULL, 
  ncol = 99L, swap = FALSE, col.residuals = NULL, col.contour = NULL, 
  c.select = NULL, grid = 30L, image = FALSE, contour = FALSE, 
  legend = TRUE, cex.legend = 1, breaks = NULL, range = NULL, 
  digits = 2L, d.persp = 1L, r.persp = sqrt(3), outscale = 0,
  data = NULL, sep = "", shift = NULL, trans = NULL,
  type = "interp", linear = FALSE, extrap = FALSE,
  k = 40, ...)

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. x may also be a character file path to the data to be used for plotting.

residuals

if set to TRUE, partial residuals may also be plotted if available.

col.surface

the color of the surface, may also be a function, e.g. col.surface = heat.colors.

ncol

the number of different colors that should be generated, if col.surface is a function.

swap

if set to TRUE colors will be represented in reverse order.

col.residuals

the color of the partial residuals, or if contour = TRUE the color of the contour lines.

col.contour

the color of the contour lines.

c.select

integer vector of maximum length of columns of x, selects the columns of the resulting data matrix that should be used for plotting. E.g. if x has 5 columns, then c.select = c(1, 2, 5) will select column 1, 2 and 5 for plotting. If c.select = 95 or c.select = 80, function plot3d will search for the corresponding columns to plot a 95\(\%\) or 80\(\%\) confidence surfaces respectively. Note that if e.g. c.select = c(1, 2), plot3d will use columns 1 + 2 and 2 + 2 for plotting.

grid

the grid size of the surface(s).

image

if set to TRUE, an image.plot is drawn.

contour

if set to TRUE, a contour plot is drawn.

legend

if image = TRUE an additional legend may be added to the plot.

cex.legend

the expansion factor for the legend text, see text.

breaks

a set of breakpoints for the colors: must give one more breakpoint than ncol.

range

specifies a certain range values should be plotted for.

digits

specifies the legend decimal places.

d.persp

see argument d in function persp.

r.persp

see argument r in function persp.

outscale

scales the outer ranges of x and z limits used for interpolation.

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. Note that data may also be a character file path to the data.

sep

the field separator character when x or data is a character, see function read.table.

shift

numeric. Constant to be added to the smooth before plotting.

trans

function to be applied to the smooth before plotting, e.g., to transform the plot to the response scale.

type

character. Which type of interpolation metjod should be used. The default is type = "interp", 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".

...

parameters passed to colorlegend if an image plot with legend is drawn, also other graphical parameters, please see the details.

Author

Nikolaus Umlauf, Thomas Kneib, Stefan Lang, Achim Zeileis.

Details

For 3D plots the following graphical parameters may be specified additionally:

  • cex: specify the size of partial residuals,

  • col: it is possible to specify the color for the surfaces if se > 0, then e.g. col = c("green", "black", "red"),

  • pch: the plotting character of the partial residuals,

  • ...: other graphical parameters passed functions persp, image.plot and contour.

See Also

plot.bayesx, bayesx, read.bayesx.output, fitted.bayesx, colorlegend.