Group: | Statistical Data Analysis |
Topic: | Nonparametric Methods |
See also: | sker rmed lowess locpol |
Function: | locpoldis | |
Description: | locpoldis computes the local polynomial estimator without mixed terms but allows for including a linear part in the regression model. It is using the quartic kernel. |
Usage: | locpoldis(x, xg, y, h, logi {, xd}) | |
Input: | ||
x | n x d matrix nonlinear inputs | |
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 | |
xd | n x dis matrix optional, inputs for the linear part | |
Output: | ||
mh | m x dd x q matrix regression of the nonlinear part and its v'th derivatives divided by v at xg in the following order: regression function, first derivatives respectively x1, x2, x3, ..., second derivative*0.5 respectively x1, x2, x3, ... |
logi=1 ; we aim to use local quadratic d =2 ; dimension of nonlinear inputs dis =1 ; dimension of discrete influence q =1 ; dimension of response n = 100 ; number of observations ;***** create data ***** x = uniform(n,d) xd = uniform(n,dis) xd =(xd.>(1/3)) y = 1.5*x[,1]^2 -x[,2]^3 +xd*(0.5) +normal(n,1)*0.2 h = 0.4*matrix(d,1) ; bandwidth vector xs = sort(x~xd~y,1) x = xs[,1:d] xd = xs[,(d+1):(d+dis)] y = xs[,d+dis+1] xg = x ; 'grid' mh = locpoldis(x,xg,y,h,logi,xd) 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_2 x_2
Contents of _tmp [ 1,] -1.0606 [ 2,] -0.14172 ... [100,] 1.2935 Contents of _tmp [ 1,] 2.8621 [ 2,] 1.1122 ... [100,] 1.535 Contents of _tmp [ 1,] 0.25281 [ 2,] -0.56869 ... [100,] -0.81995 Contents of _tmp [ 1,] -6.4567 [ 2,] -3.3899 ... [100,] -3.0269 Contents of _tmp [ 1,] 7.9354 [ 2,] -2.9056 ... [100,] -0.3416