home *** CD-ROM | disk | FTP | other *** search
/ NetNews Usenet Archive 1992 #26 / NN_1992_26.iso / spool / bit / listserv / sasl / 4931 < prev    next >
Encoding:
Text File  |  1992-11-05  |  3.1 KB  |  102 lines

  1. Comments: Gated by NETNEWS@AUVM.AMERICAN.EDU
  2. Path: sparky!uunet!gatech!paladin.american.edu!auvm!OREGON.BITNET!JOE
  3. X-Envelope-to: SAS-L@UGA.BITNET
  4. X-VMS-To: IN%"SAS-L@UGA"
  5. MIME-version: 1.0
  6. Content-transfer-encoding: 7BIT
  7. Message-ID: <01GQSA73SE4O8WX0EA@OREGON.UOREGON.EDU>
  8. Newsgroups: bit.listserv.sas-l
  9. Date:         Thu, 5 Nov 1992 08:10:32 -0800
  10. Reply-To:     Joe St Sauver <JOE@OREGON.BITNET>
  11. Sender:       "SAS(r) Discussion" <SAS-L@UGA.BITNET>
  12. From:         Joe St Sauver <JOE@OREGON.BITNET>
  13. Subject:      Hoetellings T**2
  14. Lines: 86
  15.  
  16. Date: 05 Nov 1992 15:34:00 -0500 (EST)
  17. From: "Michael R. Wechtaluk (607) 974-6569" <WECHTALUK_MR@CORNING.COM>
  18. Subject: Hotelling's T**2
  19.  
  20. >         Summary: Need a method for calculating Hotelling's T**2
  21.  
  22. You can easily run a 1 sample Hoetellings T**2 using:
  23.  
  24.   PROC GLM;
  25.     MODEL Y1 Y2 Y3 Y4=;
  26.  
  27. however Hoetellings is also a nice "starter problem" to work through via
  28. PROC IML (assuming your site has SAS/IML). Sample SAS/IML code for that
  29. test, complete with a little sample dataset, appears below.
  30.  
  31. I make no claim to the robustness of the SAS/IML solution shown for real,
  32. live, messy data (since this morning's unrelated project is to port some
  33. current SAS/IML code over to Mathematica for a user who has just recently
  34. learned that no, SAS/IML doesn't do all of its calculation in infinite
  35. precision and yes, roundoff/truncation/overflow are all nasty problems for
  36. some numerical procedures which looked so clean in matrix form, now aren't
  37. they?).
  38.  
  39. Regards,
  40.  
  41. Joe "We All Live in Arkansas Now" St Sauver (joe@oregon.uoregon.edu)
  42.  
  43. hoetellings.sas follows --------------------------------------------------------
  44.  
  45. data hypo;
  46.   input u1 u2 u3 u4 @@;
  47.   cards;
  48.   43 21 39 19
  49.   ;
  50.  
  51. data exprmnt;
  52.   input x1 x2 x3 x4 @@;
  53.   cards;
  54.   45 20 39 18   43 22 41 21   40 25 44 20   42 26 40 22   38 24 41 23
  55.   40 22 40 19   38 23 44 30   32 27 42 25   50 40 30 40   45 25 40 25
  56.   44 23 34 20   42 24 43 27   33 28 41 23   44 37 32 28   46 27 38 28
  57.   41 21 38 20   41 25 41 28   37 24 40 24   43 38 34 25   41 26 39 26
  58.   39 24 37 18   40 24 43 29   35 25 40 22   41 35 33 24   40 24 37 27
  59.   ;
  60.  
  61. proc iml;
  62.   reset print;                       /* print the output of each operation */
  63.  
  64.   print "SAS PROC IML Hoetelling''s 1-Sample T**2 Test ....";
  65.  
  66.   use exprmnt;                        /* now read in the experimental data */
  67.  
  68.   print "X Matrix Follows ....";
  69.   read all var _all_ into X;
  70.  
  71.   print "X Bar Follows ....";
  72.   XBAR = X(|:,|);
  73.  
  74.   print "Expanded X Bar Follows ....";
  75.   EXBAR = REPEAT(XBAR,NROW(X),1);
  76.  
  77.   print "S Follows ....";
  78.   S    = (X`*X) - (EXBAR`*EXBAR);
  79.  
  80.   print "Inverse S Follows ....";
  81.   SINV = INV(S);
  82.  
  83.   use hypo;                           /* read in the hypothetical means */
  84.  
  85.   print "MU0 Follows ....";
  86.   read all var _all_ into MU0;
  87.  
  88.   print "N Follows ....";
  89.   N    = NROW(X);
  90.  
  91.   print "P Follows ....";
  92.   P    = NCOL(X);
  93.  
  94.   print "T**2 Follows ....";
  95.   T2   = N*(N-1)*(XBAR-MU0)*INV(S)*(XBAR-MU0)`;
  96.  
  97.   print "Adjusted T**2 Follows ....";
  98.   ADJT2 = (N-P)/((N-1)*P)*T2;
  99.  
  100.   print "P of Obtaining (Adj T**2) > (Adj T**2 Actually Obtained) Follows ....";
  101.   PROB = 1-PROBF(ADJT2,P,(N-P));
  102.