PROC KDE will generate an incorrect bivariate kernel density estimate when the computed values of p-sub-x and p-sub-y are unequal. For details regarding the formula for p, refer to the Convolutions section of PROC KDE in the Online Documentation or "SAS/STAT User's Guide, Version 8, Volume 2".
To circumvent this problem, do not specify a combination of values for the PROC KDE statement options NGRID= , GRIDL= , and GRIDU= that will result in unequal values of p-sub-x and p-sub-y. In general, you can avoid having to compute p with a simple graphical test. It is recommended that you overlay your data values onto a plot of the estimated density and observe the fit. When the estimated density is correct, the values of p are equal and the fit will be good. When the estimated density is incorrect, the values of p are unequal and the fit will be obviously poor. Following is an outline of the code for a graphical test:
/* Output the kernel density estimate */ proc kde data=OriginalDataSet out=KernelDensityEstimate; var X_variable Y_variable; run;
/* create an annotate data for all of your raw data values */
data AnnotateDataSet;
set OriginalDataSet;
retain xsys ysys '2' position '5' function 'label' text '*'
color 'red';
x=X_variable;
y=Y_variable;
run;
/* annotate the raw data values onto a contour plot of the kernel density estimate. the density should coincide with the data values */
proc gcontour data=KernelDensityEstimate;
plot Y_variable*X_variable = density / anno= AnnotateDataSet;
run;