| Date: | Wed, 24 Dec 2008 11:44:45 +0000 |
| Reply-To: | J Sutar <jsutar@gmail.com> |
| Sender: | "SPSSX(r) Discussion" <SPSSX-L@LISTSERV.UGA.EDU> |
| From: | J Sutar <jsutar@gmail.com> |
| Subject: | Matrix Algebra |
| Content-Type: | text/plain; charset=ISO-8859-1 |
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).
Help would be much appreciated. Many thanks in advance.
Cheers
Jigs
/***********************************/.
*Sample Code*.
/***********************************/.
DATASET CLOSE ALL.
NEW FILE.
OUTPUT CLOSE ALL.
*Create Sample Data*.
DATA LIST FREE /id x1 x2 x3.
BEGIN DATA
1 1 5 1
2 1 2 1
3 2 3 1
4 4 3 1
5 3 4 2
END DATA.
MATRIX.
GET x /VARIABLES = x1 x2 x3 /FILE=* /NAMES=xvarnam.
COMPUTE tmp1 =(T(X(1,:))*X(1,:)).
COMPUTE tmp2 =(T(X(2,:))*X(2,:)).
COMPUTE tmp3 =(T(X(3,:))*X(3,:)).
COMPUTE tmp4 =(T(X(4,:))*X(4,:)).
COMPUTE tmp5 =(T(X(5,:))*X(5,:)).
PRINT tmp1.
PRINT tmp2.
PRINT tmp3.
PRINT tmp4.
PRINT tmp5.
COMPUTE tmp6=tmp1 + tmp2 + tmp3 + tmp4 + tmp5.
PRINT tmp6.
COMPUTE tmp7=INV(tmp6).
PRINT tmp7.
END MATRIX.
/***********************************/.
/*End of Sample Code*.
/***********************************/.
=====================
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
|