/*-----------------------------------------------------------------
            S A S   S A M P L E   L I B R A R Y                   
                                                                  
      NAME: hpfmmgs3                                              
     TITLE: Third Getting Started Example for PROC HPFMM          
            Mixtures of normal distributions                      
   PRODUCT: STAT                                                  
    SYSTEM: ALL                                                   
      KEYS: Galaxy data                                           
            Count data                                            
            Bayesian analysis                                     
     PROCS: HPFMM                                                 
      DATA:                                                       
                                                                  
   SUPPORT: Dave Kessler                                          
       REF: Roeder, K. (1990), Density Estimation With            
            Confidence Sets Exemplified by Superclusters and      
            Voids in the Galaxies, Journal of the American        
            Statistical Association, 85, 617--624.                
      MISC:                                                       
-----------------------------------------------------------------*/

title "HPFMM Analysis of Galaxies Data";
data galaxies;
   input velocity @@;
   v = velocity / 1000;
   datalines;
9172  9350  9483  9558  9775  10227 10406 16084 16170 18419
18552 18600 18927 19052 19070 19330 19343 19349 19440 19473
19529 19541 19547 19663 19846 19856 19863 19914 19918 19973
19989 20166 20175 20179 20196 20215 20221 20415 20629 20795
20821 20846 20875 20986 21137 21492 21701 21814 21921 21960
22185 22209 22242 22249 22314 22374 22495 22746 22747 22888
22914 23206 23241 23263 23484 23538 23542 23666 23706 23711
24129 24285 24289 24366 24717 24990 25633 26960 26995 32065
32789 34279
;

title2 "Three to Seven Components, Unequal Variances";
ods graphics on;
proc hpfmm data=galaxies criterion=AIC;
   model v = / kmin=3 kmax=7;
   ods exclude IterHistory OptInfo ComponentInfo;
run;

title2 "Three to Seven Components, Equal Variances";
proc hpfmm data=galaxies criterion=AIC gconv=0;
   model v = / kmin=3 kmax=7  equate=scale;
run;

title2 "Five Components, Equal Variances = 0.9025";
proc hpfmm data=galaxies;
   model v = / K=5 equate=scale;
   restrict int 0 (scale 1) = 0.9025;
run;
ods graphics off;