Local linear regression

Previous Topic Next Topic
classic Classic list List threaded Threaded
2 messages Options
Reply | Threaded
Open this post in threaded view

Local linear regression


Dear all,

I wrote a code which supposedly should create a function which performs a local linear regression at point x (lower case).
The issue is that I have no reference to check if indeed my code performs correctly a local linear regression. Is there any function in R that performs a local linear regression (to give conditional expectation which I am interested in and not graph) in order to double-check the results?

By the way the code that I wrote is the following (based on the equation 2.50 of Li & Racine book's page 81):

#x should be a 1xq matrix, X is a Nxq matrix of the q regressors, Y is the response variable Nx1 matrix,
#bw should the 1xq matrix of bandwidths
LL.reg <- function(Y, X, x, bw){
        N <- nrow(Y)
        q <- ncol(X)
        dX <- X-matrix(x, N, q, T)
        kx <- dnorm(dX/matrix(bw, N, q, T))
        K <- as.vector(apply(kx, 1, function(z) prod(z)))
        cX <- cbind(1, dX)

Thank you all

Reply | Threaded
Open this post in threaded view

Re: Local linear regression

locpoly() might be useful