Dear R-listers Now I have a Matrix Equation to solve, A -- m by n matrix, where n>>m, known matrix; X -- n by m unknown matrix; B -- m by m known matrix. So given the equation A*X=B, how to solve X? I first tried to take X = inv((A'*A))*A'. But since A'*A is singular, this is no way to go. Please give me some point on this. Thanks Fred
Matrix Equation Help?
5 messages · Feng Zhang, Uwe Ligges, Spencer Graves +1 more
Feng Zhang wrote:
Dear R-listers Now I have a Matrix Equation to solve, A -- m by n matrix, where n>>m, known matrix; X -- n by m unknown matrix; B -- m by m known matrix. So given the equation A*X=B, how to solve X?
You already mentioned it: ?solve Uwe Ligges
I first tried to take X = inv((A'*A))*A'. But since A'*A is singular, this is no way to go. Please give me some point on this. Thanks Fred
______________________________________________ R-help at stat.math.ethz.ch mailing list https://www.stat.math.ethz.ch/mailman/listinfo/r-help
If n>>m, then solve does not work. Consider: > A <- array(1:6, dim=c(2,3)) > B <- array(1:4, dim=c(2,2)) > solve(A, B) Error in solve.default(A, B) : singular matrix `a' in solve In this case, we have 6 = 3 x 2 unknowns but only 4 equations. It raises questions about what you mean by solve. S-Plus 2000 and 6 have "ginverse" that will produce an answer. You can construct such using "qr" or "svd". However, before coding that, I will ask, what do you mean by "solve"? hth. spencer graves
Uwe Ligges wrote:
Feng Zhang wrote:
Dear R-listers Now I have a Matrix Equation to solve, A -- m by n matrix, where n>>m, known matrix; X -- n by m unknown matrix; B -- m by m known matrix. So given the equation A*X=B, how to solve X?
You already mentioned it: ?solve Uwe Ligges
I first tried to take X = inv((A'*A))*A'. But since A'*A is singular, this is no way to go. Please give me some point on this. Thanks Fred
______________________________________________ R-help at stat.math.ethz.ch mailing list https://www.stat.math.ethz.ch/mailman/listinfo/r-help
______________________________________________ R-help at stat.math.ethz.ch mailing list https://www.stat.math.ethz.ch/mailman/listinfo/r-help
See also ?ginv in package MASS.
Spencer Graves wrote:
If n>>m, then solve does not work. Consider:
> A <- array(1:6, dim=c(2,3)) > B <- array(1:4, dim=c(2,2)) > solve(A, B)
Error in solve.default(A, B) : singular matrix `a' in solve In this case, we have 6 = 3 x 2 unknowns but only 4 equations. It raises questions about what you mean by solve. S-Plus 2000 and 6 have "ginverse" that will produce an answer. You can construct such using "qr" or "svd". However, before coding that, I will ask, what do you mean by "solve"? hth. spencer graves Uwe Ligges wrote:
Feng Zhang wrote:
Dear R-listers Now I have a Matrix Equation to solve, A -- m by n matrix, where n>>m, known matrix; X -- n by m unknown matrix; B -- m by m known matrix. So given the equation A*X=B, how to solve X?
You already mentioned it: ?solve Uwe Ligges
I first tried to take X = inv((A'*A))*A'. But since A'*A is singular, this is no way to go. Please give me some point on this. Thanks Fred
______________________________________________ R-help at stat.math.ethz.ch mailing list https://www.stat.math.ethz.ch/mailman/listinfo/r-help
______________________________________________ R-help at stat.math.ethz.ch mailing list https://www.stat.math.ethz.ch/mailman/listinfo/r-help
______________________________________________ R-help at stat.math.ethz.ch mailing list https://www.stat.math.ethz.ch/mailman/listinfo/r-help
"solve" in my question means to get a unique solution for X given A and B. If solve in R cannot do this, what else function would be helpful? In R, there are 'backsolve' and 'qr.solve'. So if these two functions are appropreciate for my problem? Thanks ----- Original Message ----- From: "Spencer Graves" <spencer.graves at PDF.COM> To: "Uwe Ligges" <ligges at statistik.uni-dortmund.de> Cc: "Feng Zhang" <f0z6305 at labs.tamu.edu>; "R-Help" <r-help at stat.math.ethz.ch> Sent: Thursday, April 24, 2003 11:21 PM Subject: Re: [R] Matrix Equation Help?
If n>>m, then solve does not work. Consider:
> A <- array(1:6, dim=c(2,3)) > B <- array(1:4, dim=c(2,2)) > solve(A, B)
Error in solve.default(A, B) : singular matrix `a' in solve In this case, we have 6 = 3 x 2 unknowns but only 4 equations. It raises questions about what you mean by solve. S-Plus 2000 and 6 have "ginverse" that will produce an answer. You can construct such using "qr" or "svd". However, before coding that, I will ask, what do you mean by "solve"? hth. spencer graves Uwe Ligges wrote:
Feng Zhang wrote:
Dear R-listers Now I have a Matrix Equation to solve, A -- m by n matrix, where n>>m, known matrix; X -- n by m unknown matrix; B -- m by m known matrix. So given the equation A*X=B, how to solve X?
You already mentioned it: ?solve Uwe Ligges
I first tried to take X = inv((A'*A))*A'. But since A'*A is singular, this is no way to go. Please give me some point on this. Thanks Fred
______________________________________________ R-help at stat.math.ethz.ch mailing list https://www.stat.math.ethz.ch/mailman/listinfo/r-help
______________________________________________ R-help at stat.math.ethz.ch mailing list https://www.stat.math.ethz.ch/mailman/listinfo/r-help