SCM Repository

[latticeextra] View of /www/man/panel.smoother.html
ViewVC logotype

View of /www/man/panel.smoother.html

Parent Directory Parent Directory | Revision Log Revision Log

Revision 143 - (download) (as text) (annotate)
Tue May 25 06:54:57 2010 UTC (9 years ago) by felix
File size: 4155 byte(s)
get rid of ".featured_example", just use example number
<html><head><title>R: Plot a smoothing line with standard error bounds.</title>


<table width="100%" summary="page for panel.smoother {latticeExtra}"><tr><td>panel.smoother {latticeExtra}</td><td align="right">R Documentation</td></tr></table>

<h2>Plot a smoothing line with standard error bounds.</h2>


Plot a smoothing line with standard error bounds.
This is based on the <code><a href="../../ggplot2/html/stat_smooth.html">stat_smooth</a></code>
function from <span class="pkg">ggplot2</span>.


panel.smoother(x, y, form = y ~ x, method = "loess", ...,
    se = TRUE, level = 0.95, n = 100,
    col = plot.line$col, = col,
    lty = plot.line$lty, lwd = plot.line$lwd,
    alpha = plot.line$alpha, = 0.25, border = NA,
    ## ignored: ##
    subscripts, group.number, group.value,
    type, col.line, col.symbol, fill,
    pch, cex, font, fontface, fontfamily)


<table summary="R argblock">
<tr valign="top"><td><code>x, y</code></td>

data points. If these are missing, they will be looked for in the
environment of <code>form</code>. So in many cases you can skip these if
passing <code>form</code>. In fact, for convenience, the formula
can be passed as the first argument (i.e. <code>x</code>).
<tr valign="top"><td><code>form, method</code></td>

the smoothing model is constructed (approximately) as
<code>method(form, data = list(x=x, y=y), ...)</code>.
See the Examples section for common choices.
<tr valign="top"><td><code>...</code></td>

further arguments passed on to the model function (<code>method</code>).
<tr valign="top"><td><code>se, level</code></td>

estimate standard errors on the smoother, at the given <code>level</code>,
and plot these as a band.
<tr valign="top"><td><code>n</code></td>

number of equi-spaced points on which to evaluate the smooth function.
<tr valign="top"><td><code>col,, lty, lwd, alpha,, border</code></td>

graphical parameters. <code>col</code> and <code>alpha</code> apply to the
smoothing line, while <code></code> and <code></code>
apply to the shaded <code>se</code> region.
<tr valign="top"><td><code>subscripts, group.number, group.value,
type, col.line, col.symbol, fill,
pch, cex, font, fontface, fontfamily</code></td>



This should work with any model function that takes a formula
argument, and has a <code>predict</code> method with a <code>se</code> argument.


Felix Andrews <a href=""></a>
Based on <code><a href="../../ggplot2/html/stat_smooth.html">stat_smooth</a></code> by Hadley Wickham.

<h3>See Also</h3>

<code><a href="#panel.quantile">panel.quantile</a></code>,
<code><a href="../../ggplot2/html/stat_smooth.html">stat_smooth</a></code>


xy &lt;- data.frame(x = runif(100),
                 y = rt(100, df = 5),
                 y2 = rt(100, df = 5) + 1)

xyplot(y ~ x, xy, panel = function(...) {
       panel.smoother(..., span = 0.9)

## per-group layers with glayer (pass `...` to get styles)
xyplot(y + y2 ~ x, xy) +

## natural spline with 5 degrees of freedom
if (require("splines"))
  xyplot(y ~ x, xy) +
    layer(panel.smoother(y ~ ns(x,5), method = "lm"))

## thin plate regression spline with smoothness
## chosen by cross validation (see ?mgcv::gam)
if (require("mgcv"))
  xyplot(y ~ x, xy) +
    layer(panel.smoother(y ~ s(x), method = "gam"))

## simple linear regression with standard errors:
xyplot(y ~ x, xy) +
  layer(panel.smoother(x, y, method = "lm"), style = 2)

<div align="center">[Package <em>latticeExtra</em> version 0.6-12 <a href="00Index.html">Index</a>]</div>
ViewVC Help
Powered by ViewVC 1.0.0  
Thanks to:
Vienna University of Economics and Business Powered By FusionForge