In: Statistics and Probability
Create a square, almost symmetric 4 X 4 matrix B with values 1, 2, 3 and 4 on the diagonal. Let values off diagonal be between 0.01 and 0.2. Almost symmetric matrix is not a scientific term. It just means that most of the off diagonal terms on transpose positions are close in value:
1. Determine matrix BINV which is an inverse of matrix B;
2. Demonstrate that the matrix multiplied by its inverse produces a unit matrix. Unit
matrix has all elements on the diagonal equal to 1 and all other equal to 0;
3. Find eigen values of Matrix B and matrix BINV;
4. Find eigen values of matrix t(B) where t(0 is transpose function.
Please R studio.
Creating almost symmetric 4 * 4 matrix B with values 1,2,3 and 4 on the diagonal and off-diagonal values between 0.01 and 0.2
#CREATING COLUMNS IN MATRIX
m1 = matrix(c(1,0.05,0.10,0.15))
m2 = matrix(c(0.045,2,0.12,0.16))
m3 = matrix(c(0.095,0.115,3,0.2))
m4 = matrix(c(0.145,0.156,0.197,4))
#MATRIX: 4*4 WITH DIAGONAL VALUES 1,2,3,4
B <- cbind(m1,m2,m3,m4)
B
Result
[,1] [,2] [,3] [,4]
[1,] 1.00 0.045 0.095 0.145
[2,] 0.05 2.000 0.115 0.156
[3,] 0.10 0.120 3.000 0.197
[4,] 0.15 0.160 0.200 4.000
Q1. Determining BINV, inverse of matrix B
# INVERSE OF MATRIX
BINV <- solve(B)
BINV
Result
[,1] [,2] [,3] [,4]
[1,] 1.00897199 -0.01820934 -0.02895683 -0.03443895
[2,] -0.02070424 0.50295179 -0.01742375 -0.01800647
[3,] -0.03047408 -0.01829492 0.33598158 -0.01472891
[4,] -0.03548458 -0.01852048 -0.01501625 0.25274816
Q2. Matrix B multiplied with its inverse BINV
# UNIT MATRIX
I <- zapsmall(B%*%BINV)
I
Result
[,1] [,2] [,3] [,4]
[1,] 1 0 0 0
[2,] 0 1 0 0
[3,] 0 0 1 0
[4,] 0 0 0 1
Q3. Find eigen values of Matrix B and matrix BINV
# EIGEN VALUES FOR MATRIX B
Bev <- eigen(B)
Bev$values
Result
[1] 4.0624422 2.9718147 1.9780407 0.9877024
# EIGEN VALUES FOR MATRIX BINV
BINVev <- eigen(BINV)
BINVev$values
Result
[1] 1.0124507 0.5055508 0.3364947 0.2461574
Q4. Find eigen values of matrix t(B)
# TRANSPOSE MATRIX B
Bt <- t(B)
Bt
Result
[,1] [,2] [,3] [,4]
[1,] 1.000 0.050 0.100 0.15
[2,] 0.045 2.000 0.120 0.16
[3,] 0.095 0.115 3.000 0.20
[4,] 0.145 0.156 0.197 4.00
# EIGEN VALUES FOR TRANSPOSE MATRIX B
Btev <- eigen(Bt)
Btev$values
Result
[1] 4.0624422 2.9718147 1.9780407 0.9877024