Fine tuning stat_ellipse() in ggplot2

This is not a real answer, but it might help.

By exploring stat_ellipse with the following commands,

stat_ellipse
ls(ggplot2:::StatEllipse)
ggplot2:::StatEllipse$calculate
ggplot2:::calculate_ellipse
?cov.wt

it seems that cov.wt is estimating the covariance matrix from the simulated data:

cov.wt(data[, c(1, 2)])$cov
#           X1        X2
# X1 1.1120267 0.8593946
# X2 0.8593946 1.0372208

# True covariance matrix:
Sigma
#      [,1] [,2]
# [1,]  1.0  0.8
# [2,]  0.8  1.0

You may consider calculating your p95 values using the estimated covariance matrix. Or just stick with your own well-executed ellipse drawing code.

Tags:

R

Ggplot2