Confidence Region (Confidence ellipse) plot for Bivariate Data

Part 1: Calculate Rotation Angle.
  1. 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.
  2. Calculate Variance Covariance matrix of sample data. 
    • Using COV() function of real stats.
  3. 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) 
  4. 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
  1. Calculate rotation matrix, Q, using angle in radian.
    • Diagonal elements are, Cos(θ)
    • Off diagonal elements are, Sin(θ) and -Sin(θ)
  2. 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)
  3. 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).
  4. 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.
  5. 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

Comments

Popular posts from this blog

Robust covariance matrix estimation in SPSS

Vignettes for Matrix concepts, related operations