Home » 367_HD04

367_HD04

*Foundations of Econometrics, Fall 2015, Prepared by Dr. I-Ming Chiu
*Accompany 367_Handout04.pdf

 

/*Matrix Operations using Mata*/

clear
mata

/*column joiner (,) and row joiner (\)*/
a = 1, 2
b = 3, 4
c = 4\5\6
d = 4,5,6

e = 4::6
f = 4..6

A = a\b

s = 2
s*A /*scalar multiplication*/

/*matrix multiplication*/
B = (1,2,-1)\(-1,0,2)

*Does this one work?
B*A
*How about this one?
A*B

/*matrix transpose*/
B’

/*matrix determinant*/
det(A)

/*matrix inverse*/
invA = luinv(A)
A*invA

W = (A, (0\1))\B
W[1,.]W[.,2]W[2::4,2..3]W[(2,4),(2,3)]

/*examples from Handout#4*/
A1 = (3,2)\(1,-1)
b1 = 0\-2
X1 = luinv(A1)*b1

*Do the supply/demand model by yourself

end