I am new to world of matrix, sorry for this basic question I could not figure out:
I have four matrix (one unknown).
Matrix X
x <- c(44.412, 0.238, -0.027, 93.128, 0.238, 0.427, -0.193, 0.673, 0.027,
-0.193, 0.094, -0.428, 93.128, 0.673, -0.428, 224.099)
X <- matrix(x, ncol = 4 )
Matrix B : need to be solved , 1 X 4 (column x nrows), with b1, b2, b3, b4 values
Matrix G
g <- c(33.575, 0.080, -0.006, 68.123, 0.080, 0.238, -0.033, 0.468, -0.006,
-0.033, 0.084, -0.764, 68.123, 0.468, -0.764, 205.144)
G <- matrix(g, ncol = 4)
Matrix A
a <- c(1, 1, 1, 1) # one this case but can be any value
A <- matrix(a, ncol = 1)
Solution:
B = inv(X) G A # inv(X) is inverse of the X matrix multiplied by G and A
I did not know how to solve this properly, particularly inverse of the matrix. Appreciate your help.
A more computationally stable solution is to use
qr
rather thansolve
.See the examples in
?qr
.I'm guessing that Nick and Ben are both teachers and have even greater scruples than I do about doing other peoples' homework, but the path to a complete solution was really so glaringly obvious that it didn't make a lot of sense not to tae the next step:
The QR method of inversion can be invoked by supplying an identity matrix as the second argument: