*Stata programming by Example *Tutorial 7 *mata maths *Matrix Addition and Subtraction *--------------Start Example 1 ----------------* mata a=1,1\1,1 a b=2,2\2,2 b c=a+b c d=c-b d end *--------------End Example----------------------* *Matrix Addition and Subtraction *--------------Start Example 2 ----------------* mata a=1,1\1,1 b=2,2\2,2 a b c=a*b c end *--------------End Example----------------------* *Transpose of Matrices *--------------Start Example 3 ----------------* mata a=1,2\3,4 a b=a' b end *--------------End Example----------------------* *The Determinant of a Matrix *--------------Start Example 3 ----------------* mata a=1,2\3,4 a b=det(a) b end *--------------End Example----------------------* *The Inverse of a Matrix *--------------Start Example 4 ----------------* mata a=1,2\3,4 a b=pinv(a) b end *--------------End Example----------------------* *solving simutanous equation *--------------Start Example 5 ----------------* *let *x+2y=c *3x+6y=c *let *x=1 *y=2 mata a=(1,2)\(3,6) a b=5\15 b x=pinv(a)*b x end *--------------End Example----------------------* *end tutorial 7 exit