search for: kernden

Displaying 1 result from an estimated 1 matches for "kernden".

2012 Jul 17
1
about different bandwidths in one graph
...Gaussian kernel. The following is my code: ######################################################### # Define the Epanechnikov kernel function kernel<-function(x){0.75*(1-x^2)*(abs(x)<=1)} ############################################################### # Define the kernel density estimator kernden=function(x,z,h,ker){ # parameters: x=variable; h=bandwidth; z=grid point; ker=kernel nz<-length(z) nx<-length(x) x0=rep(1,nx*nz) dim(x0)=c(nx,nz) x1=t(x0) x0=x*x0 x1=z*x1 x0=x0-t(x1) if(ker==1){x1=kernel(x0/h)} # Epanechnikov kernel if(ker==0){x1=dnorm(x0/h)} # normal k...