4
I’m trying to calculate the intensity of a point pattern with "Smooth kernel" (sorry, I don’t know how to translate this). Before executing Smooth kernel code, you need to specify a histogram bandwidth for your data. Several different widths are possible, and a common guideline is to calculate the mean of the square errors ("Mean Squared Error", from now on MSE) of the distribution and use the lowest value at the beginning.
A function of the package splancs
to calculate MSE is mse2d()
, specified with four arguments:
mse2d(pts,poly,nsmse,range)
being pts
the distribution of points, poly
a polygon representing the area where the points are, nsmse
is the number of histogram bands for which MSE is to be calculated, and range
is the maximum bandwidth for MSE.
My problem is the argument poly
. How to specify the script for this polygon? I couldn’t find any guidance in the splancs documentation.
In the book Applied Spatial Data Analysis with R, Bivand, Pebesma and Gómez-Rubio (2013), has an example with the data set Redwood
of spatstats
:
library(spatstat)
data(redwood)
spred<-as(redwood, "SpatialPoints")
library(splancs)
mserwq <- mse2d(as.points(coordinates(spred)), as.points(list(x = c(0,
+ 1, 1, 0), y = c(0, 0, 1, 1))), 100, 0.15)
bwq <- mserwq$h[which.min(mserwq$mse)]
bwq
This example works perfectly. But when I replicate this script with my data it returns an error. See:
#Melocactus data
m23.Xs<-c(17349,13212,11551,16659,9461,12062,12802,9638,9835,9803)
m23.Ys<-c(576,13600,6372,11763,11081,5462,15802,11667,11552,11121)
loc23<-matrix(c(m23.Xs,m23.Ys),nrow=10,byrow=FALSE)
MSEm23<-mse2d(as.points(coodinates(loc.m23),as.points
+(list(x=c(0,20000,20000,0),y=c(0,0,20000,20000))),100,0.15))
Erro em storage.mode(poly) <- "double" :
argumento "poly" ausente, sem padrão
I cannot solve this error. I have tried to specify the polygon with a "owin" object and matrix, and the same error continues. Does anyone know how to specify a polygon in the splancs?
Any comment from you will be great. Thank you for anticipation.
Hugs, Leila