functions on kernel density estimation in pointpattern analysis
Dear Roger Bivand,Tim Keitt, and Dan Putler,
Thanks for your answers. I have tried density.ppp(spatstat) and
kernel2d(splancs), but the results are not very satisfied. I think there
should be a higher density in the blue part of the map in the attachment.
My dataset has been put in the attachment and programs have been pasted in
the following, so that u can use and check it.
I want to do the work like "non-parametric estimation of a spatially
varying intensity" in Diggle's book(2003.P.116-121).
BTW, i'm not familiar with locfit,would u please also check it using
locfit? Thanks very much.
###############################################################################
Kernel density estimation--spatstat
################################################################################
library(sp)
library(foreign)
library(maptools)
library(mgcv)
library(spatstat)
guichi<-readShapePoly("d:/deleting/kernel/kernel/guichi2.shp")
W <-as(as(guichi, "SpatialPolygons"), "owin") #boundary polygons
cases<-coordinates(readShapePoints("d:/deleting/kernel/kernel/cases.shp"))
#points
colnames(cases)<-c("x","y")
cases[1:2,]
#plot(W);points(cases)
pointcase <- ppp(cases[,1], cases[,2], window=W) #generate the ppp object
kdensity<-density.ppp(pointcase, 0.05)
plot(kdensity)
*Q:*there are almost the same density in the whole area,but in fact it may
have a higher density in the blue part of the attached map? I think the
problem may the inappropriate value of sigma, how to determine its value?
################################################################################
Kernel density estimation--splancs
################################################################################
library(sp)
library(splancs)
library(foreign)
library(maptools)
case<-readShapePoints("d:/deleting/kernel/kernel/cases.shp")
guichi<-readShapePoly("d:/deleting/kernel/kernel/guichi2.shp")
#Conversion
case_pts <- coordinates(case)
case <- as.points(case_pts)
splancs_poly <-
getPolygonCoordsSlot(getPolygonsPolygonsSlot(getSpPpolygonsSlot(guichi)[[1]])[[1]])
#to unpack the coordinates of the points and the single ring boundary
polymap(splancs_poly,xlab="x(?)",ylab="y(?)")
pointmap(case_pts, add=TRUE)
m<-mse2d(case,splancs_poly,nsmse=1000,range=5) #plots the estimated mean
square error as a function of h0
plot(m$h[290:1000],m$mse[290:1000],type="l")
n<-which(m$mse==min(m$mse))
h0<-m$h[n]
#smooth variation
smooth<-kernel2d(case, splancs_poly, h0=h0, nx=100, ny=100)
polymap(splancs_poly) #sets the axes correctly and draws the polygon
image(smooth,add=T) #the smoothed image is superimposed
polymap(splancs_poly,add=T) #redrawn the polymap in order not to be obsured
by smooth image
*Q*:The result is still not satisfied,there must be something wrong with my
programs.
On 6/25/07, Dan Putler <putler at sauder.ubc.ca> wrote:
Hi All, To add some detail to Roger's earlier, post density.ppp in the spatstat seems to be a very good answer to the original post since it is specifically designed to estimate a kernel density for a point process pattern. This function use a bivariate Gaussian smoother that lends itself to user configuration. Dan On 24-Jun-07, at 5:28 PM, Tim Keitt wrote:
I rather like locfit. THK On 6/24/07, zhijie zhang <epistat at gmail.com> wrote:
Dear Friends,
Except kernel2d(splancs) function, are there any other functions
on kernel
density estimation in point pattern analysis? I use the kernel2d
(splancs)
function to anayze my dataset, and the result seems not to be very
good.
Any suggestions or help in kernel density estimation of
univariate or
multivariate point process are greatly appreciated.
BTW, i mainly want ot do the kernel density estimation in both
univariate and multivariate point process.
--
With Kind Regards,
oooO:::::::::
(..):::::::::
:\.(:::Oooo::
::\_)::(..)::
:::::::)./:::
::::::(_/::::
:::::::::::::
[********************************************************************
***]
Zhi Jie,Zhang ,PHD
Tel:86-21-54237149
Dept. of Epidemiology,School of Public Health,Fudan University
Address:No. 138 Yi Xue Yuan Road,Shanghai,China
Postcode:200032
Email:epistat at gmail.com
Website: www.statABC.com
[********************************************************************
***]
oooO:::::::::
(..):::::::::
:\.(:::Oooo::
::\_)::(..)::
:::::::)./:::
::::::(_/::::
:::::::::::::
[[alternative HTML version deleted]]
_______________________________________________ R-sig-Geo mailing list R-sig-Geo at stat.math.ethz.ch https://stat.ethz.ch/mailman/listinfo/r-sig-geo
-- Timothy H. Keitt, University of Texas at Austin Contact info and schedule at http://www.keittlab.org/tkeitt/ Reprints at http://www.keittlab.org/tkeitt/papers/ ODF attachment? See http://www.openoffice.org/
_______________________________________________ R-sig-Geo mailing list R-sig-Geo at stat.math.ethz.ch https://stat.ethz.ch/mailman/listinfo/r-sig-geo
With Kind Regards, oooO::::::::: (..)::::::::: :\.(:::Oooo:: ::\_)::(..):: :::::::)./::: ::::::(_/:::: ::::::::::::: [***********************************************************************] Zhi Jie,Zhang ,PHD Tel:86-21-54237149 Dept. of Epidemiology,School of Public Health,Fudan University Address:No. 138 Yi Xue Yuan Road,Shanghai,China Postcode:200032 Email:epistat at gmail.com Website: www.statABC.com [***********************************************************************] oooO::::::::: (..)::::::::: :\.(:::Oooo:: ::\_)::(..):: :::::::)./::: ::::::(_/:::: ::::::::::::: -------------- next part -------------- An HTML attachment was scrubbed... URL: <https://stat.ethz.ch/pipermail/r-sig-geo/attachments/20070625/0a7b4e57/attachment.html> -------------- next part -------------- A non-text attachment was scrubbed... Name: data.rar Type: application/octet-stream Size: 8653 bytes Desc: not available URL: <https://stat.ethz.ch/pipermail/r-sig-geo/attachments/20070625/0a7b4e57/attachment.obj> -------------- next part -------------- A non-text attachment was scrubbed... Name: map.jpg Type: image/jpeg Size: 20460 bytes Desc: not available URL: <https://stat.ethz.ch/pipermail/r-sig-geo/attachments/20070625/0a7b4e57/attachment.jpg>