Draws a contour of constant density at the (1-alpha
)100% level for a bivariate normal distribution using the eigendecomposition of the covariance matrix. This is likely more interesting for learning about the bivariate normal distribution than as a practical tool, for which other functions already exist (e.g. link[graphics]{contour}
).
bvNormalContour(mu = c(0,0), Sigma=NULL, eig=NULL, xl = NULL, yl = NULL,
axes = TRUE, center = FALSE, lim.adj = 0.02, alpha = 0.05, ...)
a vector giving the mean of the bivariate normal distribution. This is the center of the ellipse.
a matrix giving the covariance matrix of the bivariate normal distribution. Either Sigma
or eig
must be specified.
the eigenvalues and eigenvectors of the covariance matrix. This should be of the same form as the output of eigen
, namely a list with two components: values
and vectors
. It is assumed that the largest eigenvalue is given first. Either Sigma
or eig
must be specified.
a vector giving the lower and upper limits of the x-axis for plotting. If xl = NULL
(default), then reasonable values are computed automatically.
a vector giving the lower and upper limits of the y-axis for plotting. If yl = NULL
(default), then reasonable values are computed automatically.
logical. If axes = TRUE
(default) then the major and minor axes of the ellipse are plotted.
logical. If axes = TRUE
then the center of the ellipse is indicated with a point and dashed lines are drawn to the x-axis and y-axis.
a value giving an adjustment to the x-axis and y-axis limits computed if either xl = NULL
or yl = NULL
. Essentially this is a way to have some coarse control over these limits for quick graphing: positive values will increase the distance between the upper and lower limits (making the ellipse appear smaller) while negative values will decrease the distance (and make the ellipse appear larger).
a value giving the value of alpha to be used when computing the contour. Contours are drawn at the 1-alpha
level.
other arguments to be passed to the graphing functions.
None
Johnson, R. A., & Wichern, D. W. (2007). Applied multivariate statistical analysis (6th ed). Pearson Prentice Hall.
# NOT RUN {
mu <- c(-1,8)
Sigma <- matrix(c(3,2,2,4), ncol = 2)
# Draw a 90% contour
bvNormalContour(mu = mu, Sigma = Sigma, alpha = 0.10)
# }
Run the code above in your browser using DataLab