[R] Inverse of data.ellipse function

Tom La Bone booboo at gforcecable.com
Thu Feb 5 02:57:00 CET 2009



The following code generates 85% and 95% bivariate normal confidence
ellipses using the data.ellipse routine in the car package. Can anyone
suggest a routine in R that will tell me the confidence ellipse that would
intersect the green point, or more generally, any specified point on the
plot?

Tom


library(car)

x <- c(
 2.495507,2.800855,1.956886,2.093559,2.317661,2.134128,2.445757,2.449865,
 2.157123,2.656724,2.514258,2.049239,2.302236,2.187003,2.064303,2.307158,
 2.639794,2.095725,2.055517,2.095392,2.499140,1.997258,2.099004,2.485946,
 2.390299,2.380655,1.986580,2.452259,2.016017,2.115884,2.448890,2.039421,
 2.086519,1.905574,2.507067,2.222586,2.232333,2.286176,2.065320,2.136335,
 1.956130,2.211561,2.196912,2.527431,1.935607,2.482722,2.234416,1.892957,
 2.261484,2.172877,2.429097,2.132760,1.915024,2.474201,2.108019,2.098176,
 2.464809,2.242213,2.604528,2.221102,2.226034,2.285435,1.981518,2.026446,
 2.190195,2.108399,2.554589,1.866505,2.569580,2.263412,2.037287,1.723514,
 2.068335,1.960022,2.233751,2.357066,2.164031,2.001292,2.356718,1.974896,
 2.263872,2.483966,2.517231,2.346250,2.072050,2.110444,2.230884,2.501742,
 2.239098,1.858333,2.104560,2.195149,2.501683,2.079934,2.397314,2.152187,
 2.359440,2.111259,2.160616,1.976223)

y <- c(
 -5.600474,-5.661683,-5.007292,-4.874088,-5.339055,-5.858137,-5.594482,
 -5.826471,-5.959325,-6.031502,-5.381492,-5.232014,-5.497670,-5.151676,
 -5.520301,-5.589677,-6.037540,-4.999751,-6.166536,-4.722158,-5.876276,
 -5.420056,-5.773584,-5.428882,-5.669146,-5.546504,-4.973831,-6.201381,
 -5.217770,-4.969737,-5.905475,-5.390086,-5.003606,-4.937802,-5.324172,
 -4.991389,-5.500224,-5.836389,-5.136990,-5.067671,-5.189699,-5.273695,
 -5.761629,-5.400335,-4.672323,-5.390257,-5.176363,-4.747799,-5.246505,
 -5.357218,-5.819997,-5.307132,-4.660002,-5.103505,-5.060687,-5.242942,
 -5.357381,-4.881723,-5.952129,-5.361586,-5.202132,-5.522287,-5.638168,
 -5.589786,-4.997126,-5.116822,-5.786722,-5.205465,-5.836223,-5.730740,
 -5.345793,-5.081353,-4.932470,-5.917560,-5.001224,-5.050188,-5.246825,
 -5.303896,-5.945083,-5.001067,-5.296180,-6.290440,-5.682263,-5.526831,
 -6.298252,-5.361611,-5.422722,-5.356166,-5.618755,-5.141482,-5.472014,
 -4.973340,-5.608222,-4.600451,-5.638057,-5.093730,-5.221353,-5.497442,
 -4.817821,-5.767386)


means <- c(mean(x),mean(y))
sigma2 <- var(cbind(x,y)) 
sx <- sqrt(sigma2[1,1])
sy <- sqrt(sigma2[2,2])


a <- c(means[1]+qnorm(0.975)*sx,means[2]+qnorm(0.975)*sy)
a

plot(x,y)
data.ellipse(x,y,levels=c(0.85,0.95))
points(a[1],a[2],col="green",pch=19)
abline(h=a[2])
abline(v=a[1])

-- 
View this message in context: http://www.nabble.com/Inverse-of-data.ellipse-function-tp21843738p21843738.html
Sent from the R help mailing list archive at Nabble.com.




More information about the R-help mailing list