The MODECLUS Procedure

Example 79.1 Cluster Analysis of Samples from Univariate Distributions

(View the complete code for this example.)

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 79.1.1 through Output 79.1.18 as plots displaying both the true density and the estimated density, as well as cluster membership.

The following statements produce Output 79.1.1 through Output 79.1.4:

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;
run;
proc modeclus data=uniform m=1 k=10 20 40 60 out=out short;
   var x;
run;

proc sgplot data=out noautolegend;
   y2axis label='True' values=(0 to 2 by 1.);
   yaxis values=(0 to 3 by 0.5);
   scatter y=density x=x / markerchar=cluster group=cluster;
   pbspline y=true x=x / y2axis nomarkers lineattrs=(thickness= 1);
   by _K_;
run;
proc modeclus data=uniform m=1 r=.05 .10 .20 .30 out=out short;
   var x;
run;

proc sgplot data=out noautolegend;
   y2axis label='True' values=(0 to 2 by 1.);
   yaxis values=(0 to 2 by 0.5);
   scatter y=density x=x / markerchar=cluster group=cluster;
   pbspline y=true x=x / y2axis nomarkers lineattrs=(thickness= 1);
   by _R_;
run;

Output 79.1.1: Cluster Analysis of Sample from a Uniform Distribution

Modeclus Example with Univariate Distributions
Uniform Distribution

The MODECLUS Procedure

Cluster Summary
KNumber of
Clusters
Frequency of
Unclassified
Objects
1060
2030
4020
6010


Output 79.1.2: True Density, Estimated Density, and Cluster Membership by Various _K_ Values

True Density, Estimated Density, and Cluster Membership by Various K Values
External File:images/mode1gd1.png
External File:images/mode1gd2.png
External File:images/mode1gd3.png


Output 79.1.3: Cluster Analysis of Sample from a Uniform Distribution

Modeclus Example with Univariate Distributions
Uniform Distribution

The MODECLUS Procedure

Cluster Summary
RNumber of
Clusters
Frequency of
Unclassified
Objects
0.0540
0.120
0.220
0.310


Output 79.1.4: True Density, Estimated Density, and Cluster Membership by Various _R_ Values

True Density, Estimated Density, and Cluster Membership by Various R Values
External File:images/mode1ge1.png
External File:images/mode1ge2.png
External File:images/mode1ge3.png


The following statements produce Output 79.1.5 through Output 79.1.12:

data expon;
   title2 'Exponential Distribution';
   drop n;
   do n=1 to 100;
      x=ranexp(123);
      true=exp(-x);
      output;
   end;
run;
proc modeclus data=expon m=1 k=10 20 40 out=out short;
   var x;
run;

proc sgplot data=out noautolegend;
   y2axis label='True' values=(0 to 1 by .5);
   yaxis values=(0 to 2 by 0.5);
   scatter y=density x=x / markerchar=cluster group=cluster;
   pbspline y=true x=x / y2axis nomarkers lineattrs=(thickness= 1);
   by _K_;
run;
proc modeclus data=expon m=1 r=.20 .40 .80 out=out short;
   var x;
run;

proc sgplot data=out noautolegend;
   y2axis label='True' values=(0 to 1 by .5);
   yaxis values=(0 to 1 by 0.5);
   scatter y=density x=x / markerchar=cluster group=cluster;
   pbspline y=true x=x / y2axis nomarkers lineattrs=(thickness= 1);
   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;
run;

proc sgplot data=out noautolegend;
   y2axis label='True' values=(0 to 1 by .5);
   yaxis values=(0 to 1 by 0.5);
   scatter y=density x=x / markerchar=cluster group=cluster;
   pbspline y=true x=x / y2axis nomarkers lineattrs=(thickness= 1);
   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;
run;

proc sgplot data=out noautolegend;
   y2axis label='True' values=(0 to 1 by .5);
   yaxis values=(0 to 1 by 0.5);
   scatter y=density x=x / markerchar=cluster group=cluster;
   pbspline y=true x=x / y2axis nomarkers lineattrs=(thickness= 1);
   by _R_ _CASCAD_;
run;

Output 79.1.5: Cluster Analysis of Sample from an Exponential Distribution

Modeclus Example with Univariate Distributions
Exponential Distribution

The MODECLUS Procedure

Cluster Summary
KNumber of
Clusters
Frequency of
Unclassified
Objects
1050
2030
4010


Output 79.1.6: True Density, Estimated Density, and Cluster Membership by Various _K_ Values

True Density, Estimated Density, and Cluster Membership by Various K Values
External File:images/mode1gf1.png
External File:images/mode1gf2.png


Output 79.1.7: Cluster Analysis of Sample from an Exponential Distribution

Modeclus Example with Univariate Distributions
Exponential Distribution

The MODECLUS Procedure

Cluster Summary
RNumber of
Clusters
Frequency of
Unclassified
Objects
0.280
0.460
0.810


Output 79.1.8: True Density, Estimated Density, and Cluster Membership by Various _R_ Values

True Density, Estimated Density, and Cluster Membership by Various R Values
External File:images/mode1gg1.png
External File:images/mode1gg2.png


Output 79.1.9: Cluster Analysis of Sample from an Exponential Distribution

Modeclus Example with Univariate Distributions
Exponential Distribution
Different Density-Estimation and Clustering Windows

The MODECLUS Procedure

Cluster Summary
RCKNumber of
Clusters
Frequency of
Unclassified
Objects
0.21030
0.22020
0.24010


Output 79.1.10: True Density, Estimated Density, and Cluster Membership by _R_=0.2 with Various _CK_ Values

True Density, Estimated Density, and Cluster Membership by R=0.2 with Various CK Values
External File:images/mode1gh1.png
External File:images/mode1gh2.png


Output 79.1.11: Cluster Analysis of Sample from an Exponential Distribution

Modeclus Example with Univariate Distributions
Exponential Distribution
Cascaded Density Estimates Using Arithmetic Means

The MODECLUS Procedure

Cluster Summary
RCascadeNumber of
Clusters
Frequency of
Unclassified
Objects
0.2180
0.2280
0.2470


Output 79.1.12: True Density, Estimated Density, and Cluster Membership by _R_=0.2 with Various _CASCAD_ Values

True Density, Estimated Density, and Cluster Membership by R=0.2 with Various CASCAD Values
External File:images/mode1gi1.png
External File:images/mode1gi2.png


The following statements produce Output 79.1.13 through Output 79.1.18:

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;
run;
proc modeclus data=normix m=1 k=10 20 40 60 out=out short;
   var x;
run;

proc sgplot data=out noautolegend;
   y2axis label='True' values=(0 to 1.6 by .1);
   yaxis values=(0 to 3 by 0.5);
   scatter y=density x=x / markerchar=cluster group=cluster;
   pbspline y=true x=x / y2axis nomarkers lineattrs=(thickness= 1);
   by _K_;
run;
proc modeclus data=normix m=1 r=.05 .10 .20 .30 out=out short;
   var x;
run;

proc sgplot data=out noautolegend;
   y2axis label='True' values=(0 to 1.6 by .1);
   yaxis values=(0 to 3 by 0.5);
   scatter y=density x=x / markerchar=cluster group=cluster;
   pbspline y=true x=x / y2axis nomarkers lineattrs=(thickness= 1);
   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;
run;

proc sgplot data=out noautolegend;
   y2axis label='True' values=(0 to 1.6 by .1);
   yaxis values=(0 to 2 by 0.5);
   scatter y=density x=x / markerchar=cluster group=cluster;
   pbspline y=true x=x / y2axis nomarkers lineattrs=(thickness= 1);
   by _R_ _CASCAD_;
run;

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

Modeclus Example with Univariate Distributions
Normal Mixture Distribution

The MODECLUS Procedure

Cluster Summary
KNumber of
Clusters
Frequency of
Unclassified
Objects
1070
2020
4020
6010


Output 79.1.14: True Density, Estimated Density, and Cluster Membership by Various _K_ Values

True Density, Estimated Density, and Cluster Membership by Various K Values
External File:images/mode1gj1.png
External File:images/mode1gj2.png
External File:images/mode1gj3.png


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

Modeclus Example with Univariate Distributions
Normal Mixture Distribution

The MODECLUS Procedure

Cluster Summary
RNumber of
Clusters
Frequency of
Unclassified
Objects
0.0550
0.120
0.220
0.310


Output 79.1.16: True Density, Estimated Density, and Cluster Membership by Various _R_= Values

True Density, Estimated Density, and Cluster Membership by Various R= Values
External File:images/mode1gk1.png
External File:images/mode1gk2.png
External File:images/mode1gk3.png


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

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

The MODECLUS Procedure

Cluster Summary
RCascadeNumber of
Clusters
Frequency of
Unclassified
Objects
0.05150
0.05240
0.05440


Output 79.1.18: True Density, Estimated Density, and Cluster Membership by _R_=0.05 with Various _CASCAD_ Values

True Density, Estimated Density, and Cluster Membership by R=0.05 with Various CASCAD Values
External File:images/mode1gl1.png
External File:images/mode1gl2.png