This is as much a mathematics as an R question, in the "this should be easy but I don't see it" category. Assume I have a full rank p by p matrix V (aside: V = (X'X)^{-1} for a particular setup), a p by k matrix B, and I want to complete an orthagonal basis for the space with distance function V. That is, find A such that t(B) %*% V %*% A =0, where A has p rows and p-k columns. With V=identity this is easy. I can do it in 1-2 lines using qr(), lm(), or several other tools. A part of me is quite certain that the general problem isn't more than 3 lines of R, but after a day of beating my head on the issue I still don't see it. Math wise it looks like a simple homework problem in a mid level class, but I'm not currently sure that I'd pass said class. If someone could show the way I would be grateful. Either that or assurance that the problem actually IS hard and I'm not as dense as I think. Terry T.
Hi Terry, maybe I'm missing something, but why not define a matrix BB = V'B; then t(B) %*% V = t(BB), then your problem reduces to finding A such that t(BB) %*% A = 0? Peter On Thu, Jul 16, 2015 at 10:28 AM, Therneau, Terry M., Ph.D. <therneau at mayo.edu> wrote:> This is as much a mathematics as an R question, in the "this should be easy > but I don't see it" category. > > Assume I have a full rank p by p matrix V (aside: V = (X'X)^{-1} for a > particular setup), a p by k matrix B, and I want to complete an orthagonal > basis for the space with distance function V. That is, find A such that > t(B) %*% V %*% A =0, where A has p rows and p-k columns. > > With V=identity this is easy. I can do it in 1-2 lines using qr(), lm(), or > several other tools. A part of me is quite certain that the general problem > isn't more than 3 lines of R, but after a day of beating my head on the > issue I still don't see it. Math wise it looks like a simple homework > problem in a mid level class, but I'm not currently sure that I'd pass said > class. > > If someone could show the way I would be grateful. Either that or assurance > that the problem actually IS hard and I'm not as dense as I think. > > Terry T. > > ______________________________________________ > R-help at r-project.org mailing list -- To UNSUBSCRIBE and more, see > https://stat.ethz.ch/mailman/listinfo/r-help > PLEASE do read the posting guide http://www.R-project.org/posting-guide.html > and provide commented, minimal, self-contained, reproducible code.
Yes it is obvious --- once someone else pointed it out. Thanks for the hint. Terry T. On 07/16/2015 12:52 PM, Peter Langfelder wrote:> Hi Terry, > > maybe I'm missing something, but why not define a matrix BB = V'B; > then t(B) %*% V = t(BB), then your problem reduces to finding A such > that t(BB) %*% A = 0? > > Peter > > On Thu, Jul 16, 2015 at 10:28 AM, Therneau, Terry M., Ph.D. > <therneau at mayo.edu> wrote: >> This is as much a mathematics as an R question, in the "this should be easy >> but I don't see it" category. >> >> Assume I have a full rank p by p matrix V (aside: V = (X'X)^{-1} for a >> particular setup), a p by k matrix B, and I want to complete an orthagonal >> basis for the space with distance function V. That is, find A such that >> t(B) %*% V %*% A =0, where A has p rows and p-k columns. >> >> With V=identity this is easy. I can do it in 1-2 lines using qr(), lm(), or >> several other tools. A part of me is quite certain that the general problem >> isn't more than 3 lines of R, but after a day of beating my head on the >> issue I still don't see it. Math wise it looks like a simple homework >> problem in a mid level class, but I'm not currently sure that I'd pass said >> class. >> >> If someone could show the way I would be grateful. Either that or assurance >> that the problem actually IS hard and I'm not as dense as I think. >> >> Terry T. >> >> ______________________________________________ >> R-help at r-project.org mailing list -- To UNSUBSCRIBE and more, see >> https://stat.ethz.ch/mailman/listinfo/r-help >> PLEASE do read the posting guide http://www.R-project.org/posting-guide.html >> and provide commented, minimal, self-contained, reproducible code.