ed_plot: Log density plot using ed raw estimates

Description Usage Arguments Value Author(s) See Also Examples

View source: R/plots.R

Description

Plot the log density of data using ed raw estimates

Usage

1
2
ed_plot(x, data = NULL, panel = "panel.ed", prepanel = "prepanel.ed",
  groups = NULL, ylab = "Log Density", ...)

Arguments

x

either a formula (e.g. "~ data | condvar") or a numeric vector for which to calculate and plot ed raw estimates

data

if x is a formula, an optional data source (usually a data frame) in which variables are to be evaluated (see xyplot for details).

panel

a function, called once for each panel, that uses the packet (subset of panel variables) corresponding to the panel to create a display. The default panel function is panel.ed and is documented separately, and has arguments that can be used to customize its output in various ways. Such arguments can usually be directly supplied to the high-level function.

prepanel

See xyplot.

groups

See xyplot.

ylab

See xyplot.

...

further arguments. See corresponding entry in xyplot for non-trivial details.

Value

An object of class "trellis".

Author(s)

Ryan Hafen

See Also

densityplot

Examples

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
# plot benchden data
ed_plot(~ x | density, data = benchdat,
   scales = list(relation = "free", draw = FALSE),
   as.table = TRUE
)

# generate some data
n <- 5000
x <- rnorm(3 * n, mean = rep(c(0, 2, 4), each = n), sd = rep(1:3, each = n))
dd <- data.frame(x = x, cond = rep(1:3, each = n))

# estimate/plot all the data
ed_plot(~ x, data = dd, xlab = "data", aspect = 1)

# estimate/plot by conditioning variable
ed_plot(~ x | cond, data = dd,
  xlab = "data", aspect = 1,
  as.table = TRUE, layout = c(3, 1))

# with lines
ed_plot(~ x | cond, data = dd, kk = 15,
  panel = function(x, ...) {
    panel.grid(h = -1, v = -1)
    panel.ed(x, ...)
    ss <- seq(-8, 15, length = 300)
    panel.lines(ss, log(dnorm(ss, mean = mean(x), sd = sd(x))), col = "black")
  },
  type = c("p", "g"),
  aspect = 1,
  as.table = TRUE,
  layout = c(3, 1)
)

# using "groups"
ed_plot(~ x, data = dd, groups = cond, alpha = 0.75)

hafen/ed documentation built on May 17, 2019, 1:32 p.m.