# Re: [R] B %*% t(B) = R , then solve for B

From: Shawn Koppenhoefer <shawn.koppenhoefer_at_epfl.ch>
Date: Tue, 12 Apr 2011 18:20:46 +0200

@Doran: I still have to parse your answer, as I'm not experienced enough to see immediately how it relates to my M. Sorry for being daft! I don't immediately see how doing a linear regression on two vectors. I'm reading about design matrices now to try to understand your answer (?model.matrix). And when I look at A, I don't see anything that leads me to finding a diagonal matrix. :-(

@Spencer: Yup. SVD (Single Value Decomposition) gave me a solution (non-triangular unfortunately). From it, I got my F and t(F) however F is not triangular.
I didn't know about about QR which gives me orthogonal and upper triangular matrix. So this is closer!

In the meantime, I've learned about the "LU Decomposition"... which sounded promising:

library(Matrix)
lum=lu(M)
L=expand(lum)\$L
U=expand(lum)\$U
L%*%U

I get lower L and upper U triangular matrices, However it is not the case that U is the transpose of L :-( which is what I'm after (certainly Doran's solution gives me the answer once I figure it out).

3 x 3 Matrix of class "dgeMatrix"

[,1] [,2] [,3]
[1,] 0.6098601 0.2557882 0.1857773
[2,] 0.2557882 0.5127065 -0.1384238
[3,] 0.1857773 -0.1384238 0.9351089

> L
3 x 3 Matrix of class "dtrMatrix" (unitriangular)

```      [,1]       [,2]       [,3]

[1,]  1.0000000          .          .
[2,]  0.4194211  1.0000000          .

```
[3,] 0.3046228 -0.5336215 1.0000000

> U
3 x 3 Matrix of class "dtrMatrix"

[,1] [,2] [,3]
[1,] 0.6098601 0.2557882 0.1857773
[2,] . 0.4054235 -0.2163427
[3,] . . 0.7630718

>

See?
U is not t(L) :-(

remember that I'm trying to get this solution:

[,1] [,2] [,3]
[1,] 0.781 0.000 0.000
[2,] 0.328 0.637 0.000
[3,] 0.238 -0.341 0.873

/shawn

R-help_at_r-project.org mailing list
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. Received on Tue 12 Apr 2011 - 22:03:21 GMT

Archive maintained by Robert King, hosted by the discipline of statistics at the University of Newcastle, Australia.
Archive generated by hypermail 2.2.0, at Tue 12 Apr 2011 - 22:30:30 GMT.

Mailing list information is available at https://stat.ethz.ch/mailman/listinfo/r-help. Please read the posting guide before posting to the list.