<div>Dear Roger Bivand,Tim Keitt, and Dan Putler,<br> 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.
</div>
<div> My dataset has been put in the attachment and programs have been pasted in the following, so that u can use and check it. </div>
<div> I want to do the work like "non-parametric estimation of a spatially varying intensity" in Diggle's book(2003.P.116-121).</div>
<div> BTW, i'm not familiar with locfit,would u please also check it using locfit? Thanks very much.</div>
<div>###############################################################################<br> Kernel density estimation--spatstat<br>################################################################################
<br>library(sp)<br>library(foreign)<br>library(maptools)<br>library(mgcv)<br>library(spatstat)
<p>guichi<-readShapePoly("d:/deleting/kernel/kernel/guichi2.shp") <br>W <-as(as(guichi, "SpatialPolygons"), "owin") #boundary polygons</p>
<p>cases<-coordinates(readShapePoints("d:/deleting/kernel/kernel/cases.shp")) #points<br>colnames(cases)<-c("x","y")<br>cases[1:2,]</p>
<p>#plot(W);points(cases)</p>
<p>pointcase <- ppp(cases[,1], cases[,2], window=W) #generate the ppp object</p>
<p>kdensity<-density.ppp(pointcase, 0.05)<br>plot(kdensity) <br><font color="#ff0000"><strong>Q:</strong>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?
</font></p>
<p>################################################################################<br> Kernel density estimation--splancs<br>################################################################################
<br>library(sp)<br>library(splancs)<br>library(foreign)<br>library(maptools)</p>
<p>case<-readShapePoints("d:/deleting/kernel/kernel/cases.shp")<br>guichi<-readShapePoly("d:/deleting/kernel/kernel/guichi2.shp") </p>
<p>#Conversion<br>case_pts <- coordinates(case) <br>case <- as.points(case_pts) <br>splancs_poly <- getPolygonCoordsSlot(getPolygonsPolygonsSlot(getSpPpolygonsSlot(guichi)[[1]])[[1]]) </p>
<p>#to unpack the coordinates of the points and the single ring boundary <br>polymap(splancs_poly,xlab="x(米)",ylab="y(米)") <br>pointmap(case_pts, add=TRUE) </p>
<p>m<-mse2d(case,splancs_poly,nsmse=1000,range=5) #plots the estimated mean square error as a function of h0<br>plot(m$h[290:1000],m$mse[290:1000],type="l")</p>
<p>n<-which(m$mse==min(m$mse)) <br>h0<-m$h[n]</p>
<p><br>#smooth variation<br>smooth<-kernel2d(case, splancs_poly, h0=h0, nx=100, ny=100)<br>polymap(splancs_poly) #sets the axes correctly and draws the polygon<br>image(smooth,add=T) #the smoothed image is superimposed
<br>polymap(splancs_poly,add=T) #redrawn the polymap in order not to be obsured by smooth image<br><font color="#ff0000"><strong>Q</strong>:The result is still not satisfied,there must be something wrong with my programs</font>
.</p>
<p> </p>
<p> </p><br><br> </div>
<div><span class="gmail_quote">On 6/25/07, <b class="gmail_sendername">Dan Putler</b> <<a href="mailto:putler@sauder.ubc.ca">putler@sauder.ubc.ca</a>> wrote:</span>
<blockquote class="gmail_quote" style="PADDING-LEFT: 1ex; MARGIN: 0px 0px 0px 0.8ex; BORDER-LEFT: #ccc 1px solid">Hi All,<br><br>To add some detail to Roger's earlier, post density.ppp in the<br>spatstat seems to be a very good answer to the original post since it
<br>is specifically designed to estimate a kernel density for a point<br>process pattern. This function use a bivariate Gaussian smoother that<br>lends itself to user configuration.<br><br>Dan<br><br>On 24-Jun-07, at 5:28 PM, Tim Keitt wrote:
<br><br>> I rather like locfit.<br>><br>> THK<br>><br>> On 6/24/07, zhijie zhang <<a href="mailto:epistat@gmail.com">epistat@gmail.com</a>> wrote:<br>>> Dear Friends,<br>>> Except kernel2d(splancs) function, are there any other functions
<br>>> on kernel<br>>> density estimation in point pattern analysis? I use the kernel2d<br>>> (splancs)<br>>> function to anayze my dataset, and the result seems not to be very<br>>> good.<br>
>> Any suggestions or help in kernel density estimation of<br>>> univariate or<br>>> multivariate point process are greatly appreciated.<br>>> BTW, i mainly want ot do the kernel density estimation in both
<br>>> univariate and multivariate point process.<br>>> --<br>>> With Kind Regards,<br>>><br>>> oooO:::::::::<br>>> (..):::::::::<br>>> :\.(:::Oooo::<br>>> ::\_)::(..)::<br>
>> :::::::)./:::<br>>> ::::::(_/::::<br>>> :::::::::::::<br>>> [********************************************************************<br>>> ***]<br>>> Zhi Jie,Zhang ,PHD<br>>> Tel:86-21-54237149
<br>>> Dept. of Epidemiology,School of Public Health,Fudan University<br>>> Address:No. 138 Yi Xue Yuan Road,Shanghai,China<br>>> Postcode:200032<br>>> <a href="mailto:Email:epistat@gmail.com">Email:epistat@gmail.com
</a><br>>> Website: <a href="http://www.statABC.com">www.statABC.com</a><br>>> [********************************************************************<br>>> ***]<br>>> oooO:::::::::<br>>> (..):::::::::
<br>>> :\.(:::Oooo::<br>>> ::\_)::(..)::<br>>> :::::::)./:::<br>>> ::::::(_/::::<br>>> :::::::::::::<br>>><br>>> [[alternative HTML version deleted]]<br>>><br>>> _______________________________________________
<br>>> R-sig-Geo mailing list<br>>> <a href="mailto:R-sig-Geo@stat.math.ethz.ch">R-sig-Geo@stat.math.ethz.ch</a><br>>> <a href="https://stat.ethz.ch/mailman/listinfo/r-sig-geo">https://stat.ethz.ch/mailman/listinfo/r-sig-geo
</a><br>>><br>><br>><br>> --<br>> Timothy H. Keitt, University of Texas at Austin<br>> Contact info and schedule at <a href="http://www.keittlab.org/tkeitt/">http://www.keittlab.org/tkeitt/</a><br>> Reprints at
<a href="http://www.keittlab.org/tkeitt/papers/">http://www.keittlab.org/tkeitt/papers/</a><br>> ODF attachment? See <a href="http://www.openoffice.org/">http://www.openoffice.org/</a><br>><br>> _______________________________________________
<br>> R-sig-Geo mailing list<br>> <a href="mailto:R-sig-Geo@stat.math.ethz.ch">R-sig-Geo@stat.math.ethz.ch</a><br>> <a href="https://stat.ethz.ch/mailman/listinfo/r-sig-geo">https://stat.ethz.ch/mailman/listinfo/r-sig-geo
</a><br><br></blockquote></div><br><br clear="all"><br>-- <br>With Kind Regards,<br><br>oooO:::::::::<br>(..)::::::::: <br>:\.(:::Oooo:: <br>
::\_)::(..):: <br>:::::::)./::: <br>::::::(_/:::: <br>:::::::::::::<br>[***********************************************************************]
<br>Zhi Jie,Zhang ,PHD <br>Tel:86-21-54237149 <br>Dept. of Epidemiology,School of Public Health,Fudan University <br>Address:No. 138 Yi Xue Yuan Road,Shanghai,China <br>Postcode:200032 <br><a href="mailto:Email:epistat@gmail.com">
Email:epistat@gmail.com</a> <br>Website: <a href="http://www.statABC.com">www.statABC.com</a><br>[***********************************************************************]<br>oooO:::::::::<br>(..):::::::::
<br>:\.(:::Oooo:: <br>::\_)::(..):: <br>:::::::)./::: <br>::::::(_/:::: <br>:::::::::::::