1

I'm analyzing traffic accidents with injuries and deaths of the Bogota city. The data contains the location of 9108 accidents of the year 2015 on a road network of 8218901 meters in length, they were divided by months and each month contain on overage 800 points (accidents). I am analyzing these data as a point pattern on a linear network using the spatstat package of R.

When I use density.lpp() with kernel Gaussian

## Todo.lpp it's the point pattern on the linear network
## npoints(Todo_lpp) = 9108 ; volume(domain(Todo_lpp)) = 8218901
density.lpp(Todo_lpp, sigma = 1000)

I obtain this "Error: $ operator is invalid for atomic vectors". With kernel Epanechnikov:

density.lpp(Todo_lpp, sigma = 1000, kernel = "epanechnikov")

I obtain: "Error in makeunitname(s[1], s[1]) : In unit name, first entry should be a character string".

To correct the error I used a server thinking that it was memory of the laptop and it didn't work. I tried with a some bandwith and I obtain the same error. I also tried decreasing the number of points and size of the network and the function density.lpp() worked for a point pattern on a network of 45113 meters in length with 102 events, but for a point pattern on a network of 129604.4 meters in length with 46 points didn't work.

  1. Does the density.lpp() function have any restrictions on the shape of the network of the point pattern?
  2. Is there any way to find an optimal bandwidth for smoothing kernel over a linear network?
  3. Does the density() function have any restrictions as to the number of points of the point pattern?

When I used: densidad_2015 <- density.lpp(Bogota_2015, sigma = 1000) I obtain "Error: $ operator is invalid for atomic vectors", then I used traceback() and got the following :

    ..... 1, 1, 0.543675672992009, 0.917333284484343, 0.709566697706099, 
    1, 1, 0.377473064517719, 1, 0.310630352751969, 1, 0.490405224740971, 
    1, 1, 1))
    5: do.call(X, append(as.list(coo), list(...)))
    4: as.linim.linfun(f, ...)
    3: as.linim(f, ...)
    2: PDEdensityLPP(x, sigma, ..., weights = weights)
    1: density.lpp(Bogota_2015, sigma = 1000)

When I used: densidad_2015 <- density.lpp(Bogota_2015, sigma = 5, kernel = "epanechnikov") I obtain "Error in makeunitname(s[1], s[1]) : In unit name, first entry should be a character string", then I used traceback() and got the following :

14: stop("In unit name, first entry should be a character string")
13: makeunitname(s[[1]], s[[1]])
12: as.unitname(x$units)
11: unitname.owin(W)
10: unitname(W)
9: as.unitname(unitname)
8: owin(W$xrange, W$yrange, poly = W$bdry, mask = W$m, unitname = unitname(W), 
       check = FALSE)
7: as.owin.owin(A)
6: as.owin(A)
5: is.subset.owin(i, as.owin(x))
4: `[.im`(Z, M, drop = FALSE)
3: Z[M, drop = FALSE]
2: linim(L, Z, df = df)
1: density.lpp(Bogota_2015, sigma = 5, kernel = "epanechnikov")

Below I attach the images of 2 of the 19 localities that Bogotá has with which I performed the tests of the function density.lpp().

The image with the blue road network corresponds to 46 points (the function density.lpp() didn't work) and the image with the green network to 102 points (the function density.lpp() worked).

Point pattern with 46 events

Point pattern with 102 events

Ines
  • 11
  • 2
  • Generally the error about `$` means you're trying to apply `x$y` notation to an object `x` that is not a list. It's hard to say exactly since it's not clear to me what the `density.lpp()` function does and what kind of object it returns. – kgolyaev Feb 22 '18 at 04:27
  • In principle there are no restrictions on the network size and shape, but maybe your network has some degeneracy the code doesn't cover. It would be much easier to say if you could provide a reproducible example. Would it be possible for you to share your data? Regarding bandwidth selection: It is difficult in any domain... – Ege Rubak Feb 22 '18 at 04:50
  • Please type `traceback()` immediately after the error occurs, save the output of the traceback, and copy it to this page, so we can figure out where the error comes from. – Adrian Baddeley Feb 22 '18 at 09:01
  • Thanks for your reply. In the upper part is what I got when I use traceback (). I couldn't find how to attach a file on the platform, this is my email icmoncadaf@unal.edu.co to contact us and send you the data and the script. I also attached two images that show the point patterns in the linear network that I mentioned of 46 and 102 points. Awaiting your comments. – Ines Feb 23 '18 at 00:03
  • The output suggests there is something wrong with the internal format of the object `Bogota_2015`. We will exchange data and investigate. – Adrian Baddeley Feb 23 '18 at 06:56
  • This bug has now been fixed. – Adrian Baddeley Mar 18 '18 at 09:37

0 Answers0