Skip to contents

Compute the coordinate points of confidence ellipses at a specified confidence level.

Usage

confidence_ellipse(
  .data,
  x,
  y,
  .group_by = NULL,
  conf_level = 0.95,
  robust = FALSE
)

Arguments

.data

data frame or tibble.

x

column name for the x-axis variable.

y

column name for the y-axis variable.

.group_by

column name for the grouping variable (NULL by default). Note that this grouping variable must be a factor.

conf_level

confidence level for the ellipse (0.95 by default).

robust

optional (FALSE by default). When set to TRUE, it indicates that robust estimation method is employed to calculate the coordinates of the ellipse. The location is the 1-step M-estimator with the biweight psi function. The scale is the Minimum Covariance Determinant (MCD) estimator. Raymaekers and Rousseeuw (2019).

Value

Data frame of the coordinates points.

Author

Christian L. Goueguel

Examples

# Data
data("glass", package = "ConfidenceEllipse")
# Confidence ellipse
ellipse <- confidence_ellipse(.data = glass, x = SiO2, y = Na2O)
ellipse_grp <- confidence_ellipse(
.data = glass,
x = SiO2,
y = Na2O,
.group_by = glassType
)