[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: Matrix regression of distnce matrices + non negative least square
From: |
Jaroslav Hajek |
Subject: |
Re: Matrix regression of distnce matrices + non negative least square |
Date: |
Mon, 7 Sep 2009 17:04:35 +0200 |
On Mon, Sep 7, 2009 at 4:21 PM, Corrado<address@hidden> wrote:
> Dear Jaroslav,
>
> thanks for your help.
>
> I actually do not understand what you are suggesting:
>
> 1) The data would be stored in matrices, which I can easily dump into csv
> files
OK. But mind you, instead of working with a number of equal-sized
matrices it is often more efficient to work with a 3D array. Usually
it depends on where you get the matrices from.
> 2) The distance matrices are up to 5000 x 5000 (but they symmetric, so only
> n(n-1)/2 are important), but the ones I am using now are just 1500 x 1500.
In that case, it probably doesn't matter much which representation you choose.
> 3) I thought lsqnonneg only worked on linear system in the form y=ax
Yes. That's why you need to bring the system into this form.
> 4) The terms are matrices, how do you write a canonical form???? the x1 ....
> xn are matrices (e.g. 1500 x 1500) .... the ci are coefficients in R ....
>
A matrix equation constitutes a system of equations; one for each
element. If x1...xN are MxM, you get a
system of M*(M+1)/2 equations in N variables.
Suppose you have the matrices X in a cell array, so that X{1} is the
first matrix etc., and the RHS matrix is Y.
Then you want to do something like
A = [cellfun (@vech, X, "UniformOutput", false){:}];
b = vech (Y);
c = lsqnonneg (A, b);
To get the coefficients in "c". Note that lsqnonneg is part of Octave 3.2.0+.
There is a small problem with the above simplistic code: it does not
discard the diagonal equations, because vech includes the diagonal.
You can modify vech in order to discard even the diagonal equations.
hth
--
RNDr. Jaroslav Hajek
computing expert & GNU Octave developer
Aeronautical Research and Test Institute (VZLU)
Prague, Czech Republic
url: www.highegg.matfyz.cz
Re: Matrix regression of distance matrices + non negative least square, Corrado, 2009/09/07