Confidence Region (Confidence ellipse) plot for Bivariate Data
Part 1: Calculate Rotation Angle.
- Calculate Chi-square critical value based on required confidence (eg. alpha of 0.05, is 95% confidence ellipse).
- Using CHISQ.INV() function in Excel. 2 argument in function is degree of freedom, which is number of variables measured as part of sample data, for bivariate data dof=2.
- Calculate Variance Covariance matrix of sample data.
- Using COV() function of real stats.
- Calculate eigen value of covariance matrix.
- Using eVALUES() function of real stats or using formula considering VarCov matrix.
- sqrt(λ1) is the radius of the major axis (the longer radius)
- sqrt(λ1) is the radius of the major axis (the longer radius)
- Calculate angle from positive X-axis to the ellipse's major axis, in counterclockwise direction
- Using ATAN2() excel function.
- atan2()'s first parameter is y and second is x. atan2(covar, λ1-Var.X).
- θ is the angle in radian.
Part 2: Get the points on Confidence Ellipse
- Calculate rotation matrix, Q, using angle in radian.
- Diagonal elements are, Cos(θ)
- Off diagonal elements are, Sin(θ) and -Sin(θ)
- Create an input column for angle with values 0 to 2π in increments of π/10.
- First cell, angle=0.
- 2nd cell, angel =PI()/10
- 3rd onward, cumulative sum, get values from 0 to 6.28 (21 values)
- Calculate the lengths of the two axes of the ellipse.
- Length of major axis, a, a=sqrt(λ1)*sqrt(Chi-square Critical value).
- Length of minor axis, b, b=sqrt(λ2)*sqrt(Chi-square Critical value).
- Calculate the points on confidence ellipse using formula.
- X-value is, Xmean+(Cos(angle)*dig.of Q*mj_axis)+sin(angle)*offdig.neg.value*mn_axis)
- Y-value is, Ymean+(Cos(angle)*offdigQ*mj_axis)+sin(angle)*dig.value*mn_axis)
- Using Matrix operations, to be demonstrated.
- Get pair of points on confidence ellipse.
Part 3: Plot the graphs of confidence ellipse and include individual data and its mean in plot.
Part 4: Determine if point is inside or outside ellipse using inverse of covariance matrix.
Reference
- Confidence Ellipse Tool | Real Statistics Using Excel (real-statistics.com)
- How to Draw Ellipse of Covariance Matrix (cookierobotics.com)
- Computing prediction ellipses from a covariance matrix - The DO Loop (sas.com)
- 4.6 - Geometry of the Multivariate Normal Distribution | STAT 505 (psu.edu)
- https://github.com/SPICYL/mvda/blob/main/Confidene%20Ellipse.xlsx
Comments
Post a Comment