[R] Local linear regression: where can I find kernels?
Hi there, What I'm trying to do is to calculate the line coefficients of a local linear regression model by hand. I'm aware that there are many great packages out there that calculate the local expectation E(y|x) with local linear regression, but that's not what I need. I need the coefficients of the line that was fitted locally. So, does anybody know of a package that gets me those coefficients? If not, I would calculate the values by hand with a local least square fit using kernel weights on my data. To do so, I need a function that calculates kernel weights, i.e. K_h(x-x_i). Which function can I use? Any help would be greatly appreciated! Best regards, Philipp __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
[R] local linear and local constant kernel regression with np
Hi there, I ran into a weird problem using the np-package doing some local linear kernel regression. Whenever I run the function npregbw(...) with the option regtype=ll (local linear modelling), my optimal bandwidth is supposed to be 1278946. This is kind of funny, because my regressor data (189 data points) only runs from about 3.4 to about 5.9. So, what I get as a result is a nice and straight line, the same one I would get if I would run a normal linear regression. Whenever I set the option regtype=lc (i.e. local constant modelling), the optimal bandwidth is calculated as 0.795 - which sounds right to me. Any ideas / similar experiences? Thanks! Philipp __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
[R] Regression using mapply?
Hi, I have huge matrices in which the response variable is in the first column and the regressors are in the other columns. What I wanted to do now is something like this: #this is just to get an example-matrix DataMatrix - rep(1,1000); Disturbance - rnorm(900); DataMatrix[101:1000] - DataMatrix[101:1000]+Disturbance; DataMatrix - matrix(DataMatrix,ncol=10,nrow=100); #estimate univariate linear model with each regressor-column, response in the first column for(i in 2:10){ result - lm(DataMatrix[,1]~DataMatrix[,i]) } Is there any way to get rid of the for-loop using mapply (or some other function)? Thanks! Philipp __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.