Chapter Contents
Chapter Contents
Previous
Previous
Next
Next
The MODECLUS Procedure

Example 42.1: Cluster Analysis of Samples from Univariate Distributions

This example uses pseudo-random samples from a uniform distribution, an exponential distribution, and a bimodal mixture of two normal distributions. Results are presented in Output 42.1.1 through Output 42.1.3 as plots displaying both the true density and the estimated density, as well as cluster membership.

The following statements produce Output 42.1.1:

   options noovp ps=28 ls=95;
   title 'Modeclus Example with Univariate Distributions';
   title2 'Uniform Distribution';

   data uniform;
      drop n;
      true=1;
      do n=1 to 100;
         x=ranuni(123);
         output;
      end;

   axis1 label=(angle=90 rotate=0) minor=none 
         order=(0 to 3 by 0.5);
   axis2 minor=none;
   symbol9 v=none i=splines;

   proc modeclus data=uniform m=1 k=10 20 40 60 out=out short;
      var x;

   proc gplot data=out; 
      plot density*x=cluster /frame cframe=ligr
                              vzero nolegend 
                              vaxis=axis1 haxis=axis2;
      plot2 true*x=9/vaxis=axis1 haxis=axis2;
      by _K_;
   run;

   /*********************************************/

   proc modeclus data=uniform m=1 r=.05 .10 .20 .30 
                 out=out short;
      var x;

   axis1 label=(angle=90 rotate=0) 
         minor=none order=(0 to 2 by 0.5);
   proc gplot data=out; 
      plot density*x=cluster /frame cframe=ligr
                              vzero nolegend 
                              vaxis=axis1 haxis=axis2;
      plot2 true*x=9/vaxis=axis1 haxis=axis2;
      by _R_;
   run;

Output 42.1.1: Cluster Analysis of Sample from a Uniform Distribution

Modeclus Example with Univariate Distributions
Uniform Distribution

The MODECLUS Procedure

Cluster Summary
K Number of
Clusters
Frequency of
Unclassified
Objects
10 6 0
20 3 0
40 2 0
60 1 0


mode1b.gif (5181 bytes)

mode1c.gif (4673 bytes)

mode1d.gif (4380 bytes)

mode1e.gif (4167 bytes)

Modeclus Example with Univariate Distributions
Uniform Distribution

The MODECLUS Procedure

Cluster Summary
R Number of
Clusters
Frequency of
Unclassified
Objects
0.05 4 0
0.1 2 0
0.2 2 0
0.3 1 0


mode1g.gif (4650 bytes)

mode1h.gif (4453 bytes)

mode1i.gif (4282 bytes)

mode1j.gif (4088 bytes)

The following statements produce Output 42.1.2:

   title2 'Exponential Distribution';
   data expon;
      drop n;
      do n=1 to 100;
         x=ranexp(123);
         true=exp(-x);
         output;
      end;

   axis1 label=(angle=90 rotate=0) minor=none 
         order=(0 to 2 by 0.5);
   axis2 minor=none;

   proc modeclus data=expon m=1 k=10 20 40 out=out short;
      var x;

   proc gplot; 
      plot density*x=cluster /frame cframe=ligr
                              vzero nolegend 
                              vaxis=axis1 haxis=axis2;
      plot2 true*x=9/vaxis=axis1 haxis=axis2;
      by _K_;
   run;
   /*********************************************/

   proc modeclus data=expon m=1 r=.20 .40 .80 out=out short;
      var x;

   axis1 label=(angle=90 rotate=0) 
         minor=none order=(0 to 1 by 0.5);
   proc gplot; 
      plot density*x=cluster /frame cframe=ligr
                              vzero nolegend 
                              vaxis=axis1 haxis=axis2;
      plot2 true*x=9/vaxis=axis1 haxis=axis2;
      by _R_;
   run;
   /*********************************************/

   title3 'Different Density-Estimation and Clustering Windows';
   proc modeclus data=expon m=1 r=.20 ck=10 20 40 
                 out=out short;
      var x;

   proc gplot; 
      plot density*x=cluster /frame cframe=ligr
                              vzero nolegend 
                              vaxis=axis1 haxis=axis2;
      plot2 true*x=9/vaxis=axis1 haxis=axis2;
      by _CK_;
   run;
   /*********************************************/
   
   title3 'Cascaded Density Estimates Using Arithmetic Means';
   proc modeclus data=expon m=1 r=.20 cascade=1 2 4 am out=out short;
      var x;

   proc gplot; 
      plot density*x=cluster /frame cframe=ligr
                              vzero nolegend 
                              vaxis=axis1 haxis=axis2;
      plot2 true*x=9/vaxis=axis1 haxis=axis2;
      by _R_ _CASCAD_;
   run;

Output 42.1.2: Cluster Analysis of Sample from an Exponential Distribution

Modeclus Example with Univariate Distributions
Exponential Distribution

The MODECLUS Procedure

Cluster Summary
K Number of
Clusters
Frequency of
Unclassified
Objects
10 5 0
20 3 0
40 1 0


mode1l.gif (4429 bytes)

mode1m.gif (4161 bytes)

mode1n.gif (3772 bytes)

Modeclus Example with Univariate Distributions
Exponential Distribution

The MODECLUS Procedure

Cluster Summary
R Number of
Clusters
Frequency of
Unclassified
Objects
0.2 8 0
0.4 6 0
0.8 1 0


mode1p.gif (4304 bytes)

mode1q.gif (3946 bytes)

mode1r.gif (3731 bytes)

Modeclus Example with
Different Density-Estimation and Clustering Windows

The MODECLUS Procedure

Cluster Summary
R CK Number of
Clusters
Frequency of
Unclassified
Objects
0.2 10 3 0
0.2 20 2 0
0.2 40 1 0


mode1t.gif (4583 bytes)

mode1u.gif (4523 bytes)

mode1v.gif (4371 bytes)

Modeclus Example with
Cascaded Density Estimates Using Arithmetic Means

The MODECLUS Procedure

Cluster Summary
R Cascade Number of
Clusters
Frequency of
Unclassified
Objects
0.2 1 8 0
0.2 2 8 0
0.2 4 7 0


mode1x.gif (4608 bytes)

mode1y.gif (4540 bytes)

mode1z.gif (4447 bytes)

The following statements produce Output 42.1.3:

   title2 'Normal Mixture Distribution';
   data normix;
      drop n sigma;
      sigma=.125;
      do n=1 to 100;
         x=rannor(456)*sigma+mod(n,2)/2;
         true=exp(-.5*(x/sigma)**2)+exp(-.5*((x-.5)/sigma)**2);
         true=.5*true/(sigma*sqrt(2*3.1415926536));
         output;
      end;

   axis1 label=(angle=90 rotate=0) minor=none order=(0 to 3 by 0.5);
   axis2 minor=none;

   proc modeclus data=normix m=1 k=10 20 40 60 out=out short;
      var x;

   proc gplot; 
      plot density*x=cluster /frame cframe=ligr
                              vzero nolegend 
                              vaxis=axis1 haxis=axis2;
      plot2 true*x=9/vaxis=axis1  haxis=axis2;
      by _K_;
   run;
   /*********************************************/

   proc modeclus data=normix m=1 r=.05 .10 .20 .30 out=out short;
      var x;

   proc gplot; 
      plot density*x=cluster /frame cframe=ligr
                              vzero nolegend 
                              vaxis=axis1 haxis=axis2 ;
      plot2 true*x=9/vaxis=axis1 haxis=axis2 ;
      by _R_;
   run;
   /*********************************************/

   title3 'Cascaded Density Estimates Using Arithmetic Means';
   proc modeclus data=normix m=1 r=.05 cascade=1 2 4 am out=out short;
      var x;

   axis1 label=(angle=90 rotate=0) 
         minor=none order=(0 to 2 by 0.5);
   proc gplot; 
      plot density*x=cluster /frame cframe=ligr
                              vzero  nolegend
                              vaxis=axis1 haxis=axis2 ;
      plot2 true*x=9/vaxis=axis1 haxis=axis2 ;
      by _R_ _CASCAD_;
   run;

Output 42.1.3: Cluster Analysis of Sample from a Bimodal Mixture of Two Normal Distributions

Modeclus Example with
Normal Mixture Distribution

The MODECLUS Procedure

Cluster Summary
K Number of
Clusters
Frequency of
Unclassified
Objects
10 7 0
20 2 0
40 2 0
60 1 0


mode1ab.gif (5391 bytes)

mode1ac.gif (4971 bytes)

mode1ad.gif (4778 bytes)

mode1ae.gif (4556 bytes)

Modeclus Example with
Normal Mixture Distribution

The MODECLUS Procedure

Cluster Summary
R Number of
Clusters
Frequency of
Unclassified
Objects
0.05 5 0
0.1 2 0
0.2 2 0
0.3 1 0


mode1ag.gif (5091 bytes)

mode1ah.gif (4800 bytes)

mode1ai.gif (4710 bytes)

mode1aj.gif (4535 bytes)

Modeclus Example with
Normal Mixture Distribution
Cascaded Density Estimates Using Arithmetic Means

The MODECLUS Procedure

Cluster Summary
R Cascade Number of
Clusters
Frequency of
Unclassified
Objects
0.05 1 5 0
0.05 2 4 0
0.05 4 4 0


mode1al.gif (5374 bytes)

mode1am.gif (5324 bytes)

mode1an.gif (5288 bytes)

Chapter Contents
Chapter Contents
Previous
Previous
Next
Next
Top
Top

Copyright © 1999 by SAS Institute Inc., Cary, NC, USA. All rights reserved.