Learn R Programming

barrel (version 0.1.0)

ord_compute_ellipse: Compute coordinates for an ordination ellipse

Description

Calculates ellipse coordinates based on a covariance matrix and center. Supports confidence ellipses (standard error, "se") or dispersion ellipses ("sd").

Usage

ord_compute_ellipse(
  cov,
  center = c(0, 0),
  kind = "se",
  conf = 0.95,
  npoints = 100,
  n = NULL
)

Value

A numeric matrix with two columns representing x and y coordinates of the ellipse.

Arguments

cov

Numeric matrix (2x2) covariance matrix.

center

Numeric vector of length 2 specifying the ellipse center coordinates.

kind

Character string specifying the type of ellipse: either "se" for standard error/confidence ellipse or "sd" for standard deviation dispersion ellipse.

conf

Numeric confidence level or coverage (default 0.95).

npoints

Integer number of points to generate along ellipse perimeter (default 100).

n

Numeric sample size; required if kind = "se".

Examples

Run this code
cov_mat <- matrix(c(1, 0, 0, 1), 2, 2)
center <- c(0, 0)
ell_coords <- ord_compute_ellipse(cov_mat, center, kind = "se", conf = 0.95, n = 10)
plot(ell_coords, type = "l")

Run the code above in your browser using DataLab