help-octave
[Top][All Lists]

## Re: Matrix regression of distnce matrices + non negative least square

 From: Corrado Subject: Re: Matrix regression of distnce matrices + non negative least square Date: Thu, 10 Sep 2009 15:57:47 +0100 User-agent: KMail/1.11.4 (Linux/2.6.28-13-generic; KDE/4.2.4; x86_64; ; )

```Dear Jaroslav, Octave list,

here I am again ....

How do you calculate distance or dissimilarity matrices in Octave? and how do
you treat triangular matrices + diagonal in Octave?  is there a separate
package?

Regards

On Monday 07 September 2009 16:04:35 Jaroslav Hajek 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

--