Chapter Contents

Previous

Next
The UNIVARIATE Procedure

Example 8: Fitting Density Curves


Procedure features:
PROC UNIVARIATE statement options:
NOPRINT
HISTOGRAM statement options:
CBARLINE=
CFILL=
EXP
FILL
L=
MIDPOINTS=
NOPRINT
NORMAL
VAR statement
Other features:
GOPTIONS statement
RANNOR function
RANEXP function

This example


Program

options nodate pageno=1 linesize=80 pagesize=60;
 Note about code
goptions htitle=4 htext=3 ftext=swissb ftitle=swissb;
 Note about code
data distrdata;
   drop n;
   label Normal_x='Normal Random Variable'
         Exponential_x='Exponential Random Variable';
   do n=1 to 100;
      Normal_x=10*rannor(53124)+50;
      Exponential_x=ranexp(18746363);
      output;
   end;
run;   
 Note about code
proc univariate data=distrdata noprint;
   var Normal_x;
 Note about code
histogram Normal_x /normal(noprint) cbarline=grey ;
 Note about code
title '100 Obs Sampled from a Normal Distribution';
run;
 Note about code
proc univariate data=distrdata noprint;
  var Exponential_x;
 Note about code
   histogram /exp(fill l=3) cfill=yellow midpoints=.05 to 5.55 by .25;
 Note about code
title '100 Obs Sampled from an Exponential Distribution';
run;


Output

A Histogram Superimposed with Normal Curve

[IMAGE]

The output includes parameters estimates for the exponential curve. The exponential parameter threshold parameter [IMAGE] is 0 because the THETA= option was omitted. A maximum likelihood estimate is computed for the scale parameter [IMAGE].

PROC UNIVARIATE provides three goodness-of-fit tests for the exponential distribution that are based on the empirical distribution function. The p-values for the exponential distribution are larger than the usual cutoff values of 0.05 and 0.10, which indicates not to reject the null hypothesis that the data are exponentially distributed.

[HTML Output]
 [Listing Output]

A Histogram Superimposed with an Exponential Curve

[IMAGE]


Chapter Contents

Previous

Next

Top of Page

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