Keywords - Function groups - @ A B C D E F G H I J K L M N O P Q R S T U V W X Y Z

Group: Statistical Data Analysis
Topic: Nonparametric Methods
See also: sker rmed lowess locpoldis

Function: locpol
Description: locpol computes the local polynomial estimator. It is using the quartic kernel.

Usage: locpol(x, xg, y, h, logi)
Input:
x n x d matrix explanatory variables
xg m x d matrix grid points at which the estimation will be done
y n x q matrix dependent variable
h d x 1 matrix vector of bandwidthes
logi logical scalar 0 if linear, 1 if quadratic polynomials are wished
Output:
mh m x dd x q matrix regression function and its v'th derivatives divided by v at xg in the following order: regression function, first derivatives respectively x1, x2, x3, ... , derivatives respectively x1x1, x1x2, ..., x2x2, x2x3, ...

Note:

Example:
logi=1            ; we aim to use local quadratic
d   =2            ; dimension of nonlinear inputs
q   =1            ; dimension of response
n   = 100         ; number of observations
;*****  create data *****
x  = uniform(n,d)
y  =  1.5*x[,1]^2 -x[,2]^3 +normal(n,1)*0.2
h  = 0.4*matrix(d,1)          ; bandwidth vector
xs = sort(x~y,1)
x  = xs[,1:d]
y  = xs[,d+1]
xg = x                        ; 'grid'
mh = locpol(x,xg,y,h,logi)
mh[,1]                        ; regression function
mh[,2]                        ; derivative resp. to x_1
mh[,3]                        ; derivative resp. to x_2
mh[,4]                        ; derivative*0.5 resp. to x_1 x_1
mh[,5]                        ; ...                     x_1 x_2
mh[,6]                        ; ...                     x_2 x_2

Result:
Contents of _tmp

[  1,] -0.13671
[  2,] -0.080934
...
[100,]   1.5635
Contents of _tmp

[  1,] -0.84599
[  2,] -0.70103
...
[100,]   6.0576
Contents of _tmp

[  1,]  -1.2913
[  2,]  0.19572
...
[100,]   3.9349
Contents of _tmp

[  1,]   3.0074
[  2,]   4.5472
...
[100,]     8.44
Contents of _tmp

[  1,]  0.038032
[  2,]  -1.7854
...
[100,]   1.2624
Contents of _tmp

[  1,] -0.89065
[  2,]  0.93055
...
[100,]  -13.268



(C) MD*TECH Method and Data Technologies, 05.02.2006