The Trace of a Matrix c Copyright 2012 Dan Nettleton (Iowa State University) Statistics 611 1 / 11 The trace of a square matrixn×n A = [aij ] is trace(A) = tr(A) = n X aii . i=1 For example, 5 3 5 tr 4 −1 2 = 5 − 1 + 7 = 11. −3 c Copyright 2012 Dan Nettleton (Iowa State University) 8 7 Statistics 611 2 / 11 Some Simple Facts about Trace Suppose k, k1 , . . . , km ∈ R and A, A1 , . . . , Am are each n × n matrices. Then 1 tr(A) = tr(A0 ) 2 tr(kA) = k · tr(A) 3 tr(A1 + A2 ) = tr(A1 ) + tr(A2 ) 4 tr( Pm i=1 ki Ai ) = Pm i=1 ki · tr(Ai ) c Copyright 2012 Dan Nettleton (Iowa State University) Statistics 611 3 / 11 Result A.17: (a) tr(AB) = tr(BA). This is known as the cyclic property of the trace. (b) Ifm×n A = [aij ], then 0 tr(A A) = m X n X a2ij . i=1 j=1 Proof of Result A.17: HW problem. c Copyright 2012 Dan Nettleton (Iowa State University) Statistics 611 4 / 11 Suppose A is an m × n matrix of rank r. Prove that there exist matrices B and r×n C such that m×r A = BC and rank(B) = rank(C) = r. c Copyright 2012 Dan Nettleton (Iowa State University) Statistics 611 5 / 11 Proof: Let B = [b1 , . . . , br ] where b1 , . . . , br form a basis for C(A). Because b1 , . . . , br form a basis, they are LI so that rank(B) = r. Let cj be the vector of the coefficients of the linear combination of b1 , . . . , br that gives the jth column of A. Then A = BC, where C = [c1 , . . . , cn ]. Finally, note that r = rank(A) = rank(BC) ≤ rank(C) ≤ r ⇒ rank(C) = r. c Copyright 2012 Dan Nettleton (Iowa State University) Statistics 611 6 / 11 Suppose A is an n × n matrix such that AA = kA for some k ∈ R. Prove that tr(A) = k · rank(A). (Note that this result implies the trace of an idempotent matrix is equal to its rank.) c Copyright 2012 Dan Nettleton (Iowa State University) Statistics 611 7 / 11 Proof: Let r = rank(A). Let n×r B and r×n C be matrices of rank r such that A = BC. Then BCBC = AA = kA = kBC = B(kr×r I )C. Now B of full column rank implies CBC = kr×r I C, and C of full row rank implies CB = kr×r I. Thus, tr(A) = tr(BC) = tr(CB) = tr(kr×r I ) = k · tr(r×r I ) = k · r = k · rank(A). 2 c Copyright 2012 Dan Nettleton (Iowa State University) Statistics 611 8 / 11 Prove that tr(I − PX ) = n − rank(X). c Copyright 2012 Dan Nettleton (Iowa State University) Statistics 611 9 / 11 Proof: We know I − PX is idempotent. Thus, tr(I − PX ) = rank(I − PX ). We know I − PX is the orthogonal projection matrix onto C(X)⊥ = N (X0 ). Thus, C(I − PX ) = N (X0 ), which has dimension n − rank(X). Thus, rank(I − PX ) = n − rank(X). c Copyright 2012 Dan Nettleton (Iowa State University) Statistics 611 10 / 11 Alternate Proof: Because PX is idempotent, tr(PX ) = rank(PX ). Now note that rank(PX ) = rank(X) because rank(PX ) = rank(X(X0 X)− X0 ) ≤ rank(X) = rank(PX X) ≤ rank(PX ). (This also follows from C(X) = C(PX ).) Thus, tr(I − PX ) = tr(I) − tr(PX ) = n − tr(PX ) = n − rank(X). c Copyright 2012 Dan Nettleton (Iowa State University) Statistics 611 11 / 11