Description Usage Arguments Details Value Note Author(s) See Also Examples

Calculate an empirical confidence region for two variables, and optionally overlay the smooth polygon on a scatterplot.

1 2 3 4 5 6 7 8 9 10 11 | ```
conf2d(x, ...)
## S3 method for class 'formula'
conf2d(formula, data, subset, ...)
## Default S3 method:
conf2d(x, y, level=0.95, n=200, method="wand", shape=1, smooth=50,
plot=TRUE, add=FALSE, xlab=NULL, ylab=NULL, col.points="gray",
col="black", lwd=2, ...)
conf2d_int(x, y, surf, level, n) # internal function
``` |

`x` |
a vector of x values, or a data frame whose first two columns contain the x and y values. |

`y` |
a vector of y values. |

`formula` |
a |

`data` |
a |

`subset` |
an optional vector specifying a subset of observations to be used. |

`level` |
the proportion of points that should be inside the region. |

`n` |
the number of regions to evaluate, before choosing the region
that matches |

`method` |
kernel smoothing function to use: |

`shape` |
a bandwidth scaling factor, affecting the polygon shape. |

`smooth` |
the number of bins (scalar or vector of length 2), affecting the polygon smoothness. |

`plot` |
whether to plot a scatterplot and overlay the region as a polygon. |

`add` |
whether to add a polygon to an existing plot. |

`xlab` |
a label for the x axis. |

`ylab` |
a label for the y axis. |

`col.points` |
color of points. |

`col` |
color of polygon. |

`lwd` |
line width of polygon. |

`...` |
further arguments passed to |

`surf` |
a list whose first three elements are x coordinates, y coordinates, and a surface matrix. |

This function constructs a large number (`n`

) of smooth polygons,
and then chooses the polygon that comes closest to containing a given
proportion (`level`

) of the total points.

The default `method="wand"`

calls the
`bkde2D`

kernel smoother from the
KernSmooth package, while `method="mass"`

calls
`kde2d`

from the MASS package.

The `conf2d`

function calls `bkde2D`

or `kde2d`

to
compute a smooth surface from `x`

and y. If users already have
a smoothed surface to work from, the internal `conf2d_int`

can be
used directly to find the empirical confidence region that matches
`level`

best.

List containing five elements:

`x` |
x coordinates defining the region. |

`y` |
y coordinates defining the region. |

`inside` |
logical vector indicating which of the original data coordinates are inside the region. |

`area` |
area inside the region. |

`prop` |
actual proportion of points inside the region. |

The `area`

of a bivariate region is analogous to the range of a
univariate interval. This allows a quantitative comparison of
different confidence regions.

Ellipses are a more restrictive approach to calculate an empirical bivariate confidence region. Smooth polygons make fewer assumptions about how x and y covary.

The `conf2d`

and `freq2d`

functions are closely related. The
advantage of `conf2d`

is that it returns a region as a smooth
polygon. The advantage of `freq2d`

is that it returns a set that
is guaranteed to contain the correct proportion of points, even for
spatially complex datasets.

Arni Magnusson and Julian Burgos, based on an earlier function by Gregory R. Warnes.

`quantile`

is the corresponding univariate equivalent.

The distfree.cr package uses a different smoothing algorithm to calculate bivariate empirical confidence regions.

`ci2d`

in the gplots package is a
predecessor of `conf2d`

.

`freq2d`

calculates a discrete frequency distribution for
two continuous variables.

`r2d2-package`

gives an overview of the package.

1 2 3 4 5 6 7 8 |

Embedding an R snippet on your website

Add the following code to your website.

For more information on customizing the embed code, read Embedding Snippets.