#NGroups 4 Likelihood Example Calculation Begin Matrices; X Full 2 1 ! Data Vector M Full 2 1 ! Vector of Means S Symm 2 2 ! Covariance Matrix P Full 1 1 ! Scalar Pi T Full 1 1 ! Scalar 2 H Full 1 1 ! Scalar .5 End Matrices; Matrix X .5 -.3 ! was .5 -.3 Matrix M 0 0 Matrix S 1 .5 1 Matrix P \pi ! 3.141592 Matrix T 2 Matrix H -.5 Begin Algebra; A= (X-M)'; ! Deviations of X Values from Means B= S~; ! Inverse of Covariance Matrix C= A&B; ! Mahalanobis Distance (x-m)'S~(x-m) D=\exp(H@C); ! e^(-.5 (x-m)'S~(x-m)) E=(T.P)@\sqrt(\det(S)); ! 2pi sqrt|S| F= E~*D; ! At last, the likelihood G= -T*\ln(F); ! Now -2ln L End Algebra; End Title As if we hadn't had enough, we now do it via \pdfnor Calculation Begin Matrices = Group 1; ! Note how we get all the matrices from group 1 X full 2 1 ! But because the data were separate, we need a vector for them End Matrices; Matrix X .5 -.3 Begin Algebra; F = \pdfnor(X'_M'_S); ! Here's the height of the bivariate normal at that point G = \ln(F); ! Here's the logarithm of the height (aka likelihood) J = -G-G; ! And finally, -2lnL again End Algebra; End