panel.box | R Documentation |
With 'layer' and 'glayer' in 'latticeExtra', these functions can be used to easily generate fitted values and error boxes that have a reasonable appearance whether a plot uses 'groups' or not.
panel.box(
x,
y,
se,
lower = y - se,
upper = y + se,
width = if (is.numeric(x)) max(diff(sort(x)))/2 else 1/2,
subscripts,
...,
type,
group.number,
alpha = 0.9,
alpha.fit = alpha,
alpha.box = 0.3,
col,
col.line,
col.symbol,
border = F,
font,
fontface
)
x , y |
arguments passed by 'layer' |
lower , upper |
FIXME |
subscripts |
FIXME |
group.number |
FIXME |
alpha |
FIXME |
col |
FIXME |
col.symbol |
is used to control color when using 'groups' |
border |
default = FALSE for panel.band. |
font |
FIXME |
fontface |
FIXME |
data |
data frame to be used to add additional values of numeric variable |
form |
formula evaluated in data. The first term defines the variable with values to be filled in and the remaining terms define the variables to be used for grouping determining the minima and maxima within which values are added. |
xpd |
expansion factor to add points beyond minima and maxima. Default 1.0. |
fit |
fitted values of a model, generally passed through 'layer' from a call to 'xyplot': e.g. |
dots |
FIXME |
The 'panel.bands', 'panel.fit', and 'panel.labels' functions are invoked for their graphical effect.
Georges Monette georges@yorku.ca
## Not run:
library(spida2)
library(latticeExtra)
library(car)
Prestige$Education <- cut(Prestige$education,
breaks = c(-Inf,8,12,+Inf), labels = c('< HS','some HS','some PS'))
Prestige$Gender <- cut(Prestige$women, breaks = c(-Inf, 10, 50, +Inf),
labels = c('Male','Mixed','Female'))
fit <- lm(income ~ Gender * Education, Prestige,
na.action = na.exclude)
pred <- with(Prestige, expand.grid(Education = levels(Education),
Gender = levels(Gender)))
pred <- cbind(pred, predict(fit, newdata = pred, se = TRUE))
pred
(p <- xyplot( fit ~ Education | Gender , pred,
subscripts = T, width = .5,
fit = pred$fit,
labels = pred$Education,
lower = with(pred, fit - 2*se.fit),
upper = with(pred, fit + 2*se.fit)))
gd(3,pch = 16)
p + layer(panel.fit(...))
(p <- update(p + layer(panel.box(...)), ylim = c(0, 15000),
auto.key = list(columns= 3)))
###### Need to fix handling of width with factor predictor
p + layer(panel.labels(...))
# NOTE: with groups use 'glayer' instead of 'layer'
## End(Not run)
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.