Advanced Statistics W2: Matrix Algebra Basics
Advanced Statistics W2: Matrix Algebra Basics
Advanced Statistics W2: Matrix Algebra Basics
Advanced Statistics
W2: Matrix Algebra Basics
Titis Wijayanto
Industrial Engineering, UGM
Why matrix?
l
a11 ,, a1n
a 21 ,, a 2n
A=
= {Aij}
am1 ,, amn
[m x 1] matrix
a1
a 2
a = = {ai}
am
5 4 7
B = 3 6 1
2 1 3
[1 x n] matrix
1 2
A=
3 4
a b
B=
c d
If A = B
Then a = 1, b = 2, c = 3, d = 4
Symmetric matrix:
Ex:
is a skew-symmetric, find a, b, c?
0 1 2
A = a 0 3
b c 0
0 a b
A = 1 0 c
2 3 0
Sol:
Ex:
Sol:
0 1 2
If A = a 0 3
b c 0
1 2 3
If A = a 4 5
b c 6
is symmetric, find a, b, c?
1 2 3
1 a b
T
A = a 4 5 A = 2 4 c
b c 6
3 5 6
A = AT a = 1, b = 2, c = 3
A = AT
a = 2, b = 3, c = 5
d1
0
A = diag (d1 , d 2 ,!, d n ) =
"
0
Trace:
If A = [aij ]nn
0
d2
"
0
0
! 0
M nn
# "
! d n
1
0
I =
0
0 0 0
1 0 0
0 1 0
0 0 1
a11 a 21 ,, am1
a12 a 22 ,, am 2
A' =
a1n a 2n ,, amn
(1) ( AT )T = A
(2) ( A + B)T = AT + BT
(3) (cA)T = c( AT )
(4) ( AB)T = BT AT
Matrix operations
Matrix operations
Scalar multiplication:
Matrix addition:
1 2 1 3 1 + 1 2 + 3 0 5
0 1 + 1 2 = 0 1 1 + 2 = 1 3
1 1
3 + 3 =
2 2
1 1 0
3 + 3 = 0
2 + 2 0
A B = A + (1) B
Ex 3: (Scalar multiplication and matrix subtraction)
1 2 4
A = 3 0 1
2 1 2
0 0
2
B = 1 4 3
3 2
1
Matrix operations
Matrix operations
Ex 4: (Find AB)
Matrix multiplication:
3
1
A = 4 2
0
5
Sol:
1j
"
"
"
b
"
b
!
b
21
2j
2n
=
ai1 ai 2 ! ain
"
"
"
" ci1 ci 2 ! cij ! cin
"
"
"
b ! bnj ! bnn
an1 an 2 ! ann n1
Notes: (1) A+B = B+A, (2)
3 2
B=
4 1
AB BA
(5)(2) + (0)(1)
(5)(3) + (0)(4)
9 1
= 4 6
15 10
Matrix operations
Determinants
"
am1 x1 + am 2 x2 + ! + amn xn = bm
m linear equations
am1 am 2 " amn xn bm
=
m n n 1
m 1
Consider
A M nn
Note:
A matrix that does not have an inverse is called noninvertible (or
Positive
Negative
singular).
AB = I
C ( AB ) = CI
(CA) B = C
IB = C
B=C
(2) AA1 = A1 A = I
A1
Corresponding to
3 2
=4
Is it true that
?
Ax = x
If is an eigenvalue of A and x is an eigenvector
belonging to , any nonzero multiple of x will be an
eigenvector
(A I)x = 0
The product of the n eigenvalues equals the determinant.
The sum of the n eigenvalues equals the sum of the n diagonal
entries (trace).
2 1
A =
1 2
Quiz
1. Find the eigenvalues of these matrices. All powers have the same
eigenvectors.
Matrix in R
Matrix in R
Matrix operation
Making a Matrix in R
A <matrix(data=c(7,18,-2,22,-16,3,55,1,9,-4,0,31),byrow=
TRUE,nrow=3,ncol=4)
#check the dimensions
dim(A)
Making an Identity Matrix (I) in R
id <- function(n)diag(c(1),nrow=n,ncol=n)
# To create an identity matrix of order 12
I12 <- id(12)
Transposition
At <- t(A)
# t() is the transpose function
Diagonals
diag(A)
Addition/Substraction of matrix
A+A
#addition of matrix A and A
Multiplication of matrices
A%*$At
#matrix At multiplied by A