Matrix form of the Bayes theorem and diagnostic tests
Abstract
In order to solve certain problems in calculating probabilities, such as Markov chains or conditional specification of discrete distributions, the use of matrix and vector treatment of conditioned probabilities and of vectors of marginal probabilities is common. Following these ideas, the present study obtains matrix forms of some elementary results of probability theory, such as the total probability and Bayes theorems. These results and methodology are applied to the matrix study of results of diagnostic tests, allowing an immediate generalization to tests with more than two results. In addition,we propose safety and validity measures of a test based on matrix rules, which in some cases are related to the well-known Youden index.
Full text
IOSR Journal of Mathematics (IOSR-JM) e-ISSN: 2278-5728, p-ISSN: 2319-765X. Volume 14, Issue 6 Ver. I (Nov - Dec 2018), PP 01-06 www.iosrjournals.org DOI: 10.9790/5728-1406010106 www.iosrjournals.org 1 | Page Matrix Form of The Bayes Theorem And Diagnostic Tests María Magdala Pérez-Nimo1 José A. Camúñez-Ruiz1 1Departamento de Economía Aplicada I Universidad de Sevilla Facultad de Ciencias Económicas y Empresariales Avda. Ramón y Cajal 1 41008 Sevilla Spain Corresponding Author; María Magdala Pérez-Nimo Abstract: In order to solve certain problems in calculating probabilities, such as Markov chains or conditional specification of discrete distributions, the use of matrix and vector treatment of conditioned probabilities and of vectors of marginal probabilities is common. Following these ideas, the present study obtains matrix forms of some elementary results of probability theory, such as the total probability and Bayes theorems. These results and methodology are applied to the matrix study of results of diagnostic tests, allowing an immediate generalization to tests with more than two results. In addition,we propose safety and validity measures of a test based on matrix rules, which in some cases are related to the well-known Youden index. Key Word: Conditioned Probabilities, BayesTheorem, Matrix, Diagnostic Tests --------------------------------------------------------------------------------------------------------------------------------------- Date of Submission: 01-11-2018 Date of acceptance: 15-11-2018 --------------------------------------------------------------------------------------------------------------------------------------- I. Introduction In the Markov chain theory ([1];[2]) as well as in conditional specification problems for finite random variables [3], the matrix treatment of conditional probabilities is common. This line is followed in the present study, and the main results of conditional probabilities are obtained, including a matrix form of the Bayes' theorem. The results obtained, are applied to the study of diagnostic test. II. Matrix Approach Let us consider two complete sets of events, 12 , ,..., ,..., in A A A A and 12 , ,..., ,..., jm B B B B , both with nonzero probabilities 12 ( ), ( ),..., ( ),..., ( ) jm P B P B P B P B . We define the 12 ( ), ( ),..., ( ),..., ( ) in P A P A P A P A vectors. 1 2 () () () n PA PA PA α 1 2 () () () m PB PB PB β And the matrices (( )) ( | ), 1,2,..., ; 1,2,..., ij ij i j a a P A B i n j m A 1 1 1 2 1 2 1 2 2 2 12 ( | ) ( | ) ... ( | ) ( | ) ( | ) ... ( | ) ( | ) ( | ) ... ( | ) m m n n n m P A B P A B P A B P A B P A B P A B P A B P A B P A B A (( )) ( | ), 1,2,..., ; 1,2,..., ij ij j i b b P B A j m i n B
Matrix Form Of The Bayes Theorem And Diagnostic Tests DOI: 10.9790/5728-1406010106 www.iosrjournals.org 2 | Page 1 1 2 1 1 1 2 2 2 2 12 ( | ) ( | ) ... ( | ) ( | ) ( | ) ... ( | ) ( | ) ( | ) ... ( | ) m m n n m n P B A P B A P B A P B A P B A P B A P B A P B A P B A B Both matrices have n×m dimension. We denote n 1 the column vector of n dimension with all its components equal to one, and by n 0 the column vector of n dimension with all components equal to zero. On the other hand, it should be remembered that a matrix is said to be stochastic by rows (columns) if it is non-negative and the sum of the elements in each row (column) is equal to one. Note that n tt m 1 A 1 and mn B1 1 , therefore, A is stochastic by columns and B is stochastic by rows. In [3] Arnold and Press obtain the theorem 1: Theorem 1. (Total probability theorem, matrix form). Aβα t Bαβ Demonstration: we rely on the total probability theorem in its usual form: 1 1 1 2 1 1 2 1 2 2 2 2 12 ( | ) ( | ) ... ( | ) ( ) ( | ) ( | ) ... ( | ) ( ) ( | ) ( | ) ... ( | ) ( ) m m n n n m m P A B P A B P A B P B P A B P A B P A B P B P A B P A B P A B P B Aβ 1 1 1 22 1 1 ( | ) ( ) () ( | ) ( ) () () ( | ) ( ) m jj j m jj j n m n j j j P A B P B PA P A B P B PA PA P A B P B α Similarly, it is shown that t Bαβ . Theorem 2. The matrices t AB and t BA have eigenvalue one with α and β eigenvectors associated with that value and, respectively, each matrix. Demonstration: combining the formulas of the previous theorem we have: t Aβ α AB α α tt Bα β B Aβ β As a result: ( ) det( ) 0 t t t n n n AB α α AB - I α 0 AB - I ( ) det( ) 0 t t t m m m BAβ β B A-I β 0 B A-I Theorem 3. 2 2 t α Aβ α 2 2 tt β B α β 2 2 t α Bβ β Demonstration: Just need to apply Theorem 1. 2 2 tt α Aβ α α α
Matrix Form Of The Bayes Theorem And Diagnostic Tests DOI: 10.9790/5728-1406010106 www.iosrjournals.org 3 | Page 2 2 t t t β B α β β β On the other hand, the last equality is obtained by transposing the second. Let M be the matrix of the probabilities of the intersections of the two complete sets of events: 1 1 1 2 1 2 1 2 2 2 12 ( ) ( ) ... ( ) ( ) ( ) ... ( ) ( ) ( ) ... ( ) m m n n n m P AB P AB P AB P A B P A B P A B P A B P A B P A B M Theorem 4. (Non-conditional total probability theorem). tt n 1M β n t M1 β m M1 α Demonstration: Simply operate on the first member of each equation, 1 1 1 2 1 2 1 2 2 2 12 12 1 1 1 ( ) ( ) ... ( ) ( ) ( ) ... ( ) 1 1 ... 1 ( ) ( ) ... ( ) ( ) ( ) ... ( ) m m n n n m n n n i i i m i i i P AB P AB P AB P A B P A B P A B P A B P A B P A B P AB P AB P AB t n t 1M β The second equality is obtained by transposition of the first. The third equality is demonstrated latter is tested as the first one.□ Let () nM be the set of square matrices of n dimension. Let us now define the application : ( ) n nn DM , which associates to each vector n v the square matrix whose diagonal is v and the rest of elements are null. If there is no room for confusion we will omit the n subscript, that is, n DD . In this way, we obtain: 1 2 ( ) 0 ... 0 0 ( ) ... 0 0 0 ... ( ) n PA PA PA D(α) 1 2 ( ) 0 ... 0 0 ( ) ... 0 0 0 ... ( ) m PB PB PB D(β) Theorem 5. AD(β) M D(α)B Demonstration: 1 1 1 2 1 1 2 1 2 2 2 2 12 ( | ) ( | ) ... ( | ) ( ) 0 ... 0 ( | ) ( | ) ... ( | ) 0 ( ) ... 0 ( | ) ( | ) ... ( | ) 0 0 ... ( ) m m n n n m m P A B P A B P A B P B P A B P A B P A B P B P A B P A B P A B P B AD(β)
Matrix Form Of The Bayes Theorem And Diagnostic Tests DOI: 10.9790/5728-1406010106 www.iosrjournals.org 4 | Page 1 1 1 1 2 2 1 2 1 1 2 2 2 2 1 1 2 2 1 1 1 2 1 2 1 2 2 2 ( | ) ( ) ( | ) ( ) ... ( | ) ( ) ( | ) ( ) ( | ) ( ) ... ( | ) ( ) ( | ) ( ) ( | ) ( ) ... ( | ) ( ) ( ) ( ) ... ( ) ( ) ( ) ... ( ) ( mm mm n n n m m m m P A B P B P A B P B P A B P B P A B P B P A B P B P A B P B P A B P B P A B P B P A B P B P AB P AB P AB P A B P A B P A B PA 12 ) ( ) ... ( ) n n n m B P A B P A B M The demonstration of the other equality is analogous. Theorem 6.(Bayes' theorem, matrix form). -1 A D(α)BD(β) -1 B D(α) AD(β) Its proof is an immediate consequence of Theorem 5. 3.- Diagnostic tests. Consider a clinical test for the diagnosis of a certain disease (see, [4]). Suppose, as is usual in this context, that each patient can be sick (event D) or healthy and that the test can only present positive results (event R) if it detects the disease, and negative results otherwise. Define the vectors: Disease prevalence vector: () () PD PD α . It contains, among other elements, the prevalence of the disease P(D) Test results vector: () () PR PR β . Containing the probabilities of positive and negative results, ()PR and ()PR . We also define the matrices: Test security matrix: ( | ) ( | ) ( | ) ( | ) P D R P D R P D R P D R A It contains, among other elements, the predictive values of the test, ( | )P D R (positive) and ( | )P D R (negative). Test validity matrix: ( | ) ( | ) ( | ) ( | ) P R D P R D P R D P R D B . It contains, among other elements, ( | )P R D sensitivity and ( | )P R D specificity. Test Matrix: ( ) ( ) ( ) ( ) P D R P D R P D R P D R M . Containing the true positives ()P D R , true negatives ()P D R , false positives ()P D R and false negatives ()P D R . The relation between the test matrix and the prevalence and results vectors is then obtained in matrix form 2 M1 α and t2 M1 β : as well as the relation between all the elements of a diagnostic test: AD(β) M D(α)B . On the other hand, applying the forms of the total probability theorem and the Bayes' theorem, we obtain t -1 A D(B α) BD(α) . This is the matrix version of well-known formulas of the type
Matrix Form Of The Bayes Theorem And Diagnostic Tests DOI: 10.9790/5728-1406010106 www.iosrjournals.org 5 | Page 1 1 prevalencexsensibility TPV prevalencexsensibility prevalence specificity , which correlates prevalence, sensitivity and specificity with predictive values. Note that the use of matrices allows an easy generalization to tests with several levels of diagnosis or to diseases with different typologies. In addition, it allows definingtest security measures and indexes in terms of distances. The safety of a test usually requires the study of its predictive values. A test is completely safe if ( | ) ( | ) 1P D R P D R .That is, both predictive values are worth one. For these tests, the safety matrix A defined above is the unit . In this case, a safety measure for a test with the safety matrix A, can be defined as a certain distance from the matrix A to the identity ( ) ( , ) || ||MS d A I A I A , for some matrix norm (See, for instance, [5]). For a completely unsafe test these measures are worth zero. For a completely useless test, that is, ( | ) ( | ) 0P D R P D R , the safety matrix is 01 10 J and MS(J)must be maximal. Its value will depend on the norm used. Normalizing and transferring the MS measure,security indexes -SIcan be obtained, so that if the maximum value of MS is then 1MS SI ,taking values between 0 and 1. The test is completely safe if it takes the value 1 and completely useless when it takes the value 0. Let's look at some specific cases. i.-Row norm. 1 ( | ) ( | ) ( ) || || ( | ) 1 ( | ) |1 ( | )| | ( | )|,| ( | )| |1 ( | )| P D R P D R MS P D R P D R máx P D R P D R P D R P D R A ( ) ( | ) ( | ) 0 ( ) 2 MS P D R P D R MS A A By normalizing, we obtain the associated safety index, ( | ) ( | ) ( ) 1 2 P D R P D R SI A ii.-Column norm. 11 1 ( | ) ( | ) ( ) || || ( | ) 1 ( | ) |1 ( | )| | ( | )|,| ( | )| |1 ( | )| P D R P D R MS P D R P D R máx P D R P D R P D R P D R A 1 1 ( ) 2 ( | ), ( | ) 0 ( ) 2 MS máx P D R P D R MS A A By normalizing we obtain the associated safety index, 1( ) 1 max ( | ), ( | )SI P D R P D RA iii.-Euclidean or spectral norm. 1 ( | ) ( | ) ( ) || - || || || ( | ) 1 ( | ) s s s P D R P D R MS P D R P D R A I A
Matrix Form Of The Bayes Theorem And Diagnostic Tests DOI: 10.9790/5728-1406010106 www.iosrjournals.org 6 | Page which is the square root of the greatest singular value. The singular values of that matrix are 0 and 22 2 ( | ) ( | )P D R P D R thus: 22 ( ) || || 2 ( | ) ( | ) 0 ( ) 2 ss s MS P D R P D R MS A I A A The associated safety index is 22 ( | ) ( | ) ( ) 1 2 s P D R P D R SI A . The same reasoning may be used with the validity matrix Band define test validity measures and indexes. It must be taken into account that for sensitivity and specificity equal to one, we have that B = I, ( ) ( , ) || ||MV d B I B I B and the maximum validity is found for zero MV, while the maximum validity is given in the case of B = J. Norm MV Index Row ( | ) ( | )P R D P R D ( | ) ( | ) 12 P R D P R D Column 2 ( | ), ( | )máx P R D P R D 1 ( | ), ( | )máx P R D P R D Spectral 22 2 ( | ) ( | )P R D P R D 22 ( | ) ( | ) 12 P R D P R D MV is bounded between 0 and 2 in the three cases studied. Note that in the case of the row norm, the validity index 1 2 Y VI ,where Y is the well-known Youden index ([6]). In addition, this way of dealing with conditional probabilities can be used in teaching as a nexus between subjects containing elementary theory of probability and those containing elements of linear algebra, which are usually separated. References. [1]. Berman A. Plemmons R.J. (1994) Nonnegative Matrices in the Mathematical Sciences. SIAM. Piladelphia [2]. Isaacson D.L. y Madsen R.W. (1976) Markov Chain: Theory and aplications. John Wiley and Sons. New York. [3]. Arnold B.C. Press S. J. (1989) Compatible conditional distributions. Journal of the American Statistical Association. 84, 152-156 [4]. ] Gordis, L. (2014) Epidemiology. 5ª edición. Elsevier Saunders Philadelphia [5]. Schott J.R.(1997) Matrix Analysis for Statistics John Wiley and sons New York. [6]. Youden, W.J. (1950). Index for rating diagnostic tests. Cancer 3: 32–35. María Magdala Pérez-Nimo. " Matrix Form Of The Bayes Theorem And Diagnostic Tests." IOSR Journal of Mathematics (IOSR-JM) 14.6 (2018): 01-06.