Blocc                package:JLLprod                R Documentation

_F_a_s_t _L_o_c_a_l _C_o_n_s_t_a_n_t _R_e_g_r_e_s_s_i_o_n _f_o_r _B_i_v_a_r_i_a_t_e _D_a_t_a

_D_e_s_c_r_i_p_t_i_o_n:

     This procedure is a fast implementation of the Nadaraya-Watson
     estimator for conditional mean function such as
     r(x,z)=E[y|X=x,Z=z].

_U_s_a_g_e:

     Blocc(xx, zz, yy, kernel = NULL, ev = NULL, h = NULL)

_A_r_g_u_m_e_n_t_s:

      xx: Numerical: Nx1 vector. XX direction.

      zz: Numerical: Nx1 vector. ZZ direction.

      yy: Numerical: Nx1 vector. Dependent variable.

  kernel: Kernel function. Default is `gauss'.

      ev: Numerical: Mx2 matrix of evaluation points to get smoothed
          values at. The use of ev is highly recommended, as it
          drastically reduces computation time. Default is a 40x2
          matrix covering the entire observed support.

       h: Numerical: 2x1 vector of bandwidths, [hxx,hzz], used in the
          estimation. Default is the Silverman's rule of thumb in each
          direction.

_D_e_t_a_i_l_s:

     User may also choose a variety of kernel functions. For example
     `uniform', `triangular', `quartic', `epanech', `triweight' or
     `gauss', see Yatchew (2003), pp 33. Another choice may be
     `order34', `order56' or `order78', which are third, fifth and
     seventh  (gauss based) order kernel functions, see Pagan and Ullah
     (1999), pp 55.

_V_a_l_u_e:

      r : Numerical: MxM (i,j) matrix of nonparametric estimates or
          r(xxe[i],zze[j]).

    xxe : Numerical: Mx1 vector of evaluation points in the xx
          direction.

    zze : Numerical: Mx1 vector of evaluation points in the zz
          direction.

_N_o_t_e:

     This function may fail for very big values of N or M, because it
     uses matrices and NO loops.

_A_u_t_h_o_r(_s):

     David Toms Jacho-Chvez

_R_e_f_e_r_e_n_c_e_s:

     Yatchew, A. (2003) Semiparametric Regression for the Applied
     Econometrician. Cambridge University Press.

     Pagan, A. and Ullah, A. (1999) Nonparametric Econometrics.
     Cambridge Universtiy Press.

_S_e_e _A_l_s_o:

     'locpoly'

_E_x_a_m_p_l_e_s:

     #A very simple case
     n <- 1000
     x <- runif(n); z <- runif(n); e <- rnorm(n,sd=0.2)
     G <- function(x){(1/2)*sin(2*pi*x)}
     F <- function(z){-1/3+2*z-2*(z^2)}
     y <- G(x)+F(z) + e
     xgrid <- seq(0,1,length=30); zgrid <- seq(0,1,length=30)

     m <- Blocc(xx=x,zz=z,yy=y,ev=cbind(xgrid,zgrid))
     GF <- matrix(G(m$xxe),nr=30,nc=30,byrow=FALSE)+matrix(F(m$zze)
                  ,nr=30,nc=30,byrow=TRUE)

     #win.graph()
     layout(matrix(c(1,2),nr=1,nc=2,byrow=TRUE))
     persp(x=m$zze,y=m$xxe,z=t(GF),theta= 320, phi=17,xlab="z"
           ,ylab="x",zlab="",main="True G(x)+F(z)")
     persp(x=m$zze,y=m$xxe,z=t(m$r),theta= 320, phi=17,xlab="z"
           ,ylab="x",zlab="",main="Estimated G(x)+F(z)")

