Date: Mon, 29 Dec 2008 13:45:39 +0000
Reply-To: J Sutar <jsutar@gmail.com>
Sender: "SPSSX(r) Discussion" <SPSSX-L@LISTSERV.UGA.EDU>
From: J Sutar <jsutar@gmail.com>
Subject: Re: Matrix Algebra
In-Reply-To: <4955FDD6.3070400@gmail.com>
Content-Type: text/plain; charset=ISO-8859-1
Thanks Marta, that works fine.
Just a follow up question regarding printing formats under MATRIX command.
Is it possible to print output in comma format, I tried /FORMAT="COMMA8.0"
but it still outputted as F8.0 (without commas). Is it not possible to
specify comma under the FORMAT subcommand?
Many thanks
Jigs
2008/12/27 Marta García-Granero <mgarciagranero@gmail.com>
> J Sutar wrote:
>
>> Hello,
>> I'd like to know if the below code can be generalised for any number of
>> cases? (I tried LOOP but with little success).
>>
>> Hi
>
> Disregards my previous message (SPSS&flu don't get along very well). I
> misunderstood what th code was doing (hence my comment "I have added two
> more variables because your code couldn't work", it worked perfectly
> OK). This is the final AND fully working version of the extended code:
>
> DATA LIST FREE /id x1 x2 x3 x4 x5.
> BEGIN DATA
> 1 1 5 1 2 5
> 2 1 2 1 2 2
> 3 2 3 1 2 3
> 4 4 3 1 2 1
> 5 3 4 2 1 4
> END DATA.
>
> * Trying 3 variables (it mimics your original code)*.
> MATRIX.
> GET x /VARIABLES = x1 tO x3 /FILE=* /NAMES=xvarnam.
> COMPUTE nx=NCOL(x).
> COMPUTE ndata=NROW(x).
> COMPUTE Final=MAKE(nx,nx,0).
> LOOP i=1 TO ndata.
> - COMPUTE tmp =(T(X(i,:))*X(i,:)).
> - PRINT tmp.
> - COMPUTE Final=Final+tmp.
> END LOOP.
> PRINT Final.
> COMPUTE InvFinal=INV(Final).
> PRINT InvFinal.
> END MATRIX.
>
> * Trying with 5 variables *.
> MATRIX.
> GET x /VARIABLES = x1 tO x3 /FILE=* /NAMES=xvarnam.
> COMPUTE nx=NCOL(x).
> COMPUTE ndata=NROW(x).
> COMPUTE Final=MAKE(nx,nx,0).
> LOOP i=1 TO ndata.
> - COMPUTE tmp =(T(X(i,:))*X(i,:)).
> - PRINT tmp.
> - COMPUTE Final=Final+tmp.
> END LOOP.
> PRINT Final.
> COMPUTE InvFinal=INV(Final).
> PRINT InvFinal.
> END MATRIX.
>
> Marta
>
>
> =====================
> To manage your subscription to SPSSX-L, send a message to
> LISTSERV@LISTSERV.UGA.EDU (not to SPSSX-L), with no body text except the
> command. To leave the list, send the command
> SIGNOFF SPSSX-L
> For a list of commands to manage subscriptions, send the command
> INFO REFCARD
>
====================To manage your subscription to SPSSX-L, send a message to
LISTSERV@LISTSERV.UGA.EDU (not to SPSSX-L), with no body text except the
command. To leave the list, send the command
SIGNOFF SPSSX-L
For a list of commands to manage subscriptions, send the command
INFO REFCARD
|