The following example illustrates the basic features of PROC KDE. Assume that 1000 observations are simulated from a bivariate normal density with means (0 , 0), variances (10 , 10), and covariance 9. The SAS DATA step to accomplish this is as follows :
data bivnormal; seed = 1283470; do i = 1 to 1000; z1 = rannor(seed); z2 = rannor(seed); z3 = rannor(seed); x = 3*z1+z2; y = 3*z1+z3; output; end; drop seed; run;
The following statements request a bivariate kernel density estimate for the variables x and y .
ods html; ods graphics on; proc kde data=bivnormal; bivar x y / plots=contour surface; run; ods graphics off; ods html close;
A contour plot and a surface plot of the estimate are displayed in Figure 36.1 and Figure 36.2, respectively. Note that the correlation of 0 . 9 in the original data results in oval-shaped contours . These graphical displays are requested by specifying the experimental ODS GRAPHICS statement and the experimental PLOTS= option in the BIVAR statement. For general information about ODS graphics, see Chapter 15, Statistical Graphics Using ODS. For specific information about the graphics available in the KDE procedure, see the ODS Graphics section on page 2009.
The default output tables for this analysis are as follows.
Inputs Data Set WORK.BIVNORMAL Number of Observations Used 1000 Variable 1 x Variable 2 y Bandwidth Method Simple Normal Reference
The Inputs table lists basic information about the density fit, including the input data set, the number of observations, and the variables. The bandwidth method is the technique used to select the amount of smoothing in the estimate. A simple normal reference rule is used for bivariate smoothing.
Controls x y Grid Points 60 60 Lower Grid Limit 11.25 10.05 Upper Grid Limit 9.1436 9.0341 Bandwidth Multiplier 1 1
The Controls table lists the primary numbers controlling the kernel density fit. Here a 60 — 60 grid is fit to the entire range of the data, and no adjustment is made to the default bandwidth.