SECTION 19 NONPARAMETRIC METHODS

SECTION 19.1 DENSITY ESTIMATION

For references, see B. W. Silverman, *Density Estimation
for Statistics and Data Analysis*, Chapman and Hall, 1986. To
estimate the density function of a set of data, use

CALL DENS(X,H,IH,ABSC,ORD,N,NVAL,KERNEL,EPS,FINT,WK)

where

X = a REAL*8 array dimensiond X(N) containing the data

H = the window width

IH = 1 if automatic computation of H is desired, 0 otherwise

ABSC = a REAL*8 array dimensioned ABSC(NVAL) which will contain
the NVAL abscissa values at which the density will be evaluated

ORD = a REAL*8 array dimensioned ORD(NVAL) in which the density ordinates will be
placed

N = the number of data points

NVAL = the number of required abscissa values

KERNEL = 1 if Gaussian kernel is desired

KERNEL = 2 if Epanechnikov kernel is desired

KERNEL = 3 if Bisquare kernel is desired

KERNEL = 4 if absolute value kernel is desired

KERNEL = 5 if all of the above are desired

EPS = an input quantity such that abscissas will range from
min(X)-H-EPS to max(X)+H+EPS

FINT = the (approximate) integral of the plotted density,
calculated as the interval between plotted abscissa points times
the sum of the ordinates

WK = a REAL*8 work array dimensioned WK(N)

The call to DENS4 produces as output, as do several other programs in GQOPT, a MATHEMATICA program that can be run after the user invokes MATHEMATICA. (See Section 18.2 for how to obtain MATHEMATICA.) This program is placed in the file DENS.PR. This file is written to UNIT 12 with open statement is

OPEN (UNIT=12,FILE='DENS.PR',STATUS= 'UNKNOWN')

and should not be used for other purposes. The user should then start MATHEMATICA, to which MATHEMATICA would normally respond by typing on the screen the prompt

In[1]:=

The user should now direct MATHEMATICA to take its input from the file DENS.PR, which is accomplished by replying to the prompt as follows:

In[1]:=<<dens.pr

SECTION 19.2 KERNEL REGRESSION (KERREG)

For references, see Haerdle, Wolfgang, *Applied
Nonparametric Analysis*, Cambridge University press, 1990;
Chu,C.-K. and J. S. Marron, "Choosing a Kernel Regression
Estimator," *Statistical Science*, 6 (1991), 403-436,
Hart, J. D. and T. E. Wehrly, "Kernel Regression When the
Boundary Area Is Large, with an Application to Testing the
Adequacy of Polynomial Models," *Journal of the American
Statistical Association*, 87 (1992), 1018-1024. Kernel
regression provides the appropriate regression function for data
generated by

y=f(x)+u,

where x is the regressor, y the dependent variable, and u an error term. The call to KERREG is

CALL KERREG(X,Y,U,S,N,M,KER,H,IGM,IHW,CONF,IER)

where

X = (input) one dimensional array of length n, where n is the
number of observations, on the independent variable (REAL*8)

Y = (input) a one-dimensional array of length n on the dependent
variable (REAL*8)

U = an array dimensioned n x 3, which is a work array (REAL*8)

S = a one-dimensional work array dimensioned as follows:
DIMENSION S(0:m), where m is the number of points at which the
regression function is displayed (REAL*8)

KER = (input) the kernel used;

KER = 1 for Gaussian,

KER = 2 for bi-square,

KER = 3 for tri-cube, and

KER = 4 for Epanechnikov; i.e.,

K(x)=(1./(2pi)^{1/2})e^{-x}^{2}^{/2}for KER=1 K(x)=(1-x^{2})^{2}for KER=2 K(x)=(1-x^{3})^{3 }for KER=3 K(x)=(1-x^{2}) for KER=4 when |x|<1 and =0 otherwise

H = (input) window width (REAL*8) IGM = (input) = 1 Gasser-Mueller treatment, IGM = 0 no Gasser Mueller (only if ker = 1 or 2 or 3) IGH = (input) = 1 Hart-Wehrly treatment (relevant only if IGM =1), IGH = 0 no Hart-Wehrly CONF= (input) confidence level required (i.e., 0.95) (REAL*8) IER = (output) error return;= 0 normal return, = -3 input error

The call to KERREG produces as output, as do several other programs in GQOPT, a MATHEMATICA program that can be run after the user invokes MATHEMATICA. (See Section 18.2 for how to obtain MATHEMATICA.) This program is placed in the file KERREG.PR. This file is written to UNIT 12 with an open statement

OPEN (UNIT=12,FILE='KERREG.PR',STATUS= 'UNKNOWN')

and should not be used for other purposes. The user should then start MATHEMATICA, to which MATHEMATICA would normally respond by typing on the screen the prompt

In[1]:=

The user should now direct MATHEMATICA to take its input from the file KERREG.PR, which is accomplished by replying to the prompt as follows:

In[1]:=<<kerreg.pr

Five diagrams will be displayed: the first is the scatter diagram, the second is the fitted regression, the third one is the upper confidence contour, the fourth one is the lower confidence contour, and the fifth is the superposition of diagrams 2, 3, and 4. One may proceed from one diagram to the next by pressing ESC.