kdensity(longitude,latitude,kilometer=FALSE,noplot=FALSE,
dmin=0,dmax=0,dlength=512,h=0,kern="gaussian",nsamp=0,
confint=TRUE,pval=.05)
dfit1 <- density(dvect,from=dmin,to=dmax,n=dlength,kernel=kern,bw=h) dfit2 <- density(-dvect,from=dmin,to=dmax,n=dlength,kernel=kern,bw=h) distance <- dfit1$x dhat <- dfit1$y + dfit2$y
Local standard errors are calculated using the following asymptotic formula:
$(nh)^{-.5} (f(x) \int K^2(\psi)d \psi )^{.5} $
Klier Thomas and Daniel P. McMillen, "Evolving Agglomeration in the U.S. Auto Industry," Journal of Regional Science 48 (2008), 245-267.
Silverman, A. W., Density Estimation for Statistics and Data Analysis, Chapman and Hall, New York (1986).
data(matchdata)
lmat <- cbind(matchdata$longitude,matchdata$latitude)
# Smaller sample to reduce computation time for example
set.seed(18493)
obs <- sample(seq(1,nrow(lmat)),400)
lmat <- lmat[obs,]
fit95 <- kdensity(lmat[,1],lmat[,2],noplot=FALSE)
Run the code above in your browser using DataLab