# Re: [R] Generate a matrix Q satisfying t(Q)%*%Q=Z and XQ=W

From: Spencer Graves <spencer.graves_at_pdf.com>
Date: Wed 07 Jul 2004 - 14:00:10 EST

What can you tell us of the problem that you've translated into this? I see a minimization problem subject to constraints, but I'm not certain which are the constraints and what is the objective function. For example, are you trying to find Q to minimize sum((Z-X'X)^2) subject to XQ=W or do you want to minimize sum((XQ-W)^2) subject to Q'Q=Z or something else?

If it were my problem, I think I would work for a while with the singular value decompositions of X, W and Z, and see if that would lead me to more information about Q, including conditions under which a solution existed, expressions for Q when multiple solutions existed, and a solution minimizing your chosen objective function when solutions do not exist. (A google search produced many hits for "singular value decomposition", implemented as "svd" in R.)

hope this helps. spencer graves

Stephane DRAY wrote:

> Hello,
> I have a question that is not directly related to R ... but I try to
> do it in R ;-) :
>
> I would like to generate a matrix Q satisfying (for a given Z, X and
> W) the two following conditions:
>
> t(Q)%*%Q=Z (1)
> XQ=W (2)
>
> where:
> Q is m rows and r columns
> X is p rows and m columns
> D is p rows and r columns
> C is r rows and r columns
> with m>p,r
>
>
> e.g:
> m=6,
> p=2
> r=3
>
> Z=matrix(c(1,.2,.5,.2,1,.45,.5,.45,1),3,3)
> X=matrix(c(.1,.3,.5,.6,.2,.1,.8,1,.4,.2,.2,.9),2,6)
> W=matrix(c(0,.8,.4,.6,.2,0),2,3)
>
> #Create a matrix satisfying (1) is easy:
>
> A=matrix(runif(18),6,3)
> Q1=svd(A)\$u%*%chol(Z)
>
>
> #For the second condition (2), a solution is given by
>
> Q2=A%*%ginv(X%*%A)%*%W
>
>
>
>
>
> I do not know how to create a matrix Q that satisfies the two
> conditions. I have try to construct an iterative procedure without
> success (no convergence):
>
> eps=10
> i=0
> while(eps>.5)
> {
> Q1=svd(Q2)\$u%*%chol(Z)
> Q2=Q1%*%ginv(X%*%Q1)%*%W
> eps=sum(abs(Q1-Q2))
> cat(i,":",eps,"\n")
> i=i+1
> }
>
> Perhaps someone could have any idea to solve the problem, or a
> reference on this kind of question or the email of another list where
> I should ask this question.
>
>
> Sincerely.
>
> Stéphane DRAY
> --------------------------------------------------------------------------------------------------
>
> Département des Sciences Biologiques
> Université de Montréal, C.P. 6128, succursale centre-ville
> Montréal, Québec H3C 3J7, Canada
>
> Tel : 514 343 6111 poste 1233
> E-mail : stephane.dray@umontreal.ca
> --------------------------------------------------------------------------------------------------
>
> Web
> http://www.steph280.freesurf.fr/
>
> ______________________________________________
> R-help@stat.math.ethz.ch mailing list
> https://www.stat.math.ethz.ch/mailman/listinfo/r-help