plot2d {bamlss} | R Documentation |
Plot 2D Effects
Description
Function to plot simple 2D graphics for univariate effects/functions.
Usage
plot2d(x, residuals = FALSE, rug = FALSE, jitter = TRUE,
col.residuals = NULL, col.lines = NULL, col.polygons = NULL,
col.rug = NULL, c.select = NULL, fill.select = NULL,
data = NULL, sep = "", month = NULL, year = NULL,
step = 12, shift = NULL, trans = NULL,
scheme = 2, s2.col = NULL, grid = 50, ...)
Arguments
x |
A matrix or data frame, containing the covariate for which the effect should be plotted
in the first column and at least a second column containing the effect. Another possibility is
to specify the plot via a |
residuals |
If set to |
rug |
Add a |
jitter |
|
col.residuals |
The color of the partial residuals. |
col.lines |
The color of the lines. |
col.polygons |
Specify the background color of polygons, if |
col.rug |
Specify the color of the rug representation. |
c.select |
Integer vector of maximum length of columns of |
fill.select |
Integer vector, select pairwise the columns of the resulting data matrix
that should form one polygon with a certain background color specified in argument |
data |
If |
sep |
The field separator character when |
month , year , step |
Provide specific annotation for plotting estimation results for temporal
variables. |
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. |
scheme |
Sets the plotting scheme for polygons, possible values are |
s2.col |
The color for the second plotting scheme. |
grid |
Integer, specifies the number of polygons for the second plotting scheme. |
... |
Other graphical parameters, please see the details. |
Details
For 2D plots the following graphical parameters may be specified additionally:
-
cex
: Specify the size of partial residuals, -
lty
: The line type for each column that is plotted, e.g.lty = c(1, 2)
, -
lwd
: The line width for each column that is plotted, e.g.lwd = c(1, 2)
, -
poly.lty
: The line type to be used for the polygons, -
poly.lwd
: The line width to be used for the polygons, -
density
angle
,border
: Seepolygon
, -
...
: Other graphical parameters, see functionplot
.
See Also
plot3d
, plotmap
,
plotblock
, sliceplot
.
Examples
## Generate some data.
set.seed(111)
n <- 500
## Regressor.
d <- data.frame(x = runif(n, -3, 3))
## Response.
d$y <- with(d, 10 + sin(x) + rnorm(n, sd = 0.6))
## Not run: ## Estimate model.
b <- bamlss(y ~ s(x), data = d)
summary(b)
## Plot estimated effect.
plot(b)
plot(b, rug = FALSE)
## Extract fitted values.
f <- fitted(b, model = "mu", term = "s(x)")
f <- cbind(d["x"], f)
## Now use plot2d.
plot2d(f)
plot2d(f, fill.select = c(0, 1, 0, 1))
plot2d(f, fill.select = c(0, 1, 0, 1), lty = c(2, 1, 2))
plot2d(f, fill.select = c(0, 1, 0, 1), lty = c(2, 1, 2),
scheme = 2)
## Variations.
plot2d(sin(x) ~ x, data = d)
d$f <- with(d, sin(d$x))
plot2d(f ~ x, data = d)
d$f1 <- with(d, f + 0.1)
d$f2 <- with(d, f - 0.1)
plot2d(f1 + f2 ~ x, data = d)
plot2d(f1 + f2 ~ x, data = d, fill.select = c(0, 1, 1), lty = 0)
plot2d(f1 + f2 ~ x, data = d, fill.select = c(0, 1, 1), lty = 0,
density = 20, poly.lty = 1, poly.lwd = 2)
plot2d(f1 + f + f2 ~ x, data = d, fill.select = c(0, 1, 0, 1),
lty = c(0, 1, 0), density = 20, poly.lty = 1, poly.lwd = 2)
## End(Not run)