The Confidence 95 Ellipse

[Pages:8]conf95.sdw

2/4/02

1/8

The Confidence 95 Ellipse

Introduction. Important parameters in posturogram analysis are derived from the 95 % confidence ellipse (let's shorten it as Conf95 here). Basically it is the smallest ellipse that will cover 95 % of the points of the COP diagram. Whereas the simple procedure of drawing a perimeter around the COPtrace does not distinguish regions that are more or less frequented, the Conf95 puts more weight on regions more frequently visited. The following figure shows an example with the Conf95 (blue)

catching most of the COP-trace (red). Two important parameters are associated with this ellipse; its area and the inclination of its main axis relative to the medial-lateral axis (x-axis) or anteriorposterior axis (y-axis). The latter shows the directional tendency of the sways.

Computation. The Conf95 ellipse can be computed using the assumption that the coordinates of the COP-points will be approximately Gaussian distributed around their mean.

Generally we have a nonzero correlation between the x-coordinates and y-coordinates. The conf95 ellipse will be chosen so that for coordinates defined with respect to its axes are uncorrelated.

The first step is to subtract the mean values from the x- and y-coordinates of the COP-points.

(1)

xi xi x^ yi yi ^y

F Borg

Bioproject, Chydenius Institute, Finland.

conf95.sdw

2/4/02

2/8

Then, let us compute the 2 ? 2 correlation matrix C for the COP-points:

(2)

( ) C= Cxx Cxy C yx C yy

C xx =

xi2 C xy=C yx=

xi yi C yy=

y

2 i

i

i

i

The ellipse axis-vectors are obtained as the unit eigenvectors e0 and e1 of the matrix C. Suppose the corresponding eigenvalues are 0 1 > 0. Suppose the COP-data consists of N points. According to our construction we may now assume that the coordinates of the COP-points projected on the ellipse axes have Gaussian distributions with means 0 and standard deviations

(3)

0=

0 N1

1=

1 N1

If the coordinates visavis the axes e0 and e1 are denoted and then we may assume that the variables

(4)

0 and 1

are independent having the normal distribution, N(0,1). Especially the variable

(5)

( ) ( ) 2

= 0

2 1

will then have a chi-square distribution of second degree. Since (looking up the tables)

(6)

Prob ( dy) ? dx : dy;

mx = 0; // not used my = 0;

sc = (double)((CanvH < CanvW)? CanvH : CanvW);

x0 = (((dat[0][0] - mx)/maxd) + 0.5)*sc; y0 = (-((dat[1][0] - my)/maxd) + 0.5)*sc;

Oldp.x = RoundRealToNearestInteger(x0); Oldp.y = RoundRealToNearestInteger(y0);

for(i=1; i < rows; i++) {

x1 = (((dat[0][i] - mx)/maxd) + 0.5)*sc; y1 = (-((dat[1][i] - my)/maxd) + 0.5)*sc;

trlength += (maxd/sc)*sqrt ((x0 -x1)*(x0 -x1) + (y0-y1)*(y0-y1));

x0 = x1; y0 = y1;

F Borg

Bioproject, Chydenius Institute, Finland.

conf95.sdw

2/4/02

6/8

Newp.x = RoundRealToNearestInteger(x1); Newp.y = RoundRealToNearestInteger(y1);

CanvasSetPenPosition(panelAnal, OPEN_CANVAS, Oldp); CanvasDrawLineTo(panelAnal, OPEN_CANVAS, Newp);

Oldp.x = Newp.x; Oldp.y = Newp.y;

}

SetCtrlVal(panelAnal, OPEN_LENGTH, trlength);

// plot the confidence ellipse

r95 = sqrt(5.991); // 95% confidence *radius* -- chi-square 2 DF

area = PII*5.991*rr[0]*rr[1]; // area of the ellipse

SetCtrlVal(panelAnal, OPEN_AREA, area);

ellx = rr[0]*evec[0][0]; elly = rr[0]*evec[0][1];

// initial point

ellx *= r95*sc/maxd; elly *= r95*sc/maxd;

Oldp.x = RoundRealToNearestInteger(ellx + sc/2); Oldp.y = RoundRealToNearestInteger(elly + sc/2);

ellx = rr[aindex]*evec[aindex][0]; // the main axis end point elly = rr[aindex]*evec[aindex][1];

ellx *= r95*sc/maxd; elly *= r95*sc/maxd;

x0 = RoundRealToNearestInteger(ellx + sc/2); y0 = RoundRealToNearestInteger(elly + sc/2);

SetCtrlAttribute(panelAnal, OPEN_CANVAS, ATTR_PEN_COLOR, VAL_BLUE);

CanvasDrawLine (panelAnal, OPEN_CANVAS, MakePoint(sc -x0, sc - y0), MakePoint(x0,y0));

for(i=1; i < ELLN; i++) {

// ellipse

u = 2*PII*(double)i/(double)ELLN;

cosu = cos(u); sinu = sin(u);

ellx = rr[0]*cosu*evec[0][0] + rr[1]*sinu*evec[1][0]; elly = rr[0]*cosu*evec[0][1] + rr[1]*sinu*evec[1][1];

ellx *= r95*sc/maxd; elly *= r95*sc/maxd;

Newp.x = RoundRealToNearestInteger(ellx + sc/2); Newp.y = RoundRealToNearestInteger(elly + sc/2);

//

printf("%f\t%i\t%i\n", u, Newp.x, Newp.y);

CanvasSetPenPosition(panelAnal, OPEN_CANVAS, Oldp); CanvasDrawLineTo(panelAnal, OPEN_CANVAS, Newp);

Oldp.x = Newp.x;

F Borg

Bioproject, Chydenius Institute, Finland.

conf95.sdw

2/4/02

7/8

Oldp.y = Newp.y; } // calclutate inclination inclination = asin(evec[aindex][1])*180.0/PII; // if(inclination > 90) inclination = 180 - inclination; SetCtrlVal(panelAnal, OPEN_ANGLE, inclination);

SetCtrlAttribute(panelAnal, OPEN_CANVAS, ATTR_PEN_COLOR, VAL_BLACK);

CanvasDrawLine (panelAnal, OPEN_CANVAS, MakePoint(0, 94), MakePoint(188,94));

// x-axis

CanvasDrawLine (panelAnal, OPEN_CANVAS, MakePoint(94, 0), MakePoint(94,188));

for(j = 0; j < cols; j++) { // graphs

MaxMin1D (dat[j], rows, &max[j], &maxi[j], &min[j], &mini[j]); Scale1D (dat[j], rows, dat[j], &offset[j], &scale[j]); LinEv1D (dat[j], rows, 50, 50 + j*100, dat[j]);

ploth[j] = PlotY (panelAnal, OPEN_GRAPH, dat[j], rows, VAL_DOUBLE, VAL_THIN_LINE, VAL_EMPTY_SQUARE, VAL_SOLID, 1, VAL_RED);

ctrlID[j] = NewCtrl (panelAnal, CTRL_NUMERIC, "Max", 356 - j*63 , 680); //max ctrlID[6+j] = NewCtrl (panelAnal, CTRL_NUMERIC, "Min",386 - j*63 , 680); //max

SetCtrlAttribute (panelAnal, ctrlID[j], ATTR_LABEL_LEFT, 650); SetCtrlAttribute (panelAnal, ctrlID[j], ATTR_LABEL_TOP, 356 - j*63); SetCtrlAttribute (panelAnal, ctrlID[j], ATTR_CTRL_MODE, VAL_INDICATOR);

SetCtrlAttribute (panelAnal, ctrlID[j+6], ATTR_LABEL_LEFT, 650); SetCtrlAttribute (panelAnal, ctrlID[j+6], ATTR_LABEL_TOP, 386 - j*63); SetCtrlAttribute (panelAnal, ctrlID[j+6], ATTR_CTRL_MODE, VAL_INDICATOR);

SetCtrlVal(panelAnal, ctrlID[j], max[j]);

SetCtrlVal(panelAnal, ctrlID[6+j], min[j]); }

for(j = 0; j < cols; j++) free(dat[j]); free(vel[0]); free(vel[1]);

}

return err; } // end of AnalysBal()

Appendix B. Eigenvectors of a symmetric 2 ? 2 matrix. In the above algorithm we need the eigenvectors and eigenvalues of a symmetric 2 by 2 matrix (computed by the function SymEigenValueVector() above). First the eigenvalues of the symmetric matrix C (cxy = cyx) are

F Borg

Bioproject, Chydenius Institute, Finland.

conf95.sdw

2/4/02

8/8

determined by the solutions to

(10)

| | cxx cxy =0 c yx c yy

which are

(11)

( ) ?= cxx 2 cyy ? cx2y

cxx c yy 2 2

The eigenvectors v are solutions of

(12)

( )( ) cxx cxy c yx c yy

vx =0 vy

Thus

(13)

vy = cxx

vx

cxy

and the orthonormal eigenvectors are therefore given by ( cxy 0)

(14)

( ) ( ) e?= 1

1 cxx ? 2

cxy

1 cxx ?

cxy

The angle of inclination (visavis the x-axis) is finally determined from

cos ()=

1

(15)

( ) 1

cxx + 2

cxy

In order to draw the Conf95 ellipse we can use the parametric representation (0 u < 2 )

(16) r (u)=cos(u) 5.991 0 e0 sin (u) 5.991 1 e1

F Borg

Bioproject, Chydenius Institute, Finland.

................
................

In order to avoid copyright disputes, this page is only a partial summary.

Google Online Preview   Download