To determine an appropriate model for a data distribution, you should consider curves from several distribution families. As shown in this example, you can use the HISTOGRAM statement to fit more than one distribution and display the density curves on a histogram.
The gap between two plates is measured (in cm) for each of 50 welded assemblies selected at random from the output of a welding
process. The following statements save the measurements (Gap
) in a data set named Plates
:
data Plates; label Gap = 'Plate Gap in cm'; input Gap @@; datalines; 0.746 0.357 0.376 0.327 0.485 1.741 0.241 0.777 0.768 0.409 0.252 0.512 0.534 1.656 0.742 0.378 0.714 1.121 0.597 0.231 0.541 0.805 0.682 0.418 0.506 0.501 0.247 0.922 0.880 0.344 0.519 1.302 0.275 0.601 0.388 0.450 0.845 0.319 0.486 0.529 1.547 0.690 0.676 0.314 0.736 0.643 0.483 0.352 0.636 1.080 ;
The following statements fit three distributions (lognormal, Weibull, and gamma) and display their density curves on a single histogram:
title 'Distribution of Plate Gaps'; ods graphics on; ods select Histogram ParameterEstimates GoodnessOfFit FitQuantiles; proc univariate data=Plates; var Gap; histogram / midpoints=0.2 to 1.8 by 0.2 lognormal weibull gamma odstitle = title; inset n mean(5.3) std='Std Dev'(5.3) skewness(5.3) / pos = ne header = 'Summary Statistics'; run;
The ODS SELECT statement restricts the output to the "ParameterEstimates," "GoodnessOfFit," and "FitQuantiles" tables; see the section ODS Table Names. The LOGNORMAL, WEIBULL, and GAMMA primary options request superimposed fitted curves on the histogram in Output 4.22.1. Note that a threshold parameter is assumed for each curve. In applications where the threshold is not zero, you can specify with the THETA= secondary option.
The LOGNORMAL, WEIBULL, and GAMMA options also produce the summaries for the fitted distributions shown in Output 4.22.2 through Output 4.22.4.
Output 4.22.2 provides three EDF goodness-of-fit tests for the lognormal distribution: the Anderson-Darling, the Cramér-von Mises, and the Kolmogorov-Smirnov tests. At the significance level, all tests support the conclusion that the two-parameter lognormal distribution with scale parameter and shape parameter provides a good model for the distribution of plate gaps.
Output 4.22.3 provides two EDF goodness-of-fit tests for the Weibull distribution: the Anderson-Darling and the Cramér–von Mises tests. The p-values for the EDF tests are all less than 0.10, indicating that the data do not support a Weibull model.
Output 4.22.4 provides three EDF goodness-of-fit tests for the gamma distribution: the Anderson-Darling, the Cramér–von Mises, and the
Kolmogorov-Smirnov tests. At the significance level, all tests support the conclusion that the gamma distribution with scale parameter and shape parameter provides a good model for the distribution of plate gaps.
Based on this analysis, the fitted lognormal distribution and the fitted gamma distribution are both good models for the distribution of plate gaps.
A sample program for this example, uniex13.sas, is available in the SAS Sample Library for Base SAS software.