SCM

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>


</head><body>

<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>


<h3>Description</h3>

<p>
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>.
</p>


<h3>Usage</h3>

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


<h3>Arguments</h3>

<table summary="R argblock">
<tr valign="top"><td><code>x, y</code></td>
<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>).
</td></tr>
<tr valign="top"><td><code>form, method</code></td>
<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.
</td></tr>
<tr valign="top"><td><code>...</code></td>
<td>

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

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

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

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

ignored.
</td></tr>
</table>


<h3>Details</h3>

<p>
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.
</p>


<h3>Author(s)</h3>

<p>
Felix Andrews <a href="mailto:felix@nfrac.org">felix@nfrac.org</a>
</p>
<p>
Based on <code><a href="../../ggplot2/html/stat_smooth.html">stat_smooth</a></code> by Hadley Wickham.
</p>


<h3>See Also</h3>

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


<h3>Examples</h3>

<pre>
set.seed(1)
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.xyplot(...)
       panel.smoother(..., span = 0.9)
})

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

## 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)
</pre>

<div align="center">[Package <em>latticeExtra</em> version 0.6-12 <a href="00Index.html">Index</a>]</div>
</body></html>

root@r-forge.r-project.org
ViewVC Help
Powered by ViewVC 1.0.0  
Thanks to:
Vienna University of Economics and Business Powered By FusionForge